Software engineering #1- A first function: collision

1 minute read

н3110 ω0Я1δ,

This morning (well this morning, at 3 am…) I finished the first function (https://github.com/PainsPerdus/gboi-rocket/wiki/collision-doc). The collision function is a critical function of the game, which will be called a lot of times. Thus, this function is meant to evolve.

We debated yesterday and this morning (the real morning this time) about what this function should do, or what argument we should give it. For now this version takes a position and a size id for both element checked. We may implement another function for the bullets which takes only a point for the first element. Another optimization possible is to tell if the first hitbox is already loaded.

Dorian pointed out to me that using the RAM to store the variable is SLOOOOOOOWWWWWWW. Too bad for a critical function. The thing is that this function needs (at least) 8 variables (and even a little more), so there are not enough registers. We are thinking of using the HRAM as a cache for functions, and putting the stack in the WRAM.

For now, this function is tested with the pong game, and it works well. We will use it for the first milestone. Then we will consider our options to optimize this function if needed.

I also used this function to think about the documentation and used it for the first documentation page. (More about that in my next article :smirk_cat:)

edit: Turns out HRAM and WRAM are the same speed

JM