I have an idea for a puzzle game based on the Gameboy classic Quirk. The plot of the game is pretty thin but involves a tomato dude that has to solve movey block puzzles with blocks that can move and even swivel to open a path to the level exit.
to do this I will have to draw a tilemap and then super impose the game piece on to the screen much like the way you would add the player. Then I need to write a simple collision function that will allow the player to collide with the super imposed gamepiece bitmap. I do that like this…
struct Rect{
int16_t x;
int16_t y;
uint8_t width;
uint8_t height;
};
void moveblockleft(){
Rect rectA {x,y,16,16};
Rect rectB {player_x, player_y,16,16};
if(tft.collideRectRect( rectA.x, rectA.y, rectA.width, rectA.height, rectB.x, rectB.y, rectB.width, rectB.height))
{
rectangle structure works with the first two coordinates being where the you placed the block and its size. Then the collision part looks for when rect a which is the game piece and rectb which is the player to collide. From here I could simply tell the block to move in the appropriate direction to open the path but what fun and kind of challenge would that be?
I’m gonna start simple. we have one block on the screen in the tilemap room. And I just want it to move left if I touch the right side of the block.
how do I tell the game that my block game piece has a right side? Or should I give it all four sides?