笔记来自于onenote导出,所以为图片格式 目前实现效果:
核心代码:(面向对象编程的思路) 开源在了github上: GUORUI_CHINA_HIT_BLOCK_GAME 代码的框架展示:
void ballCheck(){
if (balls.x >= WINDOW_W - balls.r){
balls.x_move = -MOVE_SPACE;
}
if (balls.x <= balls.r){
balls.x_move = MOVE_SPACE;
}
if (balls.y <= balls.r){
balls.y_move = MOVE_SPACE;
}
if (balls.y >= WINDOW_H - BOARD_H){
if (balls.x > getBoardX() && balls.x <= (getBoardX() + BOARD_W)){
balls.y_move = -MOVE_SPACE;
}
}
if (balls.y >= WINDOW_H - balls.r){
setisOver(TRUE);
}
}
void moveBoard(){
int order = keycheck();
if (order == 2){
if (checkBoard()){
board_user.x_pose -= BOARD_MOVE;
}
else{
board_user.x_pose += (2 * BOARD_MOVE);
}
}
if (order == 1){
if (checkBoard()){
board_user.x_pose += BOARD_MOVE;
}
else{
board_user.x_pose -= (2 * BOARD_MOVE);
}
}
}
int main(){
initgraph(WINDOW_W, WINDOW_H, SHOWCONSOLE);
initBlock();
initBoard();
initBall();
isOver = FALSE;
while (!isOver){
BeginBatchDraw();
cleardevice();
drawAllBlock();
drawBoard();
drawBall();
hitblockCheck();
ballCheck();
moveBall();
moveBoard();
EndBatchDraw();
}
printf("游戏结束");
Sleep(10 * 1000);
return 0;
}
目前存在的问题:
|