diff --git a/src/world/player.c b/src/world/player.c index 7849b3c..c71ce54 100644 --- a/src/world/player.c +++ b/src/world/player.c @@ -19,3 +19,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "player.h" + +static void doCheatControls(void); + +void doPlayer(void) +{ + game.config.control[CONTROL_LEFT] = app.keyboard[SDL_SCANCODE_A]; + game.config.control[CONTROL_RIGHT] = app.keyboard[SDL_SCANCODE_D]; + game.config.control[CONTROL_UP] = app.keyboard[SDL_SCANCODE_W]; + game.config.control[CONTROL_DOWN] = app.keyboard[SDL_SCANCODE_S]; + game.config.control[CONTROL_JUMP] = app.keyboard[SDL_SCANCODE_I]; + game.config.control[CONTROL_FIRE] = app.keyboard[SDL_SCANCODE_J]; + + if (app.keyboard[SDL_SCANCODE_SPACE]) + { + world.bob->activate(1); + + app.keyboard[SDL_SCANCODE_SPACE] = 0; + } + + if (dev.debug) + { + doCheatControls(); + } +} + +static void doCheatControls(void) +{ + if (app.keyboard[SDL_SCANCODE_1]) + { + world.bob->weaponType = WPN_PISTOL; + } + + if (app.keyboard[SDL_SCANCODE_2]) + { + world.bob->weaponType = WPN_PLASMA; + } + + if (app.keyboard[SDL_SCANCODE_3]) + { + world.bob->weaponType = WPN_SPREAD; + } + + if (app.keyboard[SDL_SCANCODE_4]) + { + world.bob->weaponType = WPN_LASER; + } + + if (app.keyboard[SDL_SCANCODE_5]) + { + world.bob->weaponType = WPN_GRENADES; + } +} diff --git a/src/world/player.h b/src/world/player.h index 8ad0dc9..8c62918 100644 --- a/src/world/player.h +++ b/src/world/player.h @@ -19,3 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../common.h" + +extern App app; +extern Dev dev; +extern Game game; +extern World world; diff --git a/src/world/world.c b/src/world/world.c index 7e274dd..54e22e6 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -55,6 +55,8 @@ void initWorld(void) initEffects(); + initItems(); + world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime)); world.state = WS_START; @@ -194,45 +196,8 @@ static void doWorldStart(void) static void doWorldInProgress(void) { cameraTrack(world.entityToTrack); - - game.config.control[CONTROL_LEFT] = app.keyboard[SDL_SCANCODE_A]; - game.config.control[CONTROL_RIGHT] = app.keyboard[SDL_SCANCODE_D]; - game.config.control[CONTROL_UP] = app.keyboard[SDL_SCANCODE_W]; - game.config.control[CONTROL_DOWN] = app.keyboard[SDL_SCANCODE_S]; - game.config.control[CONTROL_JUMP] = app.keyboard[SDL_SCANCODE_I]; - game.config.control[CONTROL_FIRE] = app.keyboard[SDL_SCANCODE_J]; - - if (app.keyboard[SDL_SCANCODE_SPACE]) - { - world.bob->activate(1); - - app.keyboard[SDL_SCANCODE_SPACE] = 0; - } - - if (app.keyboard[SDL_SCANCODE_1]) - { - world.bob->weaponType = WPN_PISTOL; - } - - if (app.keyboard[SDL_SCANCODE_2]) - { - world.bob->weaponType = WPN_PLASMA; - } - - if (app.keyboard[SDL_SCANCODE_3]) - { - world.bob->weaponType = WPN_SPREAD; - } - - if (app.keyboard[SDL_SCANCODE_4]) - { - world.bob->weaponType = WPN_LASER; - } - - if (app.keyboard[SDL_SCANCODE_5]) - { - world.bob->weaponType = WPN_GRENADES; - } + + doPlayer(); if (!world.showingInfoMessage) { diff --git a/src/world/world.h b/src/world/world.h index 9a5b093..90775e1 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -58,6 +58,8 @@ extern void initQuadtree(Quadtree *root); extern void initParticles(void); extern void initEffects(void); extern void drawParticles(int plane); +extern void initItems(void); +extern void doPlayer(void); extern App app; extern Dev dev;