-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (38 loc) · 831 Bytes
/
main.cpp
File metadata and controls
40 lines (38 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<graphics.h>
#include<conio.h>
#include<iostream>
#include "snake.h"
#include<time.h>
#include "food.h"
#include<stdlib.h>
#include "game.h"
#include<windows.h>
#include<cstdio>
#pragma comment (lib,"winmm.lib")
using namespace std;
int main()
{
mciSendString(TEXT("open music.mp3 alias music"), 0, 0, 0);
mciSendString(TEXT("play music"), 0, 0, 0);
Game game;
initgraph(640, 480);
setbkcolor(RGB(250, 250, 210));
while (1)
{
cleardevice();
game.snake.SnakeMove(game.snake.GetDirection());
game.DrawMap();
game.snake.GetCommand(game.snake.GetDirection());
game.EatFood();
Sleep(game.speed);
if (game.GameOver())
{
int x;
x = MessageBox(GetForegroundWindow(), "GameOver", "Care", MB_OK);
printf("%d\n", x);
break;
}
}
closegraph();
return 0;
}