Commit c1dd3741 authored by CjhGm's avatar CjhGm
Browse files

add bmp

parent 5855126c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -191,6 +191,7 @@
<ClInclude Include="AircraftBattleDlg.h" />
<ClInclude Include="AircraftMain.h" />
<ClInclude Include="CGameObject.h" />
<ClInclude Include="CPlane.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Resource.h" />
......@@ -201,6 +202,7 @@
<ClCompile Include="AircraftBattleDlg.cpp" />
<ClCompile Include="AircraftMain.cpp" />
<ClCompile Include="CGameObject.cpp" />
<ClCompile Include="CPlane.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
......@@ -215,6 +217,9 @@
<None Include="res\AircraftBattle.rc2" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\..\..\..\desktop\planewar-mfc-master\planewar-mfc-master\planewar\image\bitmap1.bmp" />
<Image Include="..\..\..\..\..\Desktop\PlaneWar-MFC-master\PlaneWar-MFC-master\PlaneWar\image\me.bmp" />
<Image Include="..\..\..\..\..\Desktop\PlaneWar-MFC-master\PlaneWar-MFC-master\PlaneWar\image\me1.bmp" />
<Image Include="res\AircraftBattle.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -39,6 +39,9 @@
<ClInclude Include="CGameObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CPlane.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AircraftBattle.cpp">
......@@ -56,6 +59,9 @@
<ClCompile Include="CGameObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CPlane.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AircraftBattle.rc">
......@@ -71,5 +77,14 @@
<Image Include="res\AircraftBattle.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="..\..\..\..\..\Desktop\PlaneWar-MFC-master\PlaneWar-MFC-master\PlaneWar\image\me.bmp">
<Filter>资源文件</Filter>
</Image>
<Image Include="..\..\..\..\..\desktop\planewar-mfc-master\planewar-mfc-master\planewar\image\bitmap1.bmp">
<Filter>资源文件</Filter>
</Image>
<Image Include="..\..\..\..\..\Desktop\PlaneWar-MFC-master\PlaneWar-MFC-master\PlaneWar\image\me1.bmp">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -4,4 +4,21 @@
CGameObject::CGameObject(int x, int y) {
point.x = x;
point.y = y;
}
BOOL CGameObject::loadImage(CImageList& images, UINT bmpID, COLORREF crMask, int cx, int cy, int nInitial)
{
//加载游戏对象的图标对象
CBitmap bmp;
if (!bmp.LoadBitmapW(bmpID))
return FALSE;
//创建CImageList对象
if (!images.Create(cx, cy, ILC_COLOR24 | ILC_MASK, nInitial, 0))//nInitial初始个数
return FALSE;//cx,cy 图片的宽度
//图像链表中加入对象对应的图标对象,之后直接通过该链表访问图标对象
images.Add(&bmp, crMask);
return TRUE;
}
\ No newline at end of file
......@@ -6,5 +6,7 @@ protected:
CPoint point;
public:
CGameObject(int x, int y);
//加载该游戏对象对应的图像,图像对象是共有数据,只需要加载一份,使用静态方法
static BOOL loadImage(CImageList& imageList, UINT bmpID, COLORREF crMask, int cx, int cy, int nInitial);
};
#include "pch.h"
#include "CPlane.h"
#include "resource.h"
//静态图像链表
CImageList CPlane::images;
CImageList CPlane::images1;
CImageList CPlane::imagespro;
//加载战机图像
BOOL CPlane::loadImage()
{
//加载游戏对象的图标对象
CBitmap me;//升级战机图像
if (!me.LoadBitmapW(IDB_BITMAP_ME))
return FALSE;
CBitmap me1;//未升级战机图像
if (!me1.LoadBitmapW(IDB_BITMAP_ME1))
return FALSE;
//创建CImageList对象
if (!images.Create(PLANE_WIDTH, PLANE_HEIGHT, ILC_COLOR24 | ILC_MASK, 14, 0))//nInitial初始个数
return FALSE;//cx,cy 图片的宽度
if (!images1.Create(PLANE1_WIDTH, PLANE1_HEIGHT, ILC_COLOR24 | ILC_MASK, 4, 0))//nInitial初始个数
return FALSE;//cx,cy 图片的宽度
//图像链表中加入对象对应的图标对象,之后直接通过该链表访问图标对象
images.Add(&me, RGB(0, 0, 0));
images1.Add(&me1, RGB(0, 0, 0));
return TRUE;
}
\ No newline at end of file
#pragma once
#include "CGameObject.h"
//升级战机图像宽
#define PLANE_WIDTH 120
//升级战机图像高
#define PLANE_HEIGHT 150
//未升级战机图像宽
#define PLANE1_WIDTH 120
//未升级战机图像高
#define PLANE1_HEIGHT 90
//保护罩战机图像宽
#define PLANE_PRO_WIDTH 165
//保护罩战机图像高
#define PLANE_PRO_HEIGHT 166
//战机初始位置X
#define PLANE_X 400
//战机初始位置Y
#define PLANE_Y 300
class CPlane : public CGameObject
{
private:
static CImageList images;//存储升级战机图片
static CImageList images1;//存储未升级战机图片
static CImageList imagespro;//存储防护罩图片
public:
BOOL loadImage();
};
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -8,12 +8,14 @@
#define IDD_AIRCRAFTBATTLE_DIALOG 102
#define IDR_MAINFRAME 128
#define IDD_DIALOG1 129
#define IDB_BITMAP_ME 134
#define IDB_BITMAP_ME1 136
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_RESOURCE_VALUE 137
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment