前言
我大二的时候用c写过一个跑出五格就越界的贪吃蛇,现在看来简直是一堆垃圾。
我现在用cplusplus重写它,那就叫它垃圾plusplus好了(狗头)。
设计思路
贪吃蛇行为过程:
1.蛇吃果子
2.蛇以speed运动
3.蛇在ground上运动
4.果子以frquency为间隔出现
5.果子出现在在ground上
6.蛇的头撞到了空气和果子之外的物体会死
实现过程
backg.h文件:
#include<vector>
#include<windows.h>
#include<iostream>
#include<conio.h>
#include<queue>
#include<thread>
#include<random>
#include<time.h>
class backg {
public:
std::vector<std::vector<int>> ground;
HANDLE hout;
backg();
void jump(int x,int y);
void plant();
void startplant();
};
backg.c文件:
#include<backg.h>
backg::backg()
{
int m=29;/*高*/int n=91;/*长*/
std::vector<std::vector<int>> t(m, std::vector<int>(n));
ground = t;
hout = GetStdHan