Jump to content

Mord's Blog

  • entries
    170
  • comments
    93
  • views
    100,661

(Action RPG) Sliding against walls


Mord

343 views

Adding simple collision detection was easy. Test missile vs playfield/ball, back up the player if collision detected. Of course, that gives the predictable result of sticky walls. I wanted to be able to slide against the wall. Less frustrating that way. :ponder:

 

That wasn't quite as easy, and failed brilliantly... and comically... a couple times as I wondered why the heck touching upper walls acted like some sort of player trap that would drag their butts violently off the screen regardless of any hardcoded screen boundaries.

 

Then I found my two problems.

 

1) A 0 indicates that a button is pressed. Not a 1. Changed the associated "and"s I used into "ora"s. That fixed up some of the sliding, but horizontal walls were still sticky.

 

Took a little bit longer of looking at the code to notice my little tests counter wasn't being reset properly all the time. If the horizontal test succeeded (it's the first of two) then the counter wasn't brought back down to 0. As a result it wouldn't retest the horizontal movement again unless I tried moving against a vertical wall (Which did reset the counter properly)

 

At any rate...

 

2) Added a clearing of the CollisionTests counter whenever we were looking at the joystick again for input. The only time it checks the joystick for input is if it didn't spot a collision with the playfield/ball, so obviously we should reset the variable. This way the next time a collision -is- detected, it will properly (and reliably) perform a horizontal test.

 

Version 0.005 is about collision detection, which is technically done. But there are a few more things I want to fix up or clean up before I consider it "done". For one, collision testing like this causes the player to slow down while moving against the wall due to the lost frames of checking for movement in the X or Y direction. I want to speed that up. Moving further in the direction tests to make up for the lost frames should make it seem to the player that no speed is lost at all.

 

However. I was planning on changing the simplistic movement code that's hardwired in there right now with something that works on fractional/fixed-point math. I might as well do that now while I'm working on this, or I'll just have to come back and muck with it again unnecessarily later. ;)

 

Attached is a binary of what's done so far for version 0.005. You'll notice the slowdown while sliding against the walls. Horizontal testing is done first, followed by the vertical test. This is why vertical sliding looks absolutely horrible compared to the horizontal. I'll have that fixed and the normal vertical movement put back to it's normal rate by the time I finish this version. Hopefully. :)

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...