#79124 - blahh - Tue Apr 11, 2006 7:51 pm
Can someone please help me with my collisions, i'm totally lost on how to do them, or even how they work...yes i've read the tutorials....
I'm making a game, and for testing's sake i put yellow blocks on the map and I want to know when the helicopter hits them.
The helicopter moves up and down, and the map moves left (looks like copter is moving right, but always stays in same x coordinate..)
The collisions can occur on the front, top, and bottom of the helicopter.
I know you have to get the tile to see if its transparent, but I dont know how to do this.
Please take a look at my source and help me write collision detection:
http://www.savefile.com/files2.php?fid=5459605
open "project.vhw" for source, and run "build.bat" for easiest compile
-thanks
#79147 - Fenderocker - Tue Apr 11, 2006 9:45 pm
you basicly ckeck to see if the x cordinate is the same or less than any given block and then if yess check to see if any part of the heli is inside the block.
Hope that helped
#79150 - blahh - Tue Apr 11, 2006 9:55 pm
Okay. But how would i find out the coordinates of the blocks/not transparent areas?
without using the map's scrollx variable that scrolls the background though....
so basically, I want to use the map.c as used in the platform game demo to check if the tile in front/top/bottom of the heli is transparent or not...
Thats what I dont know how to do :/
Thanks :]
#79156 - tepples - Tue Apr 11, 2006 10:24 pm
blahh wrote: |
Okay. But how would i find out the coordinates of the blocks/not transparent areas? |
For one thing, many scrolling games seem to approximate the boundaries of a sprite with a rectangle or circle, which can be more easily tested against the background.
Quote: |
without using the map's scrollx variable that scrolls the background though.... |
You will probably need to keep your sprite's position in "world space" and then transform it to "camera space" after each frame.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#79159 - blahh - Tue Apr 11, 2006 10:33 pm
The palib platform game demo used this method to return the value of the tile mario is at
Code: |
u8 GetTile(s16 x, s16 y){
if (x < 0) return 1; // Say it was a collision...
return mario_world_Map[((y>>3)*128) + (x>>3)];
} |
i have no idea how to change this for the helicopter (other than mario_world_Map to map_Map).
The x value is always at 50, and y value, ranges from 0 to (191-32)
uhh so annoying..
#79391 - LiraNuna - Thu Apr 13, 2006 11:34 am
Instead of wrestling with PAlib, Start to use real libraries.
#79421 - omaremad - Thu Apr 13, 2006 4:49 pm
whats wrong with you people and palib
Code: |
u8 GetTile(s16 x, s16 y){
if (x < 0) return 1; // Say it was a collision...
return mario_world_Map[((y>>3)*128) + (x>>3)];
}
|
the marioworld map is the tileset for the bg
collision is done by ignoring magenta tiles which are exported as nulls by PAGFX
each 8 pixels are grouped to a tile and the collision is based on a bounding box style on these tiles
for the helicopter you just you the same function.....
it is explained very clearly in the palib wiki
seriously lirluna if people want palib let them be its speeds up a lot of stuff
if you want to do some advanced stuff like vram manage ment then you can still do that and use palib.....
#79851 - keldon - Sun Apr 16, 2006 1:23 pm
why the 8 bit and 16 bit variables?