资源简介

基于控制台绘图的小游戏,仿造曾经很火的flappybird,回调函数处理消息,比较简单缺乏注释,有计分和游戏状态判定机制,,缺乏文字描述,按f开始游戏,空格控制鸟跳跃,p暂停游戏

资源截图

代码片段和文件信息

/*
Author: ATP
Date:2015-10-16
*/
#include “StdAfx.h“
#include “Bird.h“

Bird::Bird(void)
{
g=2.5;
vx=0.0;
vy=0.0;
x=CONSOLEX /2.0;
y=CONSOLEY/2.0;
upa = -12.0;
memset(birddot0sizeof(birddot));
birddot[0][0][1]=1;
birddot[0][1][2]=1;
birddot[0][2][0]=1;birddot[0][2][1]=1;birddot[0][2][2]=1;birddot[0][2][3]=1;birddot[0][2][4]=1;
birddot[0][3][2]=1;
birddot[0][4][1]=1;
birddot[1][1][1]=1;birddot[1][1][2]=1;
birddot[1][2][0]=1;birddot[1][2][1]=1;birddot[1][2][2]=1;birddot[1][2][3]=1;birddot[1][2][4]=1;
birddot[1][3][1]=1;birddot[1][3][2]=1;
birdstate = 0;
}


Bird::~Bird(void)
{
}

void Bird::jump(){
vy = upa;
}

void Bird::move(){
vy += g;
y += vy;
}

void Bird::drawBD(){
HWND hwnd=GetForegroundWindow(); //找到程序运行窗口的句柄
HDC hDC = GetDC((HWND)hwnd);//通过窗口句柄得到该窗口的设备场境句柄
HPEN hPen; //画笔
HBRUSH hBrush;

/*
hPen = CreatePen(PS_SOLID 0 0xffffff);
hBrush = CreateSolidBrush(RGB(000));
HPEN oldPen = (HPEN)Selectobject(hDC hPen);
HBRUSH oldBrush = (HBRUSH)Selectobject(hDC hBrush);
Rectangle(hDC00CONSOLEXCONSOLEY);
hPen = (HPEN)Selectobject(hDC oldPen);
hBrush = (HBRUSH)Selectobject(hDC oldBrush);
*/

hPen = CreatePen(PS_SOLID 0 0x000000);
hBrush = CreateSolidBrush(RGB(00 255));
HPEN oldPen = (HPEN)Selectobject(hDC hPen);
HBRUSH oldBrush = (HBRUSH)Selectobject(hDC hBrush);

int ij;
for (i = 0; i < 5; i++){
for(j = 0; j < 5; j++){
if(birddot[birdstate][i][j] > 0){
Rectangle(hDC x+5*jy+5*ix+5*j+5y+5*i+5);
}
}
}

hPen = (HPEN)Selectobject(hDC oldPen);
hBrush = (HBRUSH)Selectobject(hDC oldBrush);
Deleteobject(hPen);
Deleteobject(hBrush);
Deleteobject(oldPen);
Deleteobject(oldBrush);
ReleaseDC(hwnd hDC);
}

void Bird::changeBdSt(){
birdstate = 1-birdstate;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    I.A....    106496  2015-10-25 11:42  pixelBird\Debug\pixelBird.exe

    I.A....    478500  2015-10-25 11:42  pixelBird\Debug\pixelBird.ilk

    I.A....   1018880  2015-10-25 11:42  pixelBird\Debug\pixelBird.pdb

    I.A....      1868  2017-07-13 12:50  pixelBird\pixelBird\Bird.cpp

    I.A....       323  2017-07-13 12:50  pixelBird\pixelBird\Bird.h

    I.A....      1200  2017-07-13 12:50  pixelBird\pixelBird\Column.cpp

    I.A....       341  2017-07-13 12:50  pixelBird\pixelBird\Column.h

    I.A....      4452  2017-07-13 12:50  pixelBird\pixelBird\Game.cpp

    I.A....       306  2017-07-13 12:51  pixelBird\pixelBird\Game.h

    I.A....      5897  2017-07-13 12:51  pixelBird\pixelBird\pixelBird.cpp

    I.A....       138  2017-07-13 12:51  pixelBird\pixelBird\pixelBird.h

    I.A....     23558  2009-08-31 02:31  pixelBird\pixelBird\pixelBird.ico

    I.A....      6562  2015-09-23 12:10  pixelBird\pixelBird\pixelBird.rc

    I.A....      4828  2015-10-16 19:43  pixelBird\pixelBird\pixelBird.vcxproj

    I.A....      2326  2015-10-16 19:43  pixelBird\pixelBird\pixelBird.vcxproj.filters

    I.A....       143  2015-09-23 12:10  pixelBird\pixelBird\pixelBird.vcxproj.user

    I.A....      2355  2015-09-23 12:10  pixelBird\pixelBird\ReadMe.txt

    I.A....       728  2015-09-23 12:10  pixelBird\pixelBird\Resource.h

    I.A....     23558  2009-08-31 02:31  pixelBird\pixelBird\small.ico

    I.A....       214  2015-09-23 12:10  pixelBird\pixelBird\stdafx.cpp

    I.A....       420  2015-09-23 12:10  pixelBird\pixelBird\stdafx.h

    I.A....       236  2015-09-23 12:10  pixelBird\pixelBird\targetver.h

    I.A....       894  2015-09-23 12:10  pixelBird\pixelBird.sln

    I.A..H.     23552  2015-10-25 11:47  pixelBird\pixelBird.suo

    I.A....        46  2017-07-13 12:58  pixelBird\控制说明.txt

    I..D...         0  2015-10-30 18:53  pixelBird\Debug

    I..D...         0  2015-11-08 22:58  pixelBird\pixelBird

    I..D...         0  2017-07-13 12:58  pixelBird

----------- ---------  ---------- -----  ----

              1707821                    28

............此处省略1个文件信息

评论

共有 条评论