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.

Dark GDK / Relationship between dbPasteImage and dbSpriteCollision

Author
Message
D_A
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location:
Posted: 18th Jul 2011 00:03
Hi all,

I would like to ask a question to solve a problem. Actually, I wanna design a labyrinth game. Thefore, I need to use bricks to build the labyrinth. Normally, I created only one brick sprite and I used dbPasteSprite function to build the labyrinth by copying the sprite across the labyrinth.

Then, I created a new animated sprite which moves acrosss the channels of the labyrinth. However, the program does not detect the relationship between bricks coppied and the animated sprite only just between the original brick and the animated sprite.

Is there easy way to solve this problem? I do not wanna clone the original sprite a hundrends of time to build the labyrinth.

Cheers,

DA

DA
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 18th Jul 2011 12:15
In this type of game, I suppose you must already have a map of the labyrinth which shows you if there is a brick in a certain spot (and what type of brick, if you have several) or it is empty and walkable. For example:



and so on, where 0 means empty place and 1, 2, 5, etc. mean different drawings of bricks. In this case it's easy to calculate in which "brick place" your character currently is, and into which "brick place" it will move with its next move. If the place is not empty, don't allow the character to move there.

This is the easiest to code in games where the character moves one place with each move. But if the movement is continuous and not just jumping from place to place, it can still be done. You can check the coordinates of the edge of the sprite in the direction in which it is moving, to see if that edge will collide with a brick or not. E.g. if you are moving to the right, then check the right edge position on the map after the move.
D_A
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location:
Posted: 18th Jul 2011 15:17
Thanks for your message.

As you said "If the place is not empty, don't allow the character to move there." I used dbSpriteCollisioon not to allow the character to move to the place which is not empty. But, it is becoming challange to use that function. I will think about this for a while again.

Cheers,

Dursun

DA

Login to post a reply

Server time is: 2024-11-19 09:49:17
Your offset time is: 2024-11-19 09:49:17