forked from carboned4/CeGue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp~RF1774e55.TMP
132 lines (112 loc) · 3.56 KB
/
Main.cpp~RF1774e55.TMP
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <stdlib.h>
#include <time.h>
#include "glut.h"
#include "GameManager.h"
#include "Frog.h"
#include "Roadside.h"
#include "Road.h"
#include "Riverside.h"
#include "River.h"
#include "Timberlog.h"
#include "Bus.h"
#include "Car.h"
#include "Turtle.h"
#include "PerspectiveCamera.h"
#include "OrthogonalCamera.h"
#define MILISECONDS 17
GameManager* man;
void regularKeys(unsigned char key, int x, int y){
man->keyPressed(key, x, y, true);
}
void regularUpKeys(unsigned char key, int x, int y){
man->keyPressed(key, x, y, false);
}
void specialKeys(int key, int x, int y) {
man->specialKeyPressed(key, x, y);
}
void displayForward(){ man->display(); } // openGL + OOP = trouble. esta funcao reencaminha a chamada à display tornado possível a sua chamada.
void reshapeForward(int w, int h){ man->reshape(w, h); } // openGL + OOP = trouble. esta funcao reencaminha a chamada à reshape tornado possível a sua chamada.
void updateForward(int useless){ // chama o update do gamemanager a cada 17ms (quase 60fps) idealmente.
man->update(useless); // o argumento useless é inuntil, so serve para se conseguir invocar a update.
man->display(); // chama a display depois da update
glutTimerFunc(MILISECONDS, updateForward, 0);
}
void spawnWorldObjects(){ // o mapa é 11 de largura por 13 de altura
double i = 0, j = 0;
Frog* frog = new Frog();
frog->setPosition(0.0, 0.0, 0.0);
frog->setZRotation(0.0);
frog->setSpeed(0.0, 0.0, 0.0);
man->setFrog(frog);
man->addGameObject(frog);
Roadside* estradaborda;
estradaborda = new Roadside();
estradaborda->setPosition(0.0, 0.0, -1.0);
man->addGameObject(estradaborda);
// ^passeio de baixo, v passeio de cima
estradaborda = new Roadside();
estradaborda->setPosition(0.0, 6.0, -1.0);
man->addGameObject(estradaborda);
Road* estrada;
estrada = new Road();
estrada->setPosition(0.0, 3.0, -1.0);
man->addGameObject(estrada);
River* rio;
rio = new River();
rio->setPosition(0.0, 9.0, -1.0);
man->addGameObject(rio);
Riverside* rioborda;
rioborda = new Riverside();
rioborda->setPosition(0.0, 12.0, -1.0);
man->addGameObject(rioborda);
Timberlog* tronco;
tronco = new Timberlog();
tronco->setPosition(-4.0, 9.0, -1.0);
tronco->setSpeed(-1.5, 0.0, 0.0);
man->addGameObject(tronco);
tronco = new Timberlog();
tronco->setPosition(-1.0, 11.0, -1.0);
tronco->setSpeed(-1.5, 0.0, 0.0);
man->addGameObject(tronco);
Bus* bus;
bus = new Bus();
bus->setPosition(-1.0, 2.0, 0.0);
bus->setSpeed(-2.00, 0.0, 0.0);
man->addGameObject(bus);
bus = new Bus();
bus->setPosition(4.0, 4.0, 0.0);
bus->setSpeed(-2.0, 0.0, 0.0);
man->addGameObject(bus);
Car* car;
car = new Car();
car->setPosition(2.0, 3.0, 0.0);
car->setSpeed(-3.0, 0.0, 0.0);
man->addGameObject(car);
Turtle* turtle;
turtle = new Turtle();
turtle->setPosition(-2.0, 10.0, -1.0);
turtle->setSpeed(-2.0, 0.0, 0.0);
man->addGameObject(turtle);
Camera* cam2 = new PerspectiveCamera(140, (DRAWLEFT-DRAWRIGHT)/(DRAWTOP-DRAWBOTTOM), 5, -5);
man->addCamera(cam2);
}
int main(int argc, char** argv){
man = new GameManager();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(440, 520);
glutInitWindowPosition(100, 100);
glutCreateWindow("CG Frogger - grupo 18");
man->init();
// "binding" de funções ao GL
glutDisplayFunc(displayForward);
glutReshapeFunc(reshapeForward);
glutKeyboardFunc(regularKeys);
glutKeyboardUpFunc(regularUpKeys);
glutSpecialFunc(specialKeys);
/* Adicionar alguns objectos */
spawnWorldObjects();
glutTimerFunc(17, updateForward, 0); // inicia o ciclo de chamada da update
glutMainLoop();
return 0;
}