📄 main.cpp
字号:
#include "WinGame.h"
#include "stdio.h"
#include <dinput.h>
#define DIDEVCAPS_DX7 1024
//#define KEYDOWN(name,key) (name[key]&0x80)
BMP *pp;
DInPut *KeyBoard;
void InitGame()
{
SetGameWindowRect(0,0,300,350);
SetGameWindowTittle("AA");
}
void InitBMP()
{
KeyBoard=new DInPut();
pp=new BMP("Npc01.bmp");
/*COLORREF temp=pp->GetBMPPixel(0,0);
for(int y=0; y<((pp->GetHeight())>>1); y++)
for(int x=0; x<((pp->GetWidth())>>1); x++)
{
pp->SetBmpPixel(x,y,temp);
}
pp->DIBToDDB();*/
pp->LoadBmpTpDDSurface(NewGame->lpDD);
/*struct BufferSurfaceAddress ss=pp->BeginBmpWriteSuface();
for(int y=0; y<10; y++)
for(int x=0; x<10; x++)
{
*(ss.lpSurface + y*ss.Pitch + x)=x*y*x;
}
pp->EndBmpWriteSurface();*/
pp->SetDDSurColorKey(RGB(255,238,187));
}
BOOL GameLoop()
{
RECT O,S;
S.left=0;
S.top=0;
S.right=30;
S.bottom=30;
static int PointX=0;
static int PointY=25;
static int CHGcolor=1;
if(KeyBoard->GetKeyDown(DIK_RIGHT))
PointX++;
if(KeyBoard->GetKeyDown(DIK_LEFT))
PointX--;
if(KeyBoard->GetKeyDown(DIK_UP))
PointY--;
if(KeyBoard->GetKeyDown(DIK_DOWN))
PointY++;
if(PointX+100>300)
PointX=200;
if(PointX<0)
PointX=0;
if(PointY+150>350)
PointY=200;
if(PointY<0)
PointY=0;
O.left=PointX;
O.top=PointY;
O.right=PointX+100;
O.bottom=PointY+150;
CHGcolor++;
struct BufferSurfaceAddress ss=NewGame->BeginWriteBufferSurface();
int x, y;
for(y=0; y<350; y++)
for(x=0; x<300; x++)
{
*(ss.lpSurface + y*ss.Pitch + x)=x*y^CHGcolor;
}
NewGame->EndWriteBufferSurface();
pp->BltToDDSurface(NewGame->lpDDSBack,&O,&S);
char OutPutFps;
int Ret=NewGame->TestFPS();
static int fps;
if(Ret!=0)
{
fps=Ret;
}
HDC hdc;
sprintf(&OutPutFps,"FPSֵΪ%d֡",fps);
NewGame->lpDDSBack->GetDC(&hdc);
TextOut(hdc,200,320,&OutPutFps,13);
NewGame->lpDDSBack->ReleaseDC(hdc);
NewGame->Flip();
return TRUE;
/*RECT Obj,Res;
Obj.right=300;
Obj.top=0;
Obj.bottom=350;
Obj.left=0;
Res.left=0;
Res.top=0;
Res.bottom=600;
Res.right=800;//RGB(255,238,187)
HDC hdc=GetDC(AppData.hMainWnd);
pp->SetTransparentColor(4188413);
//pp->SetTransparentColor(RGB(255,238,187));
pp->DrawSpirit(hdc,Obj,Res);
ReleaseDC(AppData.hMainWnd,hdc);
return TRUE;*/
}
void GameOver()
{
delete KeyBoard;
delete pp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -