Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

#1 2021-04-27 10:57:15

LegolandoBloom
New member
Registered: 2020-12-16
Posts: 5

Advice for background collision logic - GBDK

Hello people of the forum, I am trying to develop simple background collision using gbdk. I believe I can either run a loop on the main character to detect background objects, or I can make the background objects detect the player on every cycle.
Which one would be the better practice, and why? If I'm not explaining what I mean correctly please tell me and I'll try to elaborate.

Offline

 

#2 2021-04-28 04:39:41

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: Advice for background collision logic - GBDK

Depends on the amount of objects. Game boy is rather limited system, so it is recommended to reduce the amount of computations.

More common way is to detect collisions with a collision map - rectangle array in memory, that shows which tiles are collidable. In simple cases background tile map may be a collision map.

But it is not recommended to read from vram, which may seem an obvious solution.

Last edited by toxa (2021-04-28 04:47:49)

Offline

 

#3 2021-04-28 08:05:47

LegolandoBloom
New member
Registered: 2020-12-16
Posts: 5

Re: Advice for background collision logic - GBDK

toxa wrote:

Depends on the amount of objects. Game boy is rather limited system, so it is recommended to reduce the amount of computations.

More common way is to detect collisions with a collision map - rectangle array in memory, that shows which tiles are collidable. In simple cases background tile map may be a collision map.

But it is not recommended to read from vram, which may seem an obvious solution.

Thanks! Is there a resource on making a collision map or can you refer me to an example?

Edit: What I have been doing is storing background objects in 4 variable structs, x, width, y, height, kind of like treating them like entities. Is what I am doing wrong?

Last edited by LegolandoBloom (2021-04-28 08:09:07)

Offline

 

#4 2021-04-29 05:13:09

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: Advice for background collision logic - GBDK

LegolandoBloom wrote:

Edit: What I have been doing is storing background objects in 4 variable structs, x, width, y, height, kind of like treating them like entities. Is what I am doing wrong?

you were not doing anything wrong, especially if you want some complex pixel-based collisions. the problem is to implement fast checking: iterate as little objects as possible. or else it won't work with reasonable speed on the game boy.

Offline

 

#5 2021-04-29 10:17:57

LegolandoBloom
New member
Registered: 2020-12-16
Posts: 5

Re: Advice for background collision logic - GBDK

toxa wrote:

LegolandoBloom wrote:

Edit: What I have been doing is storing background objects in 4 variable structs, x, width, y, height, kind of like treating them like entities. Is what I am doing wrong?

you were not doing anything wrong, especially if you want some complex pixel-based collisions. the problem is to implement fast checking: iterate as little objects as possible. or else it won't work with reasonable speed on the game boy.

Thanks toxa, I was getting anxiety that I was approaching it the wrong way, you helped me with that

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson