1.cè¯è¨ è´ªåè ç¨åº
2.吴鉴鹰的单片单片单片机开发板怎么样啊?马上要学习单片机了,想买一块单片机开发板。机做机贪
cè¯è¨ è´ªåè ç¨åº
åºæ¬æè·¯ï¼èæ¯åä¸ä¸ªé£ç©è身åå°±å¢å ä¸æ ¼ï¼ç¨UP, DOWN, LEFT, RIGHTæ§å¶è头çè¿å¨ï¼èè身åè·çè头走ï¼æ¯åä¸æ ¼è身åä¸ä¸æ¥èµ°å°ä¸ä¸æ ¼è身åçä½ç½®ï¼ä»¥æ¤ç±»æ¨ã
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#define BEG_X 2
#define BEG_Y 1
#define WID
#define HEI
HANDLE hout;
typedef enum { UP, DOWN, LEFT, RIGHT} DIR;
typedef struct Snake_body
{
COORD pos;//è身çä½ç½®
struct Snake_body *next;//ä¸ä¸ä¸ªè身
struct Snake_body *prev;//åä¸ä¸ªè身
}SNAKE, *PSNAKE;
PSNAKE head = NULL;//è头
PSNAKE tail = NULL;//èå°¾
//ç»æ¸¸æè¾¹æ¡çå½æ°
void DrawBorder()
{
int i, j;
COORD pos = { BEG_X, BEG_Y};
for(i = 0; i < HEI; ++i)
{
SetConsoleCursorPosition(hout, pos);
for(j = 0; j < WID; ++j)
{
if(i == 0)//第ä¸è¡
{
if(j == 0)
printf("â");
else if(j == WID - 1)
printf("â");
else
printf("â");
}
else if(i == HEI - 1)//æåä¸è¡
{
if(j == 0)
printf("â");
else if(j == WID - 1)
printf("â");
else
printf("â");
}
else if(j == 0 || j == WID - 1)//第ä¸åææåä¸å
printf("â");
else
printf(" ");
}
++pos.Y;
}
}
//æ·»å è身çå½æ°
void AddBody(COORD pos)
{
PSNAKE pnew = (PSNAKE)calloc(1, sizeof(SNAKE));
pnew->pos = pos;
if(!head)
{
head = tail = pnew;
}
else
{
pnew->next = head;//æ°å建è身çnextæååå çè头
head->prev = pnew;//åå çè头çprevæåæ°å建çè身
head = pnew;//ææ°å建çè身ä½ä¸ºæ°çè头
}
SetConsoleCursorPosition(hout, head->pos);
printf("â");
}
//è身移å¨çå½æ°
void MoveBody(DIR dir)
{
PSNAKE ptmp;
COORD pos = head->pos;
switch(dir)
{
case UP:
if(head->pos.Y > BEG_Y + 1)
--pos.Y;
else
return;
break;
case DOWN:
if(head->pos.Y < BEG_Y + HEI - 2)
++pos.Y;
else
return;
break;
case LEFT:
if(head->pos.X > BEG_X + 2)
pos.X -= 2;
else
return;
break;
case RIGHT:
if(head->pos.X < BEG_X + (WID - 2) * 2)
pos.X += 2;
else
return;
break;
}
AddBody(pos);//æ·»å äºä¸ä¸ªæ°çè头
ptmp = tail;//ä¿åå½åçèå°¾
tail = tail->prev;
if(tail)
tail->next = NULL;
SetConsoleCursorPosition(hout, ptmp->pos);
printf(" ");
free(ptmp);
}
int main()
{
int ctrl;
DIR dir = RIGHT;//åå§èçæ¹åæ¯åå³ç
COORD pos = { BEG_X + 2, BEG_Y + HEI / 2};
system("color 0E");
system("mode con cols= lines=");
hout = GetStdHandle(STD_OUTPUT_HANDLE);
printf(" ------------è´ªåèç移å¨------------");
DrawBorder();
//èªå®ä¹å 个èç身ä½
AddBody(pos);
pos.X += 2;
AddBody(pos);
pos.X += 2;
AddBody(pos);
pos.X += 2;
AddBody(pos);
pos.X += 2;
AddBody(pos);
pos.X += 2;
AddBody(pos);
pos.X += 2;
AddBody(pos);
//æ§å¶èç移å¨
while(ctrl = getch())
{
switch(ctrl)
{
case 'w':
if(dir == DOWN)
continue;
dir = UP;
break;
case 's':
if(dir == UP)
continue;
dir = DOWN;
break;
case 'a':
if(dir == RIGHT)
continue;
dir = LEFT;
break;
case 'd':
if(dir == LEFT)
continue;
dir = RIGHT;
break;
case 'q':
return 0;
}
MoveBody(dir);
}
return 0;
}
æ©å±èµæï¼
å®ç°é»è¾
1ï¼å¯ä»¥è®¾ç½®å æ ï¼å°±è½å®ç°å¶å®ä½ç½®æå°å¶å®ç¬¦å·ã
2ï¼æ¶åä¸ä¸ªç»æä½ï¼å å«ä¸¤ä¸ªå ç´ åæ å ç´ åä¸ä¸ªç»æä½æéã
3ï¼ç»æä½ä¸²èå½¢æé¾è¡¨ï¼éåè·åæååæ ï¼æå°ç¬¦å·å¾å°è身ã
4ï¼ä¸æçå 头ï¼å»å°¾ï¼éæ°éååæ ï¼åæå°å½¢æèç移å¨ã
5ï¼é£ç©äº§ççä½ç½®å¤å®ï¼ä¸è½è¶çï¼ä¹ä¸è½ä¸è身ä½éåã
6ï¼èç转åå¤å®ï¼ä¸æ¡è§åï¼ä¸å 许åéã
7ï¼è½¬åçå®ç°ï¼è·è¡è¿æ¹åå³å®æ°çå ³èåæ ï¼å½å头çä¸ä¸å·¦å³ï¼
8ï¼æ»äº¡æ£æµï¼æ¯å¦å¤´èç¹åæ æ¯å¦ä¸å¢å£éåï¼æ¯å¦ä¸èº«ä½å ¶ä»å ³èéåã
9ï¼å éåéï¼è®¾ç½®å·æ°ä¼ç æ¶é´å®ç°ã
åèèµææ¥æºï¼ç¾åº¦ç¾ç§-Cè¯è¨
吴鉴鹰的单片机开发板怎么样啊?马上要学习单片机了,想买一块单片机开发板。源码
吴鉴鹰单片机开发板,吃蛇代码源码解释我用过,单片单片分析init源码我一个学长参加完比赛送给我的机做机贪,例程不错,贪吃有几个比较难,源码俄罗斯方块,吃蛇贪吃蛇,单片单片咱手机看不懂,机做机贪但是贪吃windows源码大全前面能看懂的部分,现在一些简单的源码程序都会写了,跟着他的吃蛇网游源码赚钱视频和帖子学了半年了,收获很多。