GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 5:59 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Oct 16, 2011 7:21 pm 
Rookie

Joined: Sun Oct 16, 2011 6:45 pm
Posts: 4
I'm looking at making a game that works very differently to the ones I've made previously. Usually I just make tile-based games, but I want to experiment a bit more.

The game I want to make will have a terrain similar to what you've seen in the "worms" games (curved, weirdly shaped hilly type land) which would be predrawn and loaded as an image. I want to have the "bullets" bounce correctly when hitting the terrain.

From my searching it appears the best solution for the collision detection is to use a per-pixel approach. I've looked up some tutorials on it and will have to experiment (if anyone has some suggestions for tutorials on this I would be grateful).

What I'm not sure how to find though is what to use for calculating what angle the 'bullet' should bounce off in when it hits the terrain - or more specifically how to determine what angle the terrain is that it's hitting. I think that what I need to do is grab a square of pixels and somehow calculate what angle they are forming so I can calculate the continued trajectory.

Would this be the correct method or is there a better way to do this?


Top
 Profile  
 
PostPosted: Sun Oct 16, 2011 7:35 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
hyarion wrote:
Would this be the correct method or is there a better way to do this?


If I remember correctly, worms had strange bouncing and things didn't always reflect as you'd expect them to. It was probably done on a pixel basis. If the missile hits the corner of a pixel, the normal is at that 45 degree angle. If the missile hits the side of a pixel, the normal is at that 90 degree angle.

The way I would do it is to create a search radius ... maybe a square of 8x8 pixels, and calculate it's centre of mass (earth pixel = 0, air pixel = 1). Then calculate the vector from the centre of the square to the centre of mass, and normalise it. :)

_________________
I ain't pushing no moon buttons.


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 7:07 am 
Rookie

Joined: Sun Oct 16, 2011 6:45 pm
Posts: 4
Thank you for your advice. Sounds perfect. I have a lot of reading up and testing to do now 8)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group