feat(game): implement base functions and board rendering
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <conio.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
bool gameOver;
|
||||||
|
const int width = 40;
|
||||||
|
const int height = 40;
|
||||||
|
int x, y, fruitX, fruitY, score;
|
||||||
|
enum eDirection { STOP = 0, LEFT, RIGHT, UP, DOWN };
|
||||||
|
eDirection dir;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
gameOver = false;
|
||||||
|
dir = STOP;
|
||||||
|
x = width / 2;
|
||||||
|
y = height / 2;
|
||||||
|
fruitX = rand() % width;
|
||||||
|
fruitY = rand() % height;
|
||||||
|
score = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw() {
|
||||||
|
system("cls");
|
||||||
|
for(int i = 0; i < width + 2; i++) cout << "#";
|
||||||
|
cout << "\n";
|
||||||
|
for(int i = 0; i < height; i++) {
|
||||||
|
for(int j = 0; j < width; j++ ) {
|
||||||
|
if(j == 0) cout << "#";
|
||||||
|
cout << " ";
|
||||||
|
if(j == width - 1) cout << "#";
|
||||||
|
}
|
||||||
|
cout << "\n";
|
||||||
|
}
|
||||||
|
for(int i = 0; i < width + 2; i++) cout << "#";
|
||||||
|
cout << "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void input() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void logic() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
setup();
|
||||||
|
while(!gameOver){
|
||||||
|
draw();
|
||||||
|
input();
|
||||||
|
logic();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user