ok so I completely forgot to actually keep a journal while building this lol, so i’m just writing down what i did from memory.
rough order so far:
built the nodes first (bunch of Area2Ds + shapes), then started actually coding and now the bomb’s finished
bomb, player and the coin got two children:
a Polygon2D - the red triangle you see. i drew it as a polygon instead of using an image, so there’s no asset/importing stuff to deal with
a CollisionShape2D - a little circle(for coin and the bomb) and a rectangle(for the player). this is the actual hitbox.
the bomb code:
the bomb is an Area2D, which is basically a detection zone.
the main idea is the signal hit_player. the bomb has no clue what the score is or that a game-over screen even exists- it just shouts “hit_player” and main.gd listens and deals with it. keeps the bomb simple and reusable, its only job is to fall and to say when it hit you
_physics_process moves it down every frame with position.y += fall_speed * delta. the * delta is what keeps it falling at the same speed no matter the framerate
if it drops past the bottom of the screen it calls queue_free() to delete itself — otherwise every bomb that misses just keeps falling forever and piles up
_on_area_entered runs when something overlaps it, but coins and the player are all Area2Ds too, so it checks is_in_group(“player”) first to make sure it’s actually the player -> then emits hit_player and removes itself
I’ll make the coin code after that(same Area2D, same falling, same group check - it’ll just emit a “collected” signal and add a point instead of ending the game) and then player+main cuz those 2 will be harder ig
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.