C 程式設計 簡單專案實戰飛機大戰

2021-10-10 23:13:57 字數 3762 閱讀 9561

vs2019(vs系列都可以),easyx圖形庫

一些標頭檔案

myhelp.**件

#pragma once

#include

#include

#include

#include

#include

using

namespace std;

struct node

node()

};

airplan.**件

#pragma once

#include

"myhelp.h"

class

airplan

node&

getplan()

bool

planecolide

(node& v1, node& v2,

int px)

;//飛機碰撞

void

destoryenemy

(int height);}

;

airplan.cpp檔案

#include

"airplan.h"

airplan::

airplan

(int x,

int y)

:plan

(x, y)

airplan::

airplan()

bool airplan::

planecolide

(node& v1, node& v2,

int px)

void airplan::

destoryenemy

(int height)

}}

bullet.**件

#pragma once

#include

"myhelp.h"

#include

"airplan.h"

class

bullet

void

spwnbullet

(node& plan)

;//發射子彈

void

dextorybullet()

;//銷毀子彈

};

bullet.cpp檔案

#include

"bullet.h"

void bullet::

spwnbullet

(node& plan)

//發射子彈

void bullet::

dextorybullet()

//銷毀子彈

}}

game.**件

#pragma once

#include

"airplan.h"

#include

"bullet.h"

class

game

;

game.cpp檔案

#include

"game.h"

game::

game

(int wid,

int height)

:wid

(wid)

,height

(height)

;//飛機在中間

}game::

~game()

void game::

init()

;//飛機在中間

bullet.

getbullet()

.clear()

; plan.

getenemyplan()

.clear()

;}//生成敵機

void game::

spawnenemy()

x =0;

} x++;}

//移動

void game::

control()

if(getasynckeystate

(vk_right)

||getasynckeystate

('d'))

if(getasynckeystate

(vk_left)

||getasynckeystate

('a'))

if(getasynckeystate

(vk_down)

||getasynckeystate

('s'))

if(_kbhit()

)}}//飛機撞子彈

bool game::

bulletcollide

(airplan& plan,

int px)}}

return

false;}

//遊戲是否結束

bool game::

isgameover()

}return

false;}

void game::

draw()

for(

auto p : bullet.

getbullet()

)putimage

(plan.

getplan()

.x, plan.

getplan()

.y,&ving[1]

);wsprintf

(tc,_t(

"score:%d"

), grade)

;outtextxy

(wid /

2, px, tc)

;endbatchdraw()

;}//重新整理

void game::

updata

(airplan& plan, bullet& bullet)

for(

auto

& p : bullet.

getbullet()

)if(bulletcollide

(plan, px)

) grade++

; plan.

destoryenemy

(height)

; bullet.

dextorybullet()

;spawnenemy()

;}//開始遊戲

void game::

start()

else

break;}

sleep(20

);}}

main.cpp檔案

我這裡是把放在res檔案面的。

Vue 簡單專案搭建

1.全域性安裝vue cli腳手架 2.建立乙個webpack模板專案 命令 vue init webpack my project 說明 project name 專案名稱 my project project description 專案描述 author 作者 vue build 打包方式,回...

Redux之react redux簡單專案入門

注意 已經安裝了react官方腳手架 進行修改 第一步 importfrom react redux 引入react redux importstorefrom store index 作用 把store提供給所有的元件實現store共享 conststore reactdom.render doc...

簡單專案之批量上傳

之前做一小專案中需要批量上傳功能,以前都是用的網上現成的uploadify webupload等外掛程式,心想既然是小專案還是不用外掛程式,所以不如自己寫乙個 非外掛程式 1.頁面 批量上傳頁面 1view code 美化上傳按鈕 1 2 3 選擇檔案 4 view code 檔案列表 1 file...