[gameprogrammer] Re: Map Collision
- From: Paul Smith <bob@xxxxxxxxxxxxxxx>
- To: Game Programmer List <gameprogrammer@xxxxxxxxxxxxx>
- Date: Fri, 18 Jun 2004 23:50:03 +0100
On Fri, 2004-06-18 at 22:16, Gregg Bolinger wrote:
> Ok, I search the archives and couldn't find what I was looking for. I
> am just getting into game programming and am using SDL and C++. I've
> done a lot of examples and am getting the hang of everything. So I
> thought I would venture away from tutorials and try and make something
> of my own.
>
> I know how to do sprite animation and generic collision detection of
> sprites. And I know how to scroll a background. What I don't know
> how to do is detect collision with background data. For example, I am
> making a game sort of like spy hunter but with a NASCAR twist.
> Anyway, I need to adjust the speed of my sprites when they come in
> contact with the side of the road.
>
> Any information, links, tips on how to achieve this would be great.
>
There's a couple of ways that spring to mind. Firstly, you could use a
particular colour from the palette to draw a line between the road and
off-road areas, and detect that colour from the background data.
Or, you could double up on the background data by saving another set of
background data with just 2 colours, white for on road and black for off
road (perhaps using shades of grey to determine a friction
coefficient?). If you use an image type with an alpha channel, you
could use the alpha channel to store the friction coefficient.
Or, you could store the co-ordinate of the left and right edge of the
road in a separate numerical file, and test to see when the car has hit
those co-ordinates. There's really quite a lot of ways to attack the
problem :)
Hope this helps!
> Thanks.
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Map Collision
- From: Gregg Bolinger
Other related posts:
- » [gameprogrammer] Map Collision
- » [gameprogrammer] Re: Map Collision
- [gameprogrammer] Map Collision
- From: Gregg Bolinger