Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
aostap
/
ussimang
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Merge Requests
0
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f447d015
authored
2 years ago
by
hlaidv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
05d21e0c
Esialgne2
…
Esialgne
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
0 deletions
menüü ja müür
menüü ja müür
0 → 100644
View file @
f447d015
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <conio.h>
#include <stdbool.h>
#include <unistd.h>
#define width 20
#define height 20
#define menuWidth 40
#define menuHeight 5
enum direction {Stop, Left, Right, Up, Down};
bool started = false;
bool gameover = false;
int SnakeX, SnakeY;
int AppleX, AppleY;
void mypause ( void )
{
fflush ( stdout );
getchar();
started = true;
}
void menu() {
for (int i = 0; i < menuHeight; i++) {
for (int j = 0; j < menuWidth; j++) {
printf("#");
}
printf("\n");
}
printf("\n");
for (int i = 0; i < 15; i++) {
printf(" ");
}
printf("SNAKE GAME\n\n Press Enter to continue . . .\n\n");
for (int i = 0; i < menuHeight; i++) {
for (int j = 0; j < menuWidth; j++) {
printf("#");
}
printf("\n");
}
printf("\n");
mypause();
}
void setup() {
//direction = Stop;
srand(time(NULL));
//____Snake spawnpoint
SnakeX = width / 2;
SnakeY = height / 2;
//____Apple spawnpoint
AppleX = rand() % width;
AppleY = rand() % height;
}
void borders () {
system("clear"); //clearing console window
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (i == 0 || i == width - 1 || j == 0 || j == height - 1) {
printf("#");
}
else {
if (i == SnakeX && j == SnakeY)
printf("0");
else if (i == AppleX && j == AppleY)
printf("A");
else
printf(" ");
}
}
printf("\n");
}
}
void movement () {
}
int main()
{
setup();
while (gameover == false) {
if (!started) {
menu();
}
else {
borders();
movement();
//logic();
//tail();
sleep(1);
}
}
return 0;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment