stratgame
diff 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 diff
1.1 --- a/src/game_part.cc Wed May 23 07:25:43 2012 +0300 1.2 +++ b/src/game_part.cc Wed May 23 17:10:46 2012 +0300 1.3 @@ -1,3 +1,4 @@ 1.4 +#include <stdlib.h> 1.5 #include "opengl.h" 1.6 #include "game_part.h" 1.7 #include "level.h" 1.8 @@ -12,32 +13,39 @@ 1.9 return true; 1.10 } 1.11 1.12 +void Game::start() 1.13 +{ 1.14 + Part::start(); 1.15 + 1.16 + glEnable(GL_DEPTH_TEST); 1.17 +} 1.18 + 1.19 void Game::draw() const 1.20 { 1.21 - glClear(GL_COLOR_BUFFER_BIT); 1.22 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.23 1.24 glMatrixMode(GL_MODELVIEW); 1.25 glLoadIdentity(); 1.26 - glRotatef(current_time / 100.0, 0, 0, 1); 1.27 - glScalef(0.5, 0.5, 1); 1.28 + glTranslatef(0, 0, -4); 1.29 + glRotatef(50, 1, 0, 0); 1.30 + glRotatef(current_time / 100.0, 0, 1, 0); 1.31 1.32 - glBegin(GL_QUADS); 1.33 - glColor3f(1, 0, 0); 1.34 - glVertex2f(-1, -1); 1.35 - glColor3f(0, 1, 0); 1.36 - glVertex2f(1, -1); 1.37 - glColor3f(0, 0, 1); 1.38 - glVertex2f(1, 1); 1.39 - glColor3f(1, 0, 1); 1.40 - glVertex2f(-1, 1); 1.41 - glEnd(); 1.42 + level.draw(); 1.43 +} 1.44 + 1.45 +void Game::reshape(int x, int y) 1.46 +{ 1.47 + glMatrixMode(GL_PROJECTION); 1.48 + glLoadIdentity(); 1.49 + gluPerspective(45.0, (float)x / (float)y, 0.5, 500); 1.50 } 1.51 1.52 void Game::key(int key, bool pressed) 1.53 { 1.54 switch(key) { 1.55 case 27: 1.56 - cur_part = menu_part; 1.57 + exit(0); 1.58 + //cur_part = menu_part; 1.59 break; 1.60 1.61 default: