Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/core/orxonox.cc @ 1859

Last change on this file since 1859 was 1859, checked in by patrick, 20 years ago

/orxonox/trunk/core: key action support added

File size: 3.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software Foundation,
18   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
19
20
21   ### File Specific:
22   main-programmer: Patrick Boenzli
23   co-programmer:
24*/
25
26
27
28
29
30
31/* class definition header */
32#include "orxonox.h"
33#include "data_tank.h"
34
35/* standard headers */
36#include <iostream>
37#include <cstdio>
38
39/* openGL Headers */
40#include <GL/glut.h>
41
42using namespace std;
43
44
45
46Orxonox::Orxonox () {}
47
48
49
50Orxonox::~Orxonox () {}
51
52
53/* this is a singleton class to prevent dublicates */
54Orxonox* Orxonox::singleton_ref = 0;
55Orxonox* Orxonox::getInstance (void)
56{
57  if (singleton_ref == NULL)
58    singleton_ref = new Orxonox();
59  return singleton_ref;
60}
61
62
63
64int Orxonox::globalInit (int argc, char** argv) 
65{
66  glutInit(&argc, argv);
67  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
68  glutInitWindowSize(500, 500);
69  glutInitWindowPosition(100, 100);
70  glutCreateWindow("orxOnox");
71  /* window event dispatchers */
72  glutDisplayFunc(display);
73  glutReshapeFunc(reshape);
74  glutKeyboardFunc(keyboard);
75  glutSpecialFunc(specFunc); 
76}
77
78
79
80int Orxonox::menuInit (void)
81{
82  glClearColor(0.0, 0.0, 0.0, 0.0);
83}
84
85
86
87int Orxonox::gameInit (void) 
88{
89
90}
91
92
93void Orxonox::keyboard(unsigned char key, int x, int y)
94{
95  switch(key) {
96  case 27:
97    exit(0);
98    break;
99  }
100}
101
102
103void Orxonox::specFunc(int key, int x, int y)
104{
105  switch(key) {
106  case GLUT_KEY_UP:
107    cout << "key_up" << endl;
108    break;
109  case GLUT_KEY_DOWN:
110    cout << "key_down" << endl;
111    break;
112  case GLUT_KEY_RIGHT:
113    cout << "key_right" << endl;
114    break;
115  case GLUT_KEY_LEFT:
116    cout << "key_left" << endl;
117    break;
118  }
119}
120
121
122void Orxonox::display (void) 
123{
124  glClear(GL_COLOR_BUFFER_BIT);
125  glutSwapBuffers();
126} 
127
128
129
130void Orxonox::reshape (int w, int h)
131{
132  glViewport(0, 0, (GLsizei) w, (GLsizei) h);
133  glMatrixMode(GL_PROJECTION);
134  glLoadIdentity();
135  glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);
136  glMatrixMode(GL_MODELVIEW);
137  glLoadIdentity(); //pb why a second time?
138}
139
140
141
142int main (int argc, char** argv) 
143{ 
144  Orxonox *orx = Orxonox::getInstance();
145  (*orx).globalInit(argc, argv);
146  (*orx).menuInit();
147
148  World* wd = new World;
149  Player* pl = new Player;
150  (*wd).addPlayer(pl);
151  (*wd).addPlayer(pl);
152  (*wd).addPlayer(pl);
153  (*wd).addPlayer(pl);
154
155  NPC* nl = new NPC;
156  (*wd).addNPC(nl);
157  (*wd).addNPC(nl);
158  (*wd).addNPC(nl);
159  (*wd).addNPC(nl);
160  (*wd).addNPC(nl);
161  (*wd).addNPC(nl);
162  (*wd).testThaTest();
163
164  glutMainLoop(); 
165  return 0;
166}
Note: See TracBrowser for help on using the repository browser.