回复 2楼 九转星河
都有 我给你看下我的代码头文件 game
#pragma once
#include<stdio.h>
#include<graphics.h>
#include<mmsystem.h> //播放音乐头文件
#include<coin.h>
#pragma comment(lib,"winmm.lib")// 包含库文件
#define window_width 640
#define window_height 480
#define maxnum 100
#define snakesize 10
typedef enum Ch
{
up = 72, down = 80, left = 75, right = 77}CH;
typedef struct Coor
{
int x;
int y;
}COOR;
typedef struct snake
{
COOR sCor[maxnum]; //蛇的坐标 包含100节 最大的
int n; //当前节数
CH Ch; //蛇的方向
}SNAKE;
void GameInit();
SNAKE snake; //跋蛇定义出来
主函数 mian
#include"game.h"
int main()
{
void GameInit();
getchar();
closegraph();
return 0;
}
void GameInit()
{
initgraph(window_width, window_height);
mciSendString(L"open ./好久不见.mp3 alias backmusic", 0, 0, 0);
mciSendString(L"play backmusic repeat", 0, 0, 0);
//初始化一条小蛇
rectangle(0, 0, snakesize, snakesize);
snake.Ch = down;
snake.n = 1;
snake.sCor[0].x = 0;
snake.sCor[0].y = 0;
}
void snakemove()
{
snake.sCor[0].y++;
rectangle(snake.sCor[0].x, snake.sCor[0].y, snake.sCor[0],x+snakesize,)
}