about summary refs log tree commit diff stats
path: root/vendor/godobuf/default_env.tres
blob: 20207a4aa2cfbae0c95636531b00d91502940d12 (plain) (blame)
1
2
3
4
5
6
7
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
ght: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include "input_system.h"
#include "game.h"
#include "character_system.h"
#include "message_system.h"

struct Input {
  bool left = false;
  bool right = false;
  bool up = false;
  bool down = false;
};

void InputSystem::tick(double dt) {
  SDL_Event e;
  while (SDL_PollEvent(&e)) {
    if (e.type == SDL_QUIT || (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE)) {
      game_.quit();

      return;
    } else if (e.type == SDL_KEYDOWN) {
      if (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT) {
        for (int spriteId : game_.getSprites()) {
          Sprite& sprite = game_.getSprite(spriteId);
          if (sprite.controllable) {
            game_.getSystem<CharacterSystem>().beginCrouch(spriteId);
          }
        }
      } else if (e.key.keysym.sym == SDLK_a) {
        // TODO: Remove this, it's just for testing.
        /*if (game_.getSystem<MessageSystem>().getCutsceneBarsProgress() == 1.0) {
          game_.getSystem<MessageSystem>().hideCutsceneBars();
        } else {
          game_.getSystem<MessageSystem>().displayCutsceneBars();
        }*/
        //game_.getSystem<MessageSystem>().displayMessage("Some people always try to avoid fighting when there are enemies around. You know the type, right? They use the dash ability to zoom right by. I guess you could say they're followers of \"peace at any price\".", SpeakerType::Woman);
        game_.getSystem<MessageSystem>().displayMessage("Go to sleep.\nIn the absolute darkness.\nDon't do aaaanything.\nDon't see anyone.\nJust sleep.\nIt'll be oh, so much fun......!\nOhohohoho!", SpeakerType::Woman);
      } else if (e.key.keysym.sym == SDLK_b) {
        // TODO: Remove this, it's just for testing.
        game_.getSystem<MessageSystem>().advanceText();
      }
    } else if (e.type == SDL_KEYUP && (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT)) {
      for (int spriteId : game_.getSprites()) {
        Sprite& sprite = game_.getSprite(spriteId);
        if (sprite.controllable) {
          game_.getSystem<CharacterSystem>().endCrouch(spriteId);
        }
      }
    }
  }

  Input keystate;
  const Uint8* state = SDL_GetKeyboardState(NULL);
  keystate.left = state[SDL_SCANCODE_LEFT];
  keystate.right = state[SDL_SCANCODE_RIGHT];
  keystate.up = state[SDL_SCANCODE_UP];
  keystate.down = state[SDL_SCANCODE_DOWN];

  for (int spriteId : game_.getSprites()) {
    Sprite& sprite = game_.getSprite(spriteId);

    if (sprite.controllable) {
      bool directed = false;
      Direction dir = Direction::left;

      if (keystate.up)
      {
        directed = true;
        dir = Direction::up;
      } else if (keystate.down)
      {
        directed = true;
        dir = Direction::down;
      }

      if (keystate.left)
      {
        directed = true;
        if (dir == Direction::up) {
          dir = Direction::up_left;
        } else if (dir == Direction::down) {
          dir = Direction::down_left;
        } else {
          dir = Direction::left;
        }
      } else if (keystate.right)
      {
        directed = true;
        if (dir == Direction::up) {
          dir = Direction::up_right;
        } else if (dir == Direction::down) {
          dir = Direction::down_right;
        } else {
          dir = Direction::right;
        }
      }

      if (directed) {
        game_.getSystem<CharacterSystem>().moveInDirection(spriteId, dir);
      } else {
        game_.getSystem<CharacterSystem>().stopDirecting(spriteId);
      }
    }
  }
}