Changeset 2105 in orxonox.OLD for orxonox/branches/chris/src
- Timestamp:
- Jul 11, 2004, 3:14:52 PM (20 years ago)
- Location:
- orxonox/branches/chris/src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/command_node.cc
r2100 r2105 22 22 #include <stdio.h> 23 23 #include <strings.h> 24 #include <stdlib.h> 24 25 25 26 using namespace std; … … 52 53 FILE* stream; 53 54 55 printf("Loading key bindings from %s\n", filename); 56 54 57 if( filename == NULL) filename = DEFAULT_KEYBIND_FILE; 55 58 … … 73 76 char namebuf[256]; 74 77 char valuebuf[256]; 78 memset (namebuf, 0, 256); 79 memset (valuebuf, 0, 256); 75 80 int* index; 76 81 … … 81 86 { 82 87 case 0: 88 printf("Key binding %d(%s) set to %s\n", index[1], SDLK_to_keyname( index[1]), valuebuf); 83 89 strcpy (aliases->keys[index[1]], valuebuf); 84 90 break; 85 91 case 1: 92 printf("Button binding %d(%s) set to %s\n", index[1], SDLB_to_buttonname( index[1]), valuebuf); 86 93 strcpy (aliases->buttons[index[1]], valuebuf); 87 94 break; … … 89 96 break; 90 97 } 98 memset (namebuf, 0, 256); 99 memset (valuebuf, 0, 256); 91 100 } 92 101 } … … 105 114 { 106 115 coord[0] = -1; 107 if( (coord[1] = keyname_to_SDLK (name)) != -1) coord[0] = 0; 108 if( (coord[1] = buttonname_to_SDLB (name)) != -1) coord[0] = 1; 116 coord[1] = -1; 117 int c; 118 if( (c = keyname_to_SDLK (name)) != -1) 119 { 120 coord[1] = c; 121 coord[0] = 0; 122 } 123 if( (c = buttonname_to_SDLB (name)) != -1) 124 { 125 coord[1] = c; 126 coord[0] = 1; 127 } 109 128 return coord; 110 129 } … … 112 131 void CommandNode::process () 113 132 { 133 perror("CommandNode|process()"); 114 134 if( bLocalInput) process_local (); 115 135 else process_network (); … … 123 143 while( SDL_PollEvent (&event)) 124 144 { 145 memset (cmd.cmd, 0, CMD_LENGHT); 125 146 switch( event.type) 126 147 { … … 173 194 void CommandNode::relay (Command* cmd) 174 195 { 196 perror("CommandNode|relay()"); 175 197 List<WorldEntity>* plist = bound; 176 198 199 Orxonox *orx = Orxonox::getInstance(); 200 if( orx->system_command (cmd)) return; 201 177 202 if( bLocalInput) send_over_network (cmd); 178 203 -
orxonox/branches/chris/src/command_node.h
r2100 r2105 42 42 KeyBindings* aliases; 43 43 List<WorldEntity>* bound; //!< List of WorldEntites that recieve commands from this CommandNode 44 intcoord[2];44 Sint32 coord[2]; 45 45 46 46 void relay (Command* cmd); -
orxonox/branches/chris/src/keynames.cc
r2100 r2105 48 48 if( !strcmp (name, "RETURN")) return SDLK_RETURN; 49 49 if( !strcmp (name, "ESCAPE")) return SDLK_ESCAPE; 50 if( !strcmp (name, "SPACE")) return SDLK_SPACE; 50 51 if( !strcmp (name, "EXCLAIM")) return SDLK_EXCLAIM; 51 52 if( !strcmp (name, "QUOTEDBL")) return SDLK_QUOTEDBL; … … 184 185 if( key == SDLK_CLEAR) return "CLEAR"; 185 186 if( key == SDLK_RETURN) return "RETURN"; 187 if( key == SDLK_SPACE) return "SPACE"; 186 188 if( key == SDLK_ESCAPE) return "ESCAPE"; 187 189 if( key == SDLK_EXCLAIM) return "EXCLAIM"; -
orxonox/branches/chris/src/orxonox.cc
r2104 r2105 72 72 strcat (configfilename, "/.orxonox.conf");*/ 73 73 74 strcpy (configfilename, " ./orxonox.conf");74 strcpy (configfilename, "orxonox.conf"); 75 75 } 76 76 … … 119 119 int width = 640; 120 120 int height = 480; 121 Uint32 flags = SDL_ OPENGL | SDL_GL_DOUBLEBUFFER;121 Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; 122 122 123 123 if( (screen = SDL_SetVideoMode (width, height, bpp, flags)) == NULL) … … 187 187 { 188 188 bQuitOrxonox = true; 189 //cout << "finished garbage colletion, quitting..." << endl;190 189 } 191 190 void Orxonox::mainLoop() 192 191 { 193 192 lastframe = SDL_GetTicks(); 194 193 bQuitOrxonox = false; 195 194 // This is where everything is run 195 printf("Orxonox|Entering main loop\n"); 196 196 while( !bQuitOrxonox) 197 197 { … … 207 207 display(); 208 208 } 209 printf("Orxonox|Exiting the main loop\n"); 209 210 } 210 211 … … 244 245 } 245 246 247 bool Orxonox::system_command (Command* cmd) 248 { 249 if( !strcmp( cmd->cmd, "quit") && !cmd->bUp) 250 { 251 bQuitOrxonox = true; 252 return true; 253 } 254 } 255 246 256 void Orxonox::display () 247 257 { … … 254 264 // draw HUD 255 265 // flip buffers 256 SDL_ Flip( screen);266 SDL_GL_SwapBuffers(); 257 267 } 258 268 … … 274 284 int main (int argc, char** argv) 275 285 { 286 printf(">>> Starting Orxonox <<<\n"); 276 287 Orxonox *orx = Orxonox::getInstance(); 277 288 -
orxonox/branches/chris/src/orxonox.h
r2104 r2105 53 53 54 54 void event_handler (SDL_Event* event); 55 bool system_command (Command* cmd); 55 56 56 57 int init (int argc, char** argv); -
orxonox/branches/chris/src/player.cc
r2101 r2105 61 61 void Player::command (Command* cmd) 62 62 { 63 if( strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;64 else if( strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;65 else if( strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;66 else if( strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;67 else if( strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;63 if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp; 64 else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp; 65 else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp; 66 else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp; 67 else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp; 68 68 } 69 69 70 70 void Player::draw () 71 71 { 72 glMatrixMode(GL_MODELVIEW); 73 float matrix[16]; 74 get_placement()->w.glmatrix (matrix); 75 glLoadMatrixf (matrix); 76 77 glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z); 78 79 glBegin(GL_TRIANGLES); 80 glColor3f(1,0,0); 81 glVertex3f(0,0,0); 82 glColor3f(0,1,0); 83 glVertex3f(-1,-0.5,0); 84 glColor3f(0,0,1); 85 glVertex3f(-1,+0.5,0); 86 glEnd(); 72 87 } 73 88
Note: See TracChangeset
for help on using the changeset viewer.