火星降落1.0

· · 个人记录

火星降落1.0完成!

该游戏尚有一些小bug。

游戏任务是降落到下划线区域

上代码:

#include<bits/stdc++.h>
#include <iostream>
#include <windows.h>
#include <cstdio>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
int h=20,zy=0,h2=100,f=1;
void zuo();
void hh();
void hhh();
int main(){
    while(h>0){
        _sleep(10);
        system("CLS");
        cout<<"h:"<<h<<endl;
        hhh();
        zuo();
        cout<<"/-\\ "<<endl;
        hh();
        cout<<"---------------/-\\-__________/-\\--------------"<<endl;
        if(f>=1){
            h2-=5;
            f=2; 
        }
        else{
            f--;
            if(f<-10) h2-=15;
            else h2-=10;
        }
        if(h2<=0){
            h--;
            h2=100;
        }
        if(KEY_DOWN(VK_LEFT)){
            zy--;
        }
        if(KEY_DOWN(VK_RIGHT)){
            zy++;
        }
        if(KEY_DOWN(VK_SPACE)){
            if(f<=0&&f>=-10) f=1;
            else f=0;
        }
    }
    if(f==2&&(zy>=20&&zy<=29)){
        system("CLS");
        hhh();
        zuo();
        cout<<"/-\\ "<<endl;
        cout<<"---------------/-\\-__________/-\\--------------"<<endl;
        cout<<"good!"<<endl;
    }
    else{
        system("CLS");
        hhh();
        zuo();
        cout<<"/-\\ "<<endl;
        cout<<"---------------/-\\-__________/-\\--------------"<<endl;
        cout<<"a-ou!"<<endl;
    }
    return 0;
}
void hh(){
    if(f>=1){
        zuo();
        cout<<"\\|/"<<endl;
    } 
    else{
        cout<<endl;
    }
    for(int i=2;i<h;i++){
        cout<<endl;
    }
}
void zuo(){
    for(int i=1;i<=zy;i++){
        cout<<" ";
    }
}
void hhh(){
    for(int i=1;i<23-h;i++){
        cout<<endl;
    }
}