1. 20 Dec, 2016 1 commit
    • Terence Martin's avatar
      Respond to ball drop finishing properly (moreso) · 09d29e3e
      Terence Martin authored
      Instead of just always being the turn of the player, we now take turns
      by swapping to an appropriate state depending on what the prior state
      This is only a base implementation; it doesn't know where to go after
      the final ball drop, it doesn't swap balls for the computer or player,
      and so on.
  2. 19 Dec, 2016 7 commits
    • Terence Martin's avatar
      Add more state handling · 021c44e1
      Terence Martin authored
      This adds extra events to the Maze entity that tell us if a ball has
      just started being dropped and when it has just finished stopping.
      Currently this is handled by disabling player input by switching to an
      appropriate state. Control returns when the ball stops dropping.
    • Terence Martin's avatar
      Handle maze events in Game scene · a9a1a745
      Terence Martin authored
      This hooks up the Game scene to the events that the Maze object can
      trigger, so that we can react to the maze generation complete by
      making it the players turn, which adds controls back and once again
      puts us back to where we were before.
    • Terence Martin's avatar
      Constrain player input to provided state · 9f98a325
      Terence Martin authored
      This shifts the code responsible for allowing the player to take a
      turn (or do something that can happen only on their turn) into its own
      method, which will handle it as before but do nothing if the state
      does not indicate that this is the player's turn.
      This proves that the player will not be able to interact with anything
      when it is not their turn.
    • Terence Martin's avatar
      Implement MazeEventListener · 0c2b9154
      Terence Martin authored
      This adds to the Maze entity the ability to add a listener object that
      will be told when various events happen. Currently this is just that
      the maze generation is now complete.
    • Terence Martin's avatar
      Add state machine to Game scene · f9f42d11
      Terence Martin authored
      This adds in the actual property that includes the state machine in
      the game state. We set up a state and priorState property right on the
      Scene class instance itself so that we can get at the value easier.
      This checks at the time that the scene is activated to see if it is
      currently no state (startup) and if so, changes the state to the level
      generation state, which will then kick off the level generation.
      This is basically a roundabout way to do what we were already doing.
    • Terence Martin's avatar
      Stop Maze entity from generating a Maze on init · 77d174b3
      Terence Martin authored
      This should actually be done as part of the state machine, since we
      need to do it at controlled times. This also sets up for the idea of
      generating the world in steps instead of all at once, in case we get
      that far along in the development.
    • Terence Martin's avatar
      Include new StateMachine class · 9d91e183
      Terence Martin authored
      This is a first pass and is subject to changes, so we'll see what
      This is set up so that the machine maintains both a current and a
      previous state (i.e. it has a state stack size of 1), allowing us to
      not only track our current state but also make rudimentary decisions
      about where to go next.
      There is a change listener interface that allows the machine to
      directly notify interested parties when the state changes so that they
      can take the appropriate action.
      This code currently has a proviso (in comments only) that warns again
      changing the state of the machine while inside the change handler, but
      I think as long as there is only ever a single listener this is safe.
      In the case of a multiple listener, notifications to objects that get
      notifed after the current cycle might be undefined.
  3. 18 Dec, 2016 6 commits
    • Terence Martin's avatar
      Streamline player movement · 9b473e5a
      Terence Martin authored
      In preparation for the future moving of the computer player on the
      maze, make a simple method that will turn and move a player entity in
      an appropriate direction.
    • Terence Martin's avatar
      Simplify Ball and Brick · eadf37a0
      Terence Martin authored
      The ball and brick were still using comparisons against the currently
      running animation in order to determine if they were hidden or not,
      when they could much easier just use the flag.
    • Terence Martin's avatar
      Enhance AI · e57b472b
      Terence Martin authored
      This is a feature of the AI that I wanted to implement originally but
      which I did not get around to in the press for getting the basic
      concept up and running.
      Essentially, when the AI is calculating the move that it wants to
      make, it  should pretend that the gray bricks are not actually there
      (even if they are) under the theory that when the round ends, such
      balls will drop  and would theoretically score more.
      To this end, the collision API for detecting if an entity blocks a
      ball now gets the isSimulation parameter so that this can happen.
    • Terence Martin's avatar
      Fix AI bug · 1749dc5a
      Terence Martin authored
      During simulation of a drop, a vanished gray brick would count as a
      bonus brick and add points to the ball, even though in practice this
      is not a situation in which points are scored.
      As a result of this the AI would prioritize moves through vanished
      gray bricks over regular drops for no discernible reason.
    • Terence Martin's avatar
      Enhance Player entity movement API · 6e654caa
      Terence Martin authored
      This is how this should have been implemented originally, but I just
      threw a quick couple of functions together for expediency to try and
      get the change finished before the end of that devember day.
      This merges the methods for moving left and right to simple
      translation and updates the documentation comment on this and the
      jumpTo method to not suck.
    • Terence Martin's avatar
      Add computer animations to Player entity · 97e5cc01
      Terence Martin authored
      This is a simple operation but allows us to support the computer
      player as well. This adds in the animations that are needed in order
      to display as the computer and a parameter in the contructor to
      specify which type of player to be.
      The code to select the appropriate animation was already set up to
      work as desired so no changes were needed.
  4. 17 Dec, 2016 8 commits
    • Terence Martin's avatar
      Implement simple AI tests · 29cbb3c8
      Terence Martin authored
      This just has the AI run to select a ball, then jump the player there
      and push it so we can see what happens.
      This updates the player to have a new test method for jumping to a
      specific location in the maze instead of just going left and right.
    • Terence Martin's avatar
      Implement simple AI · 769484a9
      Terence Martin authored
      This just finds all pushable balls and then simulates them moving
      through the maze to see which one is best. This uses a simple metric
      of just which ball would score the most points at this exact second.
    • Terence Martin's avatar
      Get Maze ready for AI · ec9dcc28
      Terence Martin authored
      This creates some accessor methods for entering and exiting the
      simulation for all entities that require it, and exposes the method
      that calculates the next ball position so that outside code can see
    • Terence Martin's avatar
      Implement simulation save/restore for Brick · d398dc3f
      Terence Martin authored
      For a bonus brick, we handle touches different. If we are not
      simulating, we do what we always did (only nicer; forgot to refactor
      some code).
      If we ARE simulating, we update the score in the ball that touched us
      to indicate that we actually were collected by this ball and then set
      a flag saying it happened so we won't do it again.
    • Terence Martin's avatar
      Implement simulation save/restore for Arrow · 06e11cbe
      Terence Martin authored
      For the arrow the only state we save is the direction we're pointing.
      This also updates the flip method to take a boolean that indicates if
      this flip is part of a simulation, so that it knows if it should
      change the visual orientation to match or not.
      Currently the simulation code does not invoke the update() method, so
      it is basically operating under the hope that an automatic arrow will
      be pointing the right direction when the ball gets there (same as a
    • Terence Martin's avatar
      Implement simulation save/restore for Ball · 8078c39a
      Terence Martin authored
      For the ball the only state we need to track is the position we were
      at before we were pushed (so we can go back there) and the score that
      is associated with this ball.
      Calling code is currently expected not to hide us visually if we're in
      a simulation.
    • Terence Martin's avatar
      Implement core simulation save/restore · 7d1b3091
      Terence Martin authored
      This includes the new API methods for saving and restoring the state
      of a MazeEntity instance (non-visual only) so that we can perform a
      number of simulations in the AI selector without disturbing the actual
      game state.
    • Terence Martin's avatar
      Set up for AI; include simulation flag · 20c051e8
      Terence Martin authored
      In order to use our existing code for regular and AI purposes, we now
      are able to pass a parameter to the MazeCell methods that are
      responsible for touching and redirecting the ball, so that the method
      can tell for what purpose this is happening (regular or AI).
      The existing code invokes this with a parameter that indicates that
      this operation is a regular one so that everything happens as per
  5. 16 Dec, 2016 6 commits
    • Terence Martin's avatar
      Put in ball pushing · 3ad57cee
      Terence Martin authored
      This adds a simple API to the Maze entity that allows the player to
      push the ball if it's facing downward, facing a ball, and a ball is
      not already dropping.
    • Terence Martin's avatar
      Include walking · f274dd58
      Terence Martin authored
      The Scene can now make the player walk left and right in the scene. If
      the player is not facing in the correct direction, it rotates to face
      the given direciton, otherwise it walks in that direction.
      The movement is constrained to the limits of the columns of the maze
      grid between the walls.
    • Terence Martin's avatar
      Position player properly · e4d87f90
      Terence Martin authored
      Using the new API, we position the player above the first column in
      the maze.
    • Terence Martin's avatar
      Give Player entity a reference point · 9dddef01
      Terence Martin authored
      This adds a reference point property to the player entity, which it
      will use to update its position on screen.
      This is done in combination with its map posiition and this reference
      position so that we can easily shift the player around and still know
      what position it's in.
    • Terence Martin's avatar
      Include a Player into the game · 74392e29
      Terence Martin authored
      This is currently crude, as the player remains stationary at the upper
      left corner, but it's enough to prove everything is working as
      This uses the spacebar as the push key (which seems more natural), so
      the debug toggle key is now F12.
    • Terence Martin's avatar
      Include Player entity · 499a0bde
      Terence Martin authored
      This is the first crack at this. THe player can face a direction and
      push in all directions, and is capable of not running an action until
      its  current action is completed.
  6. 15 Dec, 2016 12 commits
    • Terence Martin's avatar
      Clean up debugging calls · cf426ef5
      Terence Martin authored
      Shift the onus of checking to see if debugging is turned on or not
      from the calling class to the MazeDebugger class, which leaves without
      doing anything if debugging is not turned on.
      A boolean return tells you if anything was done or not, so that the
      Scene can eat keys as needed.
    • Terence Martin's avatar
      Shift debug flag to the debugger object · 1bcd5b79
      Terence Martin authored
      This moves the flag that says if the debugger is turned on or not into
      the debug object itself. This lengthens the code a bit but finishes the
    • Terence Martin's avatar
      Refactor most debugging code into a new class · 272b499a
      Terence Martin authored
      This does for debugging what the previous commits did for the
      generation of the maze. This pulls all of the debug options out and
      puts them into their own class.
      This still needs a bit of work, si\nce the flag and a couple of other
      things are still held in the Maze.
    • Terence Martin's avatar
      Rearrange debug code a bit · 40494759
      Terence Martin authored
      This cleans up the debug code by moving one last function upwards to
      where it lives.
    • Terence Martin's avatar
      Refactor Maze generation · f0224daa
      Terence Martin authored
      This shifts the code that generates the maze into its own class, which
      shortens up and clarifies the Maze code itself and also makes it
      easier to tweak generation in the future, since it will be self
    • Terence Martin's avatar
      Clarify ball dropping · 549186a3
      Terence Martin authored
      There were several places where code was being used to check if a cell
      in the maze was blocked or not. This has been factored out into the
      MazeContent class so that we can easily do it in one step.
    • Terence Martin's avatar
      Implement simple accessors for ActorPool access · 3d835944
      Terence Martin authored
      This simplifies the code marginally for the purposes of pulling an
      entity out of the associated ActorPool instance, but exposes a simple
      method for external code to be able to get at our entities so that the
      debug code can go away.
    • Terence Martin's avatar
      Remove the last of the instanceof uses · 5568b6a9
      Terence Martin authored
      This implements a new helper in the MazeContent entity that allows you
      to fetch the name of the entity at a given location with a built in
      null check.
    • Terence Martin's avatar
      Fix missing documentation in Teleport entity · e1e4797a
      Terence Martin authored
      All I can say is, whoops.
    • Terence Martin's avatar
      Remove almost all of the instanceof uses · 795e459e
      Terence Martin authored
      We now favor using the internal name of the entity, which for our
      purposes here is the name provided to the MazeCell constructor.
      ts-game-engine uses this for debugging so it's exposed, but it
      probably should be. This has been added to the new interface to
      remind us that it should be added along with everything else.
    • Terence Martin's avatar
      Add kill() method to MazeCell and new interface · b64b9a85
      Terence Martin authored
      In order to make code even clearer that wants to kill an entity based
      on its pool, add a kill() method directly to MazeCell that invokes the
      killEntity() method for us as a convenience.
    • Terence Martin's avatar
      Use new pool tracking for easier disposal · d0d9d641
      Terence Martin authored
      In order to make the code a little clearer in a few places, instead of
      having wordy code to select the appropriate pool for killing an
      entity, we can just use its pool directly.