Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Complex sprite drawing and directional collision

Author
Message
The CodeSmith
22
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 14th Jun 2006 06:21
Hi, I'm working on a 2D RPG. I haven't started coding it yet, as I am still in the design stage. I was wondering if someone could help me out with some of the drawing (not making art) and collision aspects of the game. Here is what I need some help on:
-Getting objects to appear behind certain objects ex. If I have a sprite of a tree and I am above the object, how could I make it so that if I walk past it, the tree will appear in front of the character so that you can't see the character when its behind it.
-Getting only part of a sprite to allow objects to pass through it ex. Again with the tree example. Is there a way make only the stump to stop the user from passing through. The only way that I could think of would be to have two seperate sprites, but I would like to know if there was a different way.
-Allowing a sprite to only pass through the other sprite when its going in a certain direction ex. If I had a sprite of a cliff, how could I make it so that you could fall down the cliff, but not go back up it.
I'm not asking you to write the code for me, just give me some ideas and pointers, but a little example code would be appreciated.

I'm not who you think...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jun 2006 13:27
It all depends on the angle of the game. If it's isometric, it is when the player is higher than the tree that he goes behind it. You can check the y position for that. The collision also depends on the angle, and also the scale of the images. There is tile map collision, which just maps the screen out into squares. This means that the tree trunks would have to be quite thick to work properly, so that you can get a 16*16 pixel tile map on it. Or you could calculate the height of the player against the height of the tree, and just switch off collision if the player is higher than the tree trunk, then put the tree in front of the player using sprite priority.

In DB Classic you will need a Player sprite loaded at the beginning of the program for behind the trees, and loaded last for in front of everything.

The CodeSmith
22
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 14th Jun 2006 19:32 Edited at: 14th Jun 2006 19:33
Sorry, I didn't give enough info before. I'm using DBP and the game will be in the viewing angle of any of the old Final Fantasy games for SNES, or like Legend of Zelda - Link to the Past. If I remember correctly isometric is like Final Fantasy Tactics.
@ Pincho Paxton
I was originally intending to make different text files that would pass information to an array. So if I had an array like Map1(16,16) then each part of the array would contain a number and based on that number the program would place a different tile. I'm no expert so please tell me if that won't work or if there is a better way to do it.
Thanks

I'm not who you think...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Jun 2006 00:51
Yeah sort of, but the tiles do not have to be 16*16, they can be 32*32 or any size, but the collision is going to be 16*16 no matter how big the images are. So long as the tree trunks are lined up with the collision grid it does not matter how big the space around them is.

The CodeSmith
22
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 15th Jun 2006 04:43
Why would it be 16*16 everytime? It seems that the amount of lines should increase with the size of the map, otherwise the collision wouldn't be very accurate. And for the collision grid, could I just make invisible lines and check for the collision, or would I give each tile its own collision check?

I'm not who you think...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Jun 2006 10:44 Edited at: 15th Jun 2006 10:45
I am not talking about the number of tiles, I am referring to the number of pixels to detect for collision...16 pixels by 16 pixels is for you tree trunks because they are probably thin. If you have 32*32 collision is actually getting much worse not better. The smaller the number, the better the collision accuracy is.

Login to post a reply

Server time is: 2026-07-04 13:25:17
Your offset time is: 2026-07-04 13:25:17