Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[SOLVED!] Walking Through Walls (Static)


Steven M

Recommended Posts

I've devised a static engine that allows the player to move around in eight directions. The camera focuses on an object which scrolls through the frame automatically (named Camerafocus for convenience), whereas the 'mask' scrolls across the screen independent of the playing area (Scrolling Options 'Follow the Frame' etc are unticked) so the player doesn't have their finger down on the Right arrow key all the time. The overall effect gives the impression of autoscrolling, like Gradius and Soldner-X.

This engine works alright for the player colliding into walls and slopes from behind and usually horizontal walls too, but the player can still walk through vertical walls and wriggle through slopes in front of him. If the mask has Scrolling Options ticked these issues seem to be fixed, however this results in the aforementioned Right key-holding-down issues. How do I go about fixing this - to achieve this autoscrolling without static bugs?

Link to comment
Share on other sites

It's hard to say without knowing what your actual code looks like, but it sounds like maybe you're achieving the autoscroll by constantly adding to the x position of the "mask" (do you mean the player mask?) instead of adding some constant rightward momentum to your existing static movement engine which presumably already has collision detection.

Link to comment
Share on other sites

It's hard to say without knowing what your actual code looks like, but it sounds like maybe you're achieving the autoscroll by constantly adding to the x position of the "mask" (do you mean the player mask?) instead of adding some constant rightward momentum to your existing static movement engine which presumably already has collision detection.

I'm a bit nervous about sharing my code, so I apologise if the problem sounds vague or sketchy. But yeah, there's a constantly-moving object that the camera follows and a seperate object that the player controls. I might give that rightward movement idea a try, though it'll play havoc with the X/Y counters.

Link to comment
Share on other sites

Presumably you have some code roughly equivalent to this:


if key(right):
Xvel += 3;
if key(left):
Xvel += -3;
if (Xvel > 0 && !(key(right))):
XVel += -1;
if (Xvel < 0 && !(key(left))):
XVel += 1;
[/CODE]

Those being rightward acceleration, leftward acceleration, rightward deceleration, and leftward deceleration, respectively. What if you just changed the speed that gets decelerated to, so it's something higher than 0? That way you can stop or move left if you want to, but left alone, your horizontal speed will default to something positive.

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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