1. 25 May, 2016 3 commits
  2. 31 Mar, 2016 2 commits
    • Terence Martin's avatar
      Fix potential tunneling issue · ab171bf1
      Terence Martin authored
      There was a very intermittent bug that could cause tunneling due to
      the way the collision code would ignore intersections if the ball
      started inside of the paddle on its movement phase.
      
      The code has been tweaked to include functionality that used to exist
      but got lost in which collision checking is only allowed for the
      paddle on the side of the screen that the ball is travelling towards
      along with the removal of the previous code.
      
      This means that the ball can be reflected by a paddle moving into it
      as long as the ball is still moving towards it, but since it reflects
      this no longer happens.
      ab171bf1
    • Terence Martin's avatar
      Fix upper ball collisions · 37adf1ee
      Terence Martin authored
      For want of an equals sign in a single ternary operator, the code for
      bouncing off of the top and bottom of the screen would incorrectly
      think it was bouncing off the bottom and translate the ball backwards
      along its speed vector all the way off the screen to the left or
      right every time it happened to exactly collide on the top of the
      screen.
      37adf1ee
  3. 30 Mar, 2016 5 commits
    • Terence Martin's avatar
      Update the index page · 68e234df
      Terence Martin authored
      This updates the index page to include a finalized description of the
      project.
      68e234df
    • Terence Martin's avatar
      Whoops; ball bounce fix · 8c0b13c8
      Terence Martin authored
      Fix up the ball bouncing against the top and bottom of the screen, as
      certain directions and speeds could cause it to do dumb stuff. How
      did *that* get in there?! *innocent look*
      8c0b13c8
    • Terence Martin's avatar
      Implement constrained corners · 27f59885
      Terence Martin authored
      The last of the textbook tasks for this project is to experiment
      with/implement the paddles not being able to go all the way to the
      extremes of the screen edges.
      
      This is implemented as a tune-able parameter that can be set to 0 to
      get the old behaviour. This value could be altered based on
      difficulty level or some such.
      27f59885
    • Terence Martin's avatar
      Include a simple test scene · d476d893
      Terence Martin authored
      This is something I've been using to test out ball collisions with
      the sides of the screen and paddles. It allows you to interactively
      set a ball position and speed and then see what happens.
      
      It's not compiled by default, but it might be handy later or just to
      look at as an example, etc.
      d476d893
    • Terence Martin's avatar
      Fix collisions with the ball up a bit · cb2e844b
      Terence Martin authored
      After futzing around a bit, I have decided that collisions between
      the ball and the paddles should happen such that the ball snaps to
      the exact collision point (instead of trying to back up) because
      otherwise things tend to look a little hurky sometimes. Probably a
      better collision is needed that determines when any axis gets within
      the radius of the bounding rectangle instead of its position.
      
      In contrast, we now use the push back code to constrain the ball
      visually to the screen when it bounces off of the top or bottom of
      the screen by backing it along its motion vector until it hits just
      the edge.
      
      This is possible because we can say that the closest the ball is
      allowed to get before this happens is its radius, so things visually
      appear "correct"
      cb2e844b
  4. 29 Mar, 2016 1 commit
    • Terence Martin's avatar
      Update to the latest version of the underlying engine · e3f40c5c
      Terence Martin authored
      This adds in the debug abilities that I was manually adding and
      removing previously (e.g. global stage), makes a translation nicer,
      but more importantly adding in the new Vector2D direction functions
      taking radians instead of degrees by default, which will be useful
      shortly. Probably.
      e3f40c5c
  5. 28 Mar, 2016 3 commits
    • Terence Martin's avatar
      Turn off debugging mode · 4412c6eb
      Terence Martin authored
      Now that all game play is nailed down, turn off the debug property on
      the game entities so that they don't display their bounding
      rectangles and origin any longer.
      4412c6eb
    • Terence Martin's avatar
      Full collision fixes · 3e2b13e3
      Terence Martin authored
      This change puts in place proper handling for collisions. One thing
      that was missing from the previous version was that a collision on
      the top or bottom of the paddle changes the Y speed, not the X, which
      makes it un-returnable.
      
      We now also push the ball correctly outside of the paddle regardless
      of where it hits.
      
      Lastly, collisions are ignored if the ball started inside of the
      paddle already when the collision started. This is key, and can
      happen because the paddles move before the ball does, so it's
      possible that the ball reflects up or down and then the paddle moves
      into it trying to return it.
      3e2b13e3
    • Terence Martin's avatar
      Fix collision issues from the last commit · 7a194799
      Terence Martin authored
      It turns out that the last code doesn't always work, for good reason;
      it assumes that the collision is always on the left/right of the
      collider, but it can actually happen on the top/bottom as well.
      
      In that case, the other code doesn't properly translate the ball all
      the way out of the collider, or it does, but since it's close to the
      top/bottom edge, the next move collides again and bad things happen.
      
      For now we just push the ball out horizontally; the better fix is to
      have the collision code do the vector reflections so it can handle
      horizontal collisions differently.
      7a194799
  6. 26 Mar, 2016 4 commits
    • Terence Martin's avatar
      Initial draft of new collision code (imperfect) · cc261b3d
      Terence Martin authored
      This modifies how collisions work so that we now use the line->rect
      collision to determine if the ball has intersected the paddle, even
      if its moving too fast.
      
      When a collision is detected, we shift the position of the ball
      backwards along its movement vector until it is just touching the
      paddle.
      
      More work needs to be done here; in particular, the same action
      should be used to adjust the ball when it bounces on the top and
      bottom of the screen so that it never physically leaves the screen.
      cc261b3d
    • Terence Martin's avatar
      Switch ball velocity to be a Vector · f6d2648c
      Terence Martin authored
      This cleans up the code a little bit, and is being done in preparation
      for upcoming collision work that is going to noodle with the ball
      position a bit.
      f6d2648c
    • Terence Martin's avatar
      Switch to ts-game-engine 0.2.7 · e5673222
      Terence Martin authored
      This includes some new vector api methods that might come in handy.
      e5673222
    • Terence Martin's avatar
      Update to the latest version of TypeScript · b88d6376
      Terence Martin authored
      As outlined in the similar recent commit in ts-game-engine, this
      change is to support upgrading the TypeScript compiler to the latest
      version and telling WebStorm to use our own version and not its
      internal version.
      
      The implications of this are that the module type in the config file
      needs to be one that supports outputting to a single file (in case we
      ever actually use a module properly) and that the output of the compiler
      tends to have parenthesis in different places for scope wrappers.
      b88d6376
  7. 24 Mar, 2016 1 commit
    • Terence Martin's avatar
      Switch to ts-game-engine 0.2.6 · b6145fd4
      Terence Martin authored
      This includes the new collision routines that we need in order to
      (mostly) stop the ball from being able to pass straight through the
      paddle if it is moving fast.
      b6145fd4
  8. 12 Feb, 2016 3 commits
    • Terence Martin's avatar
      Use new collision code · fd0c4bd4
      Terence Martin authored
      Now the engine is responsible for checking for collisions instead of
      the ball doing it on its own. Since the methods that do it are the
      same, this requires just the removal of the method here.
      
      Note that the original (now removed) method was careful not to do
      collision detection when the ball might be behind the paddle.
      
      This was necessary because currently the ball might be moving fast
      enough in one direction but not the other that it would take two
      frames to exit instead of just one.
      
      That's still technically a problem, but some upcoming changes to be
      made will make the ball check collisions in a different way that will
      stop this from happening.
      fd0c4bd4
    • Terence Martin's avatar
      Initial changes for latest engine version · 276dea62
      Terence Martin authored
      This provides the alterations needed to use the new sprite sheet
      functionality of the latest version of the image.
      
      The sprites for the different balls and paddles are now in single
      image files, which cuts down on the number of things to preload and
      makes the code clearer.
      276dea62
    • Terence Martin's avatar
      Merge in version 0.2.5 ; SpriteSheet changes · 236226c6
      Terence Martin authored
      This will give us the new API functions that we need to load
      SpriteSheets the way that we want to in the game.
      236226c6
  9. 11 Feb, 2016 1 commit
    • Terence Martin's avatar
      Update the code to the latest ts-game-engine · 2bfd71f6
      Terence Martin authored
      This brings in the latest ts-game-engine, 0.2.4, replacing the used
      0.2.1 version.
      
      This just updates the engine version used; no porting effort has been
      done yet to use the new features.
      2bfd71f6
  10. 19 Jan, 2016 17 commits
    • Terence Martin's avatar
      c3622c4d
    • Terence Martin's avatar
      Include controls in index file · 697b920b
      Terence Martin authored
      697b920b
    • Terence Martin's avatar
      Fix one last TODO · aa269ff3
      Terence Martin authored
      I had an "issue" with how the code that renders the score needed to
      know the widths of the paddles to make sure it was laying the score out
      correctly without overlapping the paddles. This is easy to pull off
      in the game scene where the paddles are, but less so in the win scene.
      
      In that scene the paddle widths were hard coded, which bugged me.
      
      Now there is another method to set the paddle widths that gets called
      at an appropriate time. This doesn't really matter but I like the
      idea of being able to tweak the paddle images and having things
      continue to visually "work"
      aa269ff3
    • Terence Martin's avatar
      Tighten up collision detection · 1611126a
      Terence Martin authored
      Resolve the issue where the ball can get caught inside the paddle and
      oscillate back and forth, possibly exiting on the wrong side and
      causing a score. This is done by not colliding with the right paddle
      when moving to the left and vice versa, and is something the original
      did but the initial ported code did not.
      
      Also, take into account that the ball has a thickness when colliding
      with the ceiling/floor walls.
      1611126a
    • Terence Martin's avatar
      Fix music bug · 5401269e
      Terence Martin authored
      There was a problem with the music restarting when the title scene
      became active after it had been muted. The quickest expedient was to
      have a boolean flag to tell us if the scene activation is the first
      one or not.
      5401269e
    • Terence Martin's avatar
      Change the winning score for attract mode · 40e627cc
      Terence Martin authored
      In order to make attract mode more attractive (hah!) there is now a
      smaller score to "win" before the game goes back to the title screen.
      40e627cc
    • Terence Martin's avatar
      Fully implement attract mode · f85f4c23
      Terence Martin authored
      Now, as long as the game has 0 players, different things happen in
      the scene.
      
      Anyone winning immediately goes back to the title screen, any key
      press or mouse click takes you to the title screen, and text flashes
      in the middle of the screen telling you that you can press a key to
      actually play.
      f85f4c23
    • Terence Martin's avatar
      Automatically start attract mode · 66477240
      Terence Martin authored
      The title screen will automatically kick off a 0 player game as an
      "attract mode" if no game is started after a set period of time.
      66477240
    • Terence Martin's avatar
      Support players properly · 4b89262b
      Terence Martin authored
      Since I had had the code set up for the computer to play itself, the
      boolean that used to indicate if this is a single player game instead
      now is an integer that indicates the number of players, which can be 0.
      
      When the game scene activates. it tells the paddles to track the ball
      or not as appropriate based on the number of players.
      
      We now also "properly" start the game at the title screen instead of
      on the game screen, and you can press 0 to start a game with 0
      players, making the computer play itself.
      
      Lastly, fixed a bug in the paddle code where setting tracking (or
      turning it off) invoked the wrong function to update tracking, which
      caused a problem if tracking was disabled.
      4b89262b
    • Terence Martin's avatar
      Speed up ball as the volley continues · b2bc66b8
      Terence Martin authored
      During a single volley, every time the ball bounces off of a paddle a
      certain number of times in a row, the ball image is swapped to a new
      image (color changes) and the horizontal speed of the ball is increased.
      
      Both the number of bounces and the speed increase are tune-able
      parameters.
      b2bc66b8
    • Terence Martin's avatar
      Include ball trails · 1486385c
      Terence Martin authored
      This is a configurable option in the code, and stores the last X
      positions of the ball so that this many ball images are always
      rendered, showing you the relative path of the ball.
      1486385c
    • Terence Martin's avatar
      Include sound · 258d8764
      Terence Martin authored
      This includes playing a sound when the ball bounces off of a paddle
      or the wall, or when a score happens.
      
      This was implemented by providing one extra callback for a wall
      bounce so that the game scene can hold all of the sounds instead of
      the ball doing it itself.
      
      This allows for centralizing all sound playing/muting in one handy
      place.
      258d8764
    • Terence Martin's avatar
      Add ball "English" · a6357f13
      Terence Martin authored
      In order to vary the game and add a little skill to it, the Y
      velocity of the ball varies when it impacts with the paddles.
      
      Specifically, the closer to the ends of the paddle the ball impacts,
      the faster the Y speed is, and the opposite is true closer to the
      center of the paddle.
      a6357f13
    • Terence Martin's avatar
      Include scoring and winning · 1d1ad09e
      Terence Martin authored
      Now balls that collide with the edges of the stage actually score
      points, and the game will end as appropriate.
      
      I also added a TODO for a defect in the collision code.
      1d1ad09e
    • Terence Martin's avatar
      Fix a return value "issue" · 36d95be4
      Terence Martin authored
      Not really a problem, but the code that sets the entity dimensions on
      preload is a lambda that should specify that it returns no value.
      
      This has no impact on anything, but I'm trying to get into the habit
      of always specifying the return value of a method/function.
      36d95be4
    • Terence Martin's avatar
      Include paddle collision · b2ed2f60
      Terence Martin authored
      This is actually implemented as generic collision with any registered
      entity. Currently however, the mechanism only allows for horizontal
      intersections (reflecting on the X axis only).
      b2ed2f60
    • Terence Martin's avatar
      Fix the AI for centering after returning the ball · 6ee0136f
      Terence Martin authored
      This change is a two-fer. Firstly, there was a problem with the
      previous code (which admittedly is only because we don't support
      bouncing off the paddles yet) in which a paddle might not center
      itself if the ball is behind it when it returns.
      
      Now the calculation for the ball traveling away from the paddle is
      based on the direction of the ball and what side of the field the
      paddle is on. This is really only required for debugging since the
      computer paddle is otherwise always on the right, but I hate hard
      coding things.
      
      While I was in the area I fixed an oversight on my part in which the
      center-on-return should be subject to the paddle targeting fudge
      just as a regular return is, so that the computer doesn't look too
      human.
      6ee0136f