#include <iostream>
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
using namespace std;
char map[20][2000];
int stmap_r,enmap_r,stmap_a,enmap_a;
int pl_mosthp=100,pl_row=10,pl_arr=45;
int hori=0,vert=0;
int isjumping=0;
char key;
void mapjudge(int x,int y) {
stmap_r=x-10;
if(stmap_r<=1) {
stmap_r=1;
}
enmap_r=stmap_r+15;
if(enmap_r>=19) {
enmap_r=19;stmap_r=4;
}
stmap_a=y-70;
if(stmap_a<=0) {
stmap_a=0;
}
enmap_a=stmap_a+140;
}
void color(int a){
if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
}//白蓝绿紫红靛黄
void gotoxy(int x, int y) {
COORD pos = {x,y};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
return ;
}
void jump(){
if(isjumping==0){
vert-=5;
isjumping=1;
}
}
void keyinput(){
if(kbhit()) {
key=getch();
if(key=='a') {
hori--;
} else if(key=='d') {
hori++;
} else if(key=='s') {
vert++;
} else if(key=='w') {
jump();
} else if(key==' ') {
system("pause");
system("cls");
}
}
}
void go(){
if(hori<0){
hori++;
if(pl_arr>=2&&map[pl_row-1][pl_arr-2]!='#'){
pl_arr--;
map[pl_row-1][pl_arr]=' ';
}
}
if(hori>0){
hori--;
if(pl_arr<=1998&&map[pl_row-1][pl_arr]!='#') {
pl_arr++;
map[pl_row-1][pl_arr-2]=' ';
}
}
if(vert<0){
vert++;
if(pl_row>=2&&map[pl_row-2][pl_arr-1]!='#') {
pl_row--;
map[pl_row][pl_arr-1]=' ';
}
}
if(vert>0){
vert--;
if(pl_row<=18&&map[pl_row][pl_arr-1]!='#') {
pl_row++;
map[pl_row-2][pl_arr-1]=' ';
}
}
}
void gra(){
if(pl_row<=18&&map[pl_row][pl_arr-1]!='#') vert++;
}
int main(){
for(int i=0; i<20; i++) {
for(int j=0; j<2000; j++) {
map[i][j]=' ';
}
}
for(int i=0;i<2000;i++){
map[18][i]='#';
}
system("mode con cols=150 lines=30");
srand(unsigned(time(NULL)));
CONSOLE_CURSOR_INFO cursor_info= {1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
while(true){
if(pl_row==17) isjumping=0;
keyinput();
gra();
go();
map[pl_row-1][pl_arr-1]='I';
for(int i=1; i<=142; i++) printf("-");
printf("\n");
for(int i=stmap_r; i<enmap_r; i++) {
printf("|");
for(int j=stmap_a; j<enmap_a; j++) {
printf("%c",map[i][j]);
}
printf("|");
printf("\n");
}
for(int i=1; i<=142; i++) printf("-");
printf("\n");
mapjudge(pl_row,pl_arr);
printf("坐标 :%d %d",pl_row,pl_arr);
gotoxy(0,0);
}
return 0;
}
4 个赞
你好
2 个赞
hello
2 个赞
嘤嘤嘤,我csp差一分
2 个赞
666
1 个赞
就知道是你。牛逼牛逼!
1 个赞
…这是什么玩意,有bug,惊天大bug.