<>c++ use easyx Making pixel birds , Simple hands on games

Old rules , First, the renderings

1 First load a bunch of resource images
// Loading image resources void loadRes() { loadimage(&BK[0], _T("res\\bg_day.png")); loadimage(
&BK[1], _T("res\\bg_night.png")); loadimage(&bk, _T("res\\bg_day.png"));
loadimage(&OVEIMG, _T("res\\bg_day.png")); loadimage(&BIRD[0][0], _T(
"res\\bird0_0.png")); loadimage(&BIRD[0][1], _T("res\\bird0_1.png")); loadimage(
&BIRD[0][2], _T("res\\bird0_2.png")); loadimage(&BIRD[1][0], _T(
"res\\bird1_0.png")); loadimage(&BIRD[1][1], _T("res\\bird1_1.png")); loadimage(
&BIRD[1][2], _T("res\\bird1_2.png")); loadimage(&BIRD[2][0], _T(
"res\\bird2_0.png")); loadimage(&BIRD[2][1], _T("res\\bird2_1.png")); loadimage(
&BIRD[2][2], _T("res\\bird2_2.png")); loadimage(&PIPE[0][0], _T(
"res\\pipe_down.png")); loadimage(&PIPE[0][1], _T("res\\pipe_up.png"));
loadimage(&PIPE[1][0], _T("res\\pipe2_down.png")); loadimage(&PIPE[1][1], _T(
"res\\pipe2_up.png")); loadimage(&NUMBER[0][0], _T("res\\font_048.png"));
loadimage(&NUMBER[0][1], _T("res\\font_049.png")); loadimage(&NUMBER[0][2], _T(
"res\\font_050.png")); loadimage(&NUMBER[0][3], _T("res\\font_051.png"));
loadimage(&NUMBER[0][4], _T("res\\font_052.png")); loadimage(&NUMBER[0][5], _T(
"res\\font_053.png")); loadimage(&NUMBER[0][6], _T("res\\font_054.png"));
loadimage(&NUMBER[0][7], _T("res\\font_055.png")); loadimage(&NUMBER[0][8], _T(
"res\\font_056.png")); loadimage(&NUMBER[0][9], _T("res\\font_057.png"));
loadimage(&NUMBER[1][0], _T("res\\number_context_00.png")); loadimage(&NUMBER[1]
[1], _T("res\\number_context_01.png")); loadimage(&NUMBER[1][2], _T(
"res\\number_context_02.png")); loadimage(&NUMBER[1][3], _T(
"res\\number_context_03.png")); loadimage(&NUMBER[1][4], _T(
"res\\number_context_04.png")); loadimage(&NUMBER[1][5], _T(
"res\\number_context_05.png")); loadimage(&NUMBER[1][6], _T(
"res\\number_context_06.png")); loadimage(&NUMBER[1][7], _T(
"res\\number_context_07.png")); }
2 Initialize game resources
void init() { // Loading graphics resources loadRes(); // Initialize graphical interface initgraph(288, 512); // Initialize random number seed
srand((unsigned int)time(NULL)); // initialize variable best = 0; isDay = rand() % 2;
birdColor= rand() % 3; // Game start time clock_t time = clock(); // Opening animation while (true) {
reset(); drawAlpha(&bk, 60, 120, &TITLE); drawAlpha(&bk, 125, 200, &BIRD[
birdColor][pose]); drawAlpha(&bk, 90, 270, &PLAY); pose = ((clock() - time) /
diff) % 3; put(); if (GetControl()) { break; } Sleep(10); } }
3 Start the game
// Game preprocessing void start() { // Initialization data isDay = rand() % 2; birdColor = rand() % 3;
pipeX[0] = 288 + 30; pipeX[1] = 288 + 30 + 190; pipeY[0] = rand() % 250; pipeY[1
] = rand() % 250; pose = 0; landX = 0; score = 0; y = 220; vy = 0; // Game start time
clock_t time= clock(); // Opening animation clock_t t = clock(); while (true) { reset();
drawScore(60, score, 13, 26, 144, 0); drawAlpha(&bk, 50, 120, &READY); drawAlpha
(&bk, (int)x, (int)y, &BIRD[birdColor][pose]); drawAlpha(&bk, 90, 220, &TUTORIAL
); drawAlpha(&bk, (int)landX, (int)landY, &LAND); landX -= (clock() - t) * vx /
100; t = clock(); pose = ((clock() - time) / diff) % 3; put(); if (landX < -44)
{ landX = -20; } if (GetControl()) { break; } Sleep(10); } }
4 Control pixel bird
bool GetControl() { bool res = false; if (_kbhit()) { char ch = _getch(); if (
ch== ' ') { res = true; } } MOUSEMSG msg; while (MouseHit()) { msg = GetMouseMsg
(); if (msg.mkLButton) { res = true; } } return res; }
It's easy to operate , It's a single mouse / Press the space bar , Every bird can play it .

5 Bird death , judge gameover The logic of
// Judging bird death bool isDie() { if (y + buttom > landY) return true; if (x + right >
pipeX[0] && x + left < pipeX[0] + 52) { if (y + top < pipeY[0] + 40 || y +
buttom> pipeY[0] + 140) return true; } if (x + right > pipeX[1] && x + left <
pipeX[1] + 52) { if (y + top < pipeY[1] + 40 || y + buttom > pipeY[1] + 140)
return true; } return false; }
c language ,c++,unity,python,c#,【 Answer questions 】, There is a need for contact q:2316773638

Technology
©2020 ioDraw All rights reserved
Java exercises 1: Simply define a car class New photo album app launched by Microsoft : Using cross platform framework React Native to write Chapter two Fundamentals of programming Programming exercises pandas Time order of webpack Code segmentation import()Vue slot slot: Default slot , Named slot , Scope slot Fundamentals of data analysis ——R language ( Processing missing values )C++ Implementation of matrix meteor shower effect PostMan Advanced Usage , Interface MD5+Secret autograph Sign The 12th Blue Bridge Cup B group C/C++ Provincial competition