91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.01M
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-11
  • 語言: 其他
  • 標簽: 其他??

資源簡介

retro_snake.c

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#define?X_BORDER?70
#define?Y_BORDER?30
#define?INTERVAL?150
#define?FAST_INTERVAL?50

void?gotoxy(HANDLE?int?int);
void?drawBorderUI(HANDLE);
void?gameStart(HANDLE);
void?initMoveSnake(HANDLE?int);
void?generateBean(HANDLE?int);
void?gameOver(HANDLE);

struct?beans?{
????int?x;
????int?y;
};
struct?snakeNode?{
????int?x;
????int?y;
};
struct?beans?bean;
struct?snakeNode?node[X_BORDER?*?Y_BORDER];
int?score?=?0?highscore?=?0?snakeLength?=?2?retry?=?0;

/******************************************/

int?main(int?argc?char*?argv[])
{
????int?direction?=?0;
????HANDLE?hOut?=?GetStdHandle(STD_OUTPUT_HANDLE);
????gameStart(hOut);
????RETRY:
????drawBorderUI(hOut);
????initMoveSnake(hOut?direction);

????if?(retry)?{
????????system(“cls“);
????????goto?RETRY;
????}
????gotoxy(hOut?0?Y_BORDER?+?1);
????return?0;
}

void?gotoxy(HANDLE?hOut?int?x?int?y)
{
????COORD?pos;
????pos.X?=?x;
????pos.Y?=?y;
????SetConsoleCursorPosition(hOut?pos);
}

void?gameStart(HANDLE?hOut)
{
????CONSOLE_CURSOR_INFO?cursor_info?=?{1?0};
????SetConsoleCursorInfo(hOut?&cursor_info);?//?hide?cursor
????gotoxy(hOut?X_BORDER?/?2?-?11?Y_BORDER?/?2);
????printf(“Press?Space?to?Start?Game“);
????gotoxy(hOut?0?0);
????while?(getch()?!=?VK_SPACE)?;
????system(“cls“);
}

void?drawBorderUI(HANDLE?hOut)
{
????gotoxy(hOut?0?0);
????????for?(int?i?=?0;?i?????gotoxy(hOut?0?Y_BORDER);
????????for?(int?i?=?0;?i?????for?(int?i?=?0;?i?????????gotoxy(hOut?0?i);?putchar(‘X‘);}
????for?(int?i?=?0;?i?????????gotoxy(hOut?X_BORDER?i);?putchar(‘X‘);}
????gotoxy(hOut?X_BORDER?+?5?Y_BORDER?/?2?-?3);
????printf(“W?S?A?D?to?Control?Snake?“);
????gotoxy(hOut?X_BORDER?+?5?Y_BORDER?/?2?-?1);
????printf(“?Space?to?Switch?Speed“);
????gotoxy(hOut?X_BORDER?+?5?Y_BORDER?/?2?+?1);
????printf(“????Highscore?%d“?highscore);
}

void?initMoveSnake(HANDLE?hOut?int?direction)
{
????int?fast?=?0;
????memset(node?0?sizeof(node));
????gotoxy(hOut?X_BORDER?/?2?-?1?Y_BORDER?/?2);
????putchar(‘O‘);
????putchar(‘@‘);
????node[0].x?=?X_BORDER?/?2;
????node[1].x?=?X_BORDER?/?2?-?1;
????node[0].y?=?node[1].y?=?Y_BORDER?/?2;
????direction?=?6;??//?6?right?2?down?8?up?4?left

????generateBean(hOut?snakeLength);
????for?(;?;)?{
????????while?(kbhit())?{
????????????switch?(getch())?{
????????????????case?‘w‘:?if?(direction?!=?2)?direction?=?8;?break;
????????????????case?‘s‘:?if?(direction?!=?8)?direction?=?2;?break;
????????????????case?‘a‘:?if?(direction?!=?6)?direction?=?4;?break;
????????????????case?‘d‘:?if?(direction?!=?4)?direction?=?6;?break;
????????????????case?VK_SPACE:?fast?=?1?-?fast;
????????????????default:?;
????????????}
????????}
???????

評論

共有 條評論