-
Notifications
You must be signed in to change notification settings - Fork 0
/
maze + pacdots cpp
52 lines (42 loc) · 965 Bytes
/
maze + pacdots cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
#include <GL/glut.h>
#include <math.h>
#include "pacman_t1.h"
#define COLUMNS 19
#define ROWS 22
void init() //m
{
glClearColor(0.0, 0.0, 0.2, 1.0); //sets background colour
initGrid(COLUMNS, ROWS);
}
void display_callback() //m
{
glClear(GL_COLOR_BUFFER_BIT);
drawGrid();
glutSwapBuffers();
}
void reshape_callback(int w, int h) //m
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
{
glOrtho(0.0, COLUMNS, 0.0, COLUMNS * (GLfloat)h / (GLfloat)w, -1.0, 1.0);
} else
{
glOrtho(0.0, ROWS * (GLfloat)w / (GLfloat)h, 0.0, ROWS, -1.0, 1.0);
}
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(1400, 800);
glutCreateWindow("Pacman");
glutDisplayFunc(display_callback);
glutReshapeFunc(reshape_callback);
init();
glutMainLoop();
return 0;
}