I used a similar approach in a platformer I wrote in another Basic. It wasnt a game really, just an experiment with collision upon sloped and un-even ground.
I did 8 pixel checks around the sprite i.e. North, North East, East etc. The bottom checks - South West & South East looked for a non transparent part of a sprite. Once collision had occured I checked if the area 1,-1 (one pixel across , one up) was transparent. If this was the case I altered the Xdir and Ydir accordingly.
I did the following checks (0,1) (1,-1) (1,-2) (1,-2) (2,-2) which resulted in a realisitc looking walk along terrain.
I eventually created a TYPE containg image,x, y, Cos value and Sin values. When the player collided with the image I altered the players xdir & ydir to the Cos and Sin values associated with it. The player sprite was then rotated after comparing its current angle to the collison values This resulted in a Sonic style looking game.
|