Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jiahan Cao
Aircraft-Battle
Commits
0e93ef7e
Commit
0e93ef7e
authored
May 28, 2019
by
CjhGm
Browse files
add plane image
parent
8ca314c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
PlaneWar-MFC-master/PlaneWar/MyPlane.cpp
View file @
0e93ef7e
#include "StdAfx.h"
#include "MyPlane.h"
#include "Resource.h"
#include <iostream>
//战机类实现
...
...
@@ -22,13 +23,13 @@ CMyPlane::~CMyPlane(void)
{
}
//绘制战机
BOOL
CMyPlane
::
Draw
(
CDC
*
pDC
,
BOOL
bPause
,
BOOL
isProtect
)
BOOL
CMyPlane
::
Draw
(
CDC
*
pDC
,
BOOL
bPause
,
BOOL
isProtect
)
{
if
(
bPause
==
0
)
{
if
(
isProtect
==
TRUE
)
{
CPoint
point
;
point
.
x
=
mPoint
.
x
-
25
;
point
.
y
=
mPoint
.
y
-
30
;
point
.
x
=
mPoint
.
x
-
25
;
point
.
y
=
mPoint
.
y
-
30
;
imagespro
.
Draw
(
pDC
,
0
,
point
,
ILD_TRANSPARENT
);
}
if
(
index
==
1
)
{
...
...
@@ -50,7 +51,7 @@ BOOL CMyPlane::Draw(CDC* pDC, BOOL bPause,BOOL isProtect)
}
BOOL
CMyPlane
::
Draw
(
CDC
*
pDC
,
BOOL
bPause
)
{
if
(
bPause
==
0
)
{
return
images
.
Draw
(
pDC
,
index
,
mPoint
,
ILD_TRANSPARENT
);
return
images
.
Draw
(
pDC
,
index
,
mPoint
,
ILD_TRANSPARENT
);
}
return
FALSE
;
}
...
...
@@ -71,7 +72,7 @@ BOOL CMyPlane::LoadImage()
return
FALSE
;
//cx,cy 图片的宽度
//图像链表中加入对象对应的图标对象,之后直接通过该链表访问图标对象
images
.
Add
(
&
me
,
RGB
(
0
,
0
,
0
));
images
.
Add
(
&
me
,
RGB
(
0
,
0
,
0
));
images1
.
Add
(
&
me1
,
RGB
(
0
,
0
,
0
));
return
TRUE
;
...
...
@@ -90,7 +91,7 @@ BOOL CMyPlane::LoadImageProtect() {
return
FALSE
;
//cx,cy 图片的宽度
//图像链表中加入对象对应的图标对象,之后直接通过该链表访问图标对象
imagespro
.
Add
(
&
protect
,
RGB
(
255
,
255
,
255
));
imagespro
.
Add
(
&
protect
,
RGB
(
255
,
255
,
255
));
//imagespro.Add(&protectme2, RGB(255, 255, 255));
return
TRUE
;
}
...
...
@@ -101,7 +102,7 @@ BOOL CMyPlane::isFire()//
}
void
CMyPlane
::
SetIsUpdate
(
BOOL
isUpdate
)
{
this
->
index
=
isUpdate
;
this
->
index
=
isUpdate
;
}
BOOL
CMyPlane
::
GetIsUpdate
()
{
return
index
;
...
...
PlaneWar-MFC-master/PlaneWar/PlaneWarView.cpp
View file @
0e93ef7e
...
...
@@ -4,6 +4,7 @@
#include "stdafx.h"
#include <mmsystem.h>
#include <iostream>
#pragma comment(lib, "WINMM.LIB")
#include <MMSYSTEM.H>
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
...
...
@@ -213,17 +214,9 @@ void CPlaneWarView::OnTimer(UINT_PTR nIDEvent)
//替换cdc原本的缓冲区为缓冲位图,这样cdc输出的内容就写到了缓冲位图中
CBitmap
*
pOldBit
=
cdc
.
SelectObject
(
cacheBitmap
);
//输出背景
if
(
isStarted
==
FALSE
)
scene
.
StickScene
(
&
cdc
,
-
1
,
rect
);
else
scene
.
StickScene
(
&
cdc
,
passNum
,
rect
);
if
(
nIDEvent
==
4
)
{
//滚动背景
scene
.
MoveBg
();
}
//欢迎界面
if
(
isStarted
==
FALSE
)
{
//欢迎界面
scene
.
StickScene
(
&
cdc
,
-
1
,
rect
);
startIMG
.
Draw
(
&
cdc
,
0
,
CPoint
(
rect
.
right
/
2
-
173
,
100
),
ILD_TRANSPARENT
);
//设置透明背景
cdc
.
SetBkMode
(
TRANSPARENT
);
...
...
@@ -262,6 +255,18 @@ void CPlaneWarView::OnTimer(UINT_PTR nIDEvent)
CView
::
OnTimer
(
nIDEvent
);
return
;
}
else
{
// 游戏界面
scene
.
StickScene
(
&
cdc
,
passNum
,
rect
);
if
(
nIDEvent
==
4
)
{
//滚动背景
scene
.
MoveBg
();
}
//刷新显示战机
if
(
myplane
!=
NULL
)
{
myplane
->
Draw
(
&
cdc
,
FALSE
,
isProtect
);
}
}
//将二级缓冲cdc中的数据推送到一级级缓冲pDC中,即输出到屏幕中
pDC
->
BitBlt
(
0
,
0
,
rect
.
Width
(),
rect
.
Height
(),
&
cdc
,
0
,
0
,
SRCCOPY
);
...
...
@@ -291,7 +296,7 @@ void CPlaneWarView::OnMouseMove(UINT nFlags, CPoint point)
if
(
myplane
!=
NULL
&&
isPause
==
0
)
{
//绘制新游戏对象
myplane
->
SetPoint
(
point
.
x
,
point
.
y
);
myplane
->
SetPoint
(
point
.
x
-
PLANE1_WIDTH
/
2
,
point
.
y
-
PLANE1_HEIGHT
/
2
);
}
CView
::
OnMouseMove
(
nFlags
,
point
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment