裸写的俄罗斯方块的代码,有意见或者想征用,直接评论留言即可。
效果如下:
/***************************************************************/
/*只用数组实现贪吃蛇
1、实现上下左右键控制蛇 ------ 2016.10.30
2、加入蛇的碰壁及自咬检测机制 ------ 2016.11.1
3、优化游戏画面背景及蛇的图案 ------ 2016.11.2
4、解决蛇移动时闪屏的缺陷 ------ 2016.11.3(gotoxy实现_博文)
5、加入随机食物 ------ 2016.11.4
6、加入食物延迟一段时间后再消失 ------ 2016.11.5
7、增加蛇迟到食物便增长的功能 ------ 2016.11.5
8、完成贪吃蛇功能 ------ 2016.11.5
*/
/***************************************************************/
#include<stdio.h>
#include<conio.h>
#include<windows.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#define OK 1
#define ERROR 0
#define CHESS_X 20//x轴 原点在右上角 竖轴 与windows的恰好相反这个要注意
#define CHESS_Y 20//y轴
#define BACK 176//背景图案
#define NODE 219//蛇的结点
#define EFFECT_TIME 50//食物等待的有效时间
int t = 0;
int snake_length = 4;
int food_mark = 0;
int snake_grow_flag = 0;//蛇增长的标志
int food_eat_flag = 0;//当蛇吃上了食物
int food_move_flag = 0;//当蛇尾到达食物的点
int x_replace = 0;
int y_replace = 0;
int x_food_record = 0;
int y_food_record = 0;
int x_food_tail_record = 0;
int y_food_tail_record = 0;
int x_food_replace = 0;
int y_food_replace = 0;
//存储画面的坐标
/*char chess_board[10][10] = {
176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
176, 176, 176, 176, 176, 176, 176, 176, 176, 176