跳到正文

个人记录

火星降落2.0

Zilljy258约 3 分钟
原文
文章信息与版本

文章信息

发布
2021年10月3日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 3 分钟
获赞
1

版本

  1. v1当前

火星降落2.0完成!!!

相比火星降落1.0,新版增加及优化如下:

1.燃料限制

2.结束延时

3.冷冻bug去除

上代码:

C++
#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;
double fuel=100;
void zuo();
void hh();
void hhh();
int main(){
	while(h>0){
		_sleep(10);
		system("CLS");
		cout<<"high:"<<h<<endl;
		cout<<"fuel:"<<fuel<<endl;
		hhh();
		zuo();
		cout<<"/-\\ "<<endl;
		hh();
		cout<<"---------------/-\\-____-_____/-\\--------------"<<endl;
		if(f>=1){
			h2-=5;
			f=2; 
			fuel-=0.5;
		}
		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)&&fuel>=1.0){
			if(f<=0) f=1;
			else f=0;
		}
		if(fuel<=0) f=0;
	}
	if(f==2&&(zy>=20&&zy<=27&&zy!=23)){
		system("CLS");
		hhh();
		zuo();
		cout<<"/-\\ "<<endl;
		cout<<"---------------/-\\-____-_____/-\\--------------"<<endl;
		cout<<"good!"<<endl;
	}
	else{
		system("CLS");
		hhh();
		zuo();
		cout<<"/-\\ "<<endl;
		cout<<"---------------/-\\-____-_____/-\\--------------"<<endl;
		cout<<"a-ou!"<<endl;
	}
	_sleep(1000);
    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<22-h;i++){
		cout<<endl;
	}
}
原文