easyx小游戏

#include "stdafx.h"

int main(){
    srand(time(NULL));
    initgraph(640,480);
    int user_x=20,user_y=400,block_x=0,block_y=0;
    block_y=rand()%100;
    char ch;
    int t=clock();
    for(;;){
        circle(user_x,user_y,15);
        if(_kbhit()){
            ch=_getch();
            if(ch==W)user_y-=10;
        }
        else if(clock()-t>100){
            t=clock();
            user_y+=10;
            if(user_y>480)user_y=480;
            block_x-=10;
        }
        cleardevice();
        
        rectangle(block_x,480-block_y,block_x+20,480);
        //block_x-=10;
        if(block_x==0)block_x=480,block_y=rand()%100;
        if(block_x==user_x && 480-block_y<user_y)goto lose;
        if(user_y<350)user_y=350;
        

    }
lose:
    cleardevice();
    TCHAR st[]=_T("GAME OVER");
    outtextxy(200,200,st);
    for(;;);
    closegraph();
    return 0;
    closegraph();
}

注:stdafx包括:

easyx小游戏

 

 

 

 

 

 

游戏目标:不让小球碰到柱子

游戏截图:
easyx小游戏

 

easyx小游戏

上一篇:阿里云的专业技术认证分为哪些?为啥要获得阿里云的ACP认证!


下一篇:Bigdecimal类型判断是否等于0(用equals方法的坑)