It is currently Mon Oct 23, 2017 3:47 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Jun 27, 2005 12:07 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
I'm asking what's the best way to handle object/player moves and collision in an action-oriented game.
I hesitate between two methods. The first one would be to separe what would be called "main position", only this one will be checked for collision stuff. The segond parameter, the "fine position" is the low bits of the main position and aren't checked at all for all colision stuff. They're only here to animate the sprite proprely, also when the fine position overlaps and so the main one will change, the sprite/object can pass to another frame (so it's arms/legs would move).
The other solution is less innovative, but it would simply check the collision trough two variables, one is position-size and the other one position+size. The position is 8 bit wide and it's the exact one of the middle of the sprite on the screen (I use only one screen at time, like Zelda, no scrooling while the game play is on). This one seems to be simpler, but I think it isn't that good to merge the visual part with the maths part, and also it would need additional counters for any frame/mooves.

One third way to handle that is to use the first one for BG-Sprite collision, and the segond one for sprite-sprite collision.

Also, another problem comes with non-playable objects (i.e. enemies). They have to move on their own, so the programm have to handle both the move of their position and of their actucal graphics. With the first method, I simply have to decide wich direction the enemy walks, run, and maybe jump (I don't know yet how I'll do the AI), and finally apply this change unless the main position reach the exepted value. Trough the segond solution, this would be harder to handle, and I don't want to have something glitchy, typically like Castlevania 2 where you fall into invisible pits and you can grow non-existing stairs during game-play.

Does annyone have comments/ideas/notices/help/tips ? That would be cool.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2005 12:34 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
I'm just afraid that this tread was highacked by other ones so nobody answered to me, or if really nobody has something to answer or found the question interesstless.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2005 1:40 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3471
Location: Indianapolis
For background hit detection, basing it on the map data in a metatile format makes a lot of sense. That sounds like your first method, right? Then you just have to check on all sides of the object and see when it's moving into the next metatile.

The scrolling shouldn't add much more for sprites. Could add/subract the scroll change to all the non-player sprite positions when it happens. And for the background, keep a counter of the position within a metatile.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2005 5:41 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I remember reading the original post and saying to myself that you've pretty much covered several workable methods. If I were in your position and wanted to find the best, I'd implement each so I could find out all the fine aspects. I'd choose the best and keep the experience from each.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 2:08 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
Blargg : Yeah, experience thing is interessting, but I wanna to know if someone has already tried something like that.
Yeah, the fist method is definitely the good one for Background collision, however, for sprite vs sprite collision, it would put all the sprites in an array like the BG, and so it could ruin the game play because you can be at the same distance between a monster and you player, but on a different place on the array and the result of the collition check would be different. This have to be tested, trough.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 6:59 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3471
Location: Indianapolis
Oh yeah, if I understand the the 2nd method correctly, that's perfect for sprites. That's the same as what I used in Munchie Attack and Roadkill. Just take an objects coordinate (same as what's in SPR-RAM), compare it to another object, subtract or add the size to the coordinate, and check again. Takes a pretty decent amount of CPU time to do all the objects, but it's fairly straight-forward.

Roadkill even used all 64 sprites, 2 for players and 62 for cars. Then I just cheated and compared the player to each individual car sprite (rather than comparing againsts objects that are made up of several sprites).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 04, 2005 3:54 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
OK thanks. I use a different way to handle the sprites I.E. the player and the objects have a variable number of sprites, but they're all relative to the same coordinate for a single object, so it's simpler.
Also, it's better to also check an ennemy to not run into another ennemy to have a decent game.

_________________
Life is complex: it has both real and imaginary components.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 8 guests


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
You cannot post attachments in this forum

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