stratgame

view src/game_part.cc @ 3:8d95187cb3ee

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 23 May 2012 17:10:46 +0300
parents 369b51c9e4a8
children cd12944a8ea8
line source
1 #include <stdlib.h>
2 #include "opengl.h"
3 #include "game_part.h"
4 #include "level.h"
6 Game::~Game() {}
8 bool Game::init()
9 {
10 if(!level.load("data/test.level")) {
11 return false;
12 }
13 return true;
14 }
16 void Game::start()
17 {
18 Part::start();
20 glEnable(GL_DEPTH_TEST);
21 }
23 void Game::draw() const
24 {
25 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
27 glMatrixMode(GL_MODELVIEW);
28 glLoadIdentity();
29 glTranslatef(0, 0, -4);
30 glRotatef(50, 1, 0, 0);
31 glRotatef(current_time / 100.0, 0, 1, 0);
33 level.draw();
34 }
36 void Game::reshape(int x, int y)
37 {
38 glMatrixMode(GL_PROJECTION);
39 glLoadIdentity();
40 gluPerspective(45.0, (float)x / (float)y, 0.5, 500);
41 }
43 void Game::key(int key, bool pressed)
44 {
45 switch(key) {
46 case 27:
47 exit(0);
48 //cur_part = menu_part;
49 break;
51 default:
52 break;
53 }
54 }