序文
少しゲームをプレイしたかった......
しかし、アイデアは半額を打つ......
だけ際立っていた......最初のテンプレートテンプレートを果たしました
コード
//head
#include <iostream>
#include <cstdio>
#include <cstring>
#include <windows.h>
#include <conio.h>
using namespace std;
//*head
//define
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define Row_down KEY_DOWN(VK_MBUTTON)
#define Left_down KEY_DOWN(VK_LBUTTON)
#define fup(a,b) for(int i = (a); i < (b); i++)
#define sup(a,b) for(int j = (a); j < (b); j++)
//*define
//struct
struct player{
int x;
int y;
int money;
}pl;
struct jump{
int time;
int hel;
void helfresh()
{
}
}jup;
//*struct
//char
char map[16][31] = {
" ",
" ",
" ... ... ",
" ....... ",
" ",
" ... ... ",
" ",
" .. .. ",
" ... .. .. ... ",
" . . ",
" .. ... .. ",
" ",
" .................. ",
" ",
" "
};
char index[30][30];
//*char
//int
//*int
//bool
bool run_ch = true;
//*bool
//function
void gotoxy(int y, int x)
{
COORD pos = {x,y};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
}
void init()
{
pl.x = 0;
pl.y = 0;
int i, j = 30;
for(i = 0; i <= 15; i++)
{
gotoxy(i, j);
cout<<"*";
}
i = 15;
for(j = 0; j <= 30; j++)
{
gotoxy(i, j);
cout<<"*";
}
for(i = 0; i < 15; i ++)
{
for(j = 0; j < 30; j++)
{
gotoxy(i, j);
cout<<map[i][j];
}
}
}
void shop()
{
}
bool arv(int a, int b)
{
if(map[a][b]=='*'||map[a][b]=='.'||map[a][b]=='|'||a<0||b<0||a>=15||b>=30)
return false;
return true;
}
char cnt_char;int cnt = 0;
void run_read(char ch)
{
if(ch == 'a')
{
int nx = pl.x;
int ny = pl.y - 1;
if(!arv(nx, ny))
return;
gotoxy(pl.x, pl.y);
cout<<" ";
pl.x = nx;
pl.y = ny;
gotoxy(pl.x, pl.y);
cout<<"A";
}
if(ch == 'd')
{
int nx = pl.x;
int ny = pl.y + 1;
if(!arv(nx, ny))
return;
gotoxy(pl.x, pl.y);
cout<<" ";
pl.x = nx;
pl.y = ny;
gotoxy(pl.x, pl.y);
cout<<"A";
}
if(ch == 's')
{
int nx = pl.x + 1;
int ny = pl.y;
if(!arv(nx, ny))
return;
gotoxy(pl.x, pl.y);
cout<<" ";
pl.x = nx;
pl.y = ny;
gotoxy(pl.x, pl.y);
cout<<"A";
}
if(ch == 'k')
{
if(jup.hel > 0 && map[pl.x + 1][pl.y] != '.' && pl.x != 14)
{
jup.hel--;
goto next2;
}
if(map[pl.x + 1][pl.y] != '.' && pl.x != 14)
return;
next2:
jup.time = 3;
if(cnt_char == 'd')
run_read('d');
if(cnt_char == 'a')
run_read('a');
}
if(ch == 'w')
{
int nx = pl.x - 1;
int ny = pl.y;
if(!arv(nx, ny))
return;
gotoxy(pl.x, pl.y);
cout<<" ";
pl.x = nx;
pl.y = ny;
gotoxy(pl.x, pl.y);
cout<<"A";
}
if(ch == 'n')
{
jup.time = 0;
cnt_char = ' ';
cnt = 0;
}
if(ch == 'f')
{
shop();
}
}
void run()
{
char ch;
while(run_ch)
{
if(map[pl.x + 1][pl.y] == '.' || pl.x == 14)
{
jup.hel = 0;
jup.helfresh();
}
if(!kbhit())
{
cnt++;
if(cnt > 3)
cnt_char = ' ', cnt = 0, ch = ' ';
goto run_next;
}
ch = getch();
if(ch == 'w')
goto run_next;
run_read(ch);
run_next:
gotoxy(16,0);
cout<<pl.x<<" "<<pl.y<" ";
if(ch == 'k')
ch = cnt_char;
else
cnt_char = ch;
if(jup.time == 0)
{
run_read('s');
run_read(cnt_char);
Sleep(100);
}
else
{
run_read('w');
run_read(cnt_char);
jup.time--;
Sleep(100);
}
Sleep(20);
}
}
//*function
//main
int main()
{
init();
run();
return 0;
}
//*main
レンダリング:
(絵が原因ブログの庭に私の写真、腐敗にありそうですが、私はできるだけ早くベッドに集計を変更します)
あなたが変更スプラウトことができますので、私は(実際には、彼はまた、理解することができます)、ノートの後ろにコードを貼り付けます。
私はの効果と言って持っていますごみの数しかし、私はない、他の開発者は、ああ、学ぶためにどこかわからないだろう、私たちだけでゆっくりと一部の開発者は、いくつかのコードの例を見て見つけます。