Star Child Dev Log #23
Jay Ingle - lead developer, designer, and artist:
Hello, this will be the final in our series examining the ingredients that make up our Lava Bomber enemy. See the past few weeks for all the rest.
This is our completed enemy, with placeholder graphics:

Today we will be taking a look at the lava bomb itself, that the bomber drops on your head. In the last devlog, we looked at how the lava bomb is its own scene, and how we instantiate it at the proper time, in the proper place. You can see that code here:

But for now, let us take a look at the node structure of our lava bomb scene:

We have our root node, which is a RigidBody2D (extended class: RigidProjectileClass, but we will talk about that later). We have an unused collision shape simply because Godot will complain if we don't have one directly related to our RigidBody2D. This has no layers selected, so it will not interact with anything else. We have our AnimatedSprite. We have an Area2D that we use for detecting the player's hitbox, as well as detecting when it hits a wall/floor. If we were to use the RigidBody2D to detect the player's hitbox, then the RigidBody2D would push the player, in Godot's physics engine. We only want the projectile to damage the player, not influence their position (beyond a bit of knockback). But we still want to use a RigidBody2D node, since this gives us access to the physics engine, for other reasons. A standard death timer, which we explained the functionality of last time. An VisibleOnScreenNotifier node, which will allow us to detect when the projectile has gone off-screen, so we can remove it from the game accordingly. And finally, a particle explosion when it hits something.
Unlike last time, when we talked about NOT having multiple classes for enemies based on their root node, we do have a class for each type of projectile. This is because each type of projectile essentially acts very similarly, and it is easier to keep these things in mind. Whereas, enemies can have all kinds of unusual behavior, and it is harder to keep track of classes in this case (entirely due to Godot's way of handling classes).
Here is our entire lava bomb script:

The power variable at the top controls how strongly the projectile is going to be pushed by the physics engine, upon spawning it. The _ready() function is automatically called when the lava bomb enters the scene. Because we are extended from the RigidBody2D node, Godot gives us an apply_impulse() function that we use to push the projectile in the direction we want, with the amount of power we want. So, lava bomb is spawned in by the lava bomber, then the impulse is applied, pushing the bomb downward, at which point the physics engine takes over, gravity is applied every frame, etc.
We talked about body_entered signals last time, this is much the same. We do not have to create the explode_and_die() or damage_player() functions because they are already in our RigidProjectileClass script.
Well that is about it for the Lava Bomber enemy, and the Lava Bomb it spawns. Perhaps next time I can show you the graphics that will actually be in the game.
If you have any tips, advice, or ideas about any of the last several devlogs, please do post them. I am well aware that I am not the most experienced programmer, and I often stumble around blindly, learning the quirks of the Godot engine. But even if my methods are not the best, I make em work! Nothing more important than that.
Hello, this will be the final in our series examining the ingredients that make up our Lava Bomber enemy. See the past few weeks for all the rest.
This is our completed enemy, with placeholder graphics:

Today we will be taking a look at the lava bomb itself, that the bomber drops on your head. In the last devlog, we looked at how the lava bomb is its own scene, and how we instantiate it at the proper time, in the proper place. You can see that code here:

But for now, let us take a look at the node structure of our lava bomb scene:

We have our root node, which is a RigidBody2D (extended class: RigidProjectileClass, but we will talk about that later). We have an unused collision shape simply because Godot will complain if we don't have one directly related to our RigidBody2D. This has no layers selected, so it will not interact with anything else. We have our AnimatedSprite. We have an Area2D that we use for detecting the player's hitbox, as well as detecting when it hits a wall/floor. If we were to use the RigidBody2D to detect the player's hitbox, then the RigidBody2D would push the player, in Godot's physics engine. We only want the projectile to damage the player, not influence their position (beyond a bit of knockback). But we still want to use a RigidBody2D node, since this gives us access to the physics engine, for other reasons. A standard death timer, which we explained the functionality of last time. An VisibleOnScreenNotifier node, which will allow us to detect when the projectile has gone off-screen, so we can remove it from the game accordingly. And finally, a particle explosion when it hits something.
Unlike last time, when we talked about NOT having multiple classes for enemies based on their root node, we do have a class for each type of projectile. This is because each type of projectile essentially acts very similarly, and it is easier to keep these things in mind. Whereas, enemies can have all kinds of unusual behavior, and it is harder to keep track of classes in this case (entirely due to Godot's way of handling classes).
Here is our entire lava bomb script:

The power variable at the top controls how strongly the projectile is going to be pushed by the physics engine, upon spawning it. The _ready() function is automatically called when the lava bomb enters the scene. Because we are extended from the RigidBody2D node, Godot gives us an apply_impulse() function that we use to push the projectile in the direction we want, with the amount of power we want. So, lava bomb is spawned in by the lava bomber, then the impulse is applied, pushing the bomb downward, at which point the physics engine takes over, gravity is applied every frame, etc.
We talked about body_entered signals last time, this is much the same. We do not have to create the explode_and_die() or damage_player() functions because they are already in our RigidProjectileClass script.
Well that is about it for the Lava Bomber enemy, and the Lava Bomb it spawns. Perhaps next time I can show you the graphics that will actually be in the game.
If you have any tips, advice, or ideas about any of the last several devlogs, please do post them. I am well aware that I am not the most experienced programmer, and I often stumble around blindly, learning the quirks of the Godot engine. But even if my methods are not the best, I make em work! Nothing more important than that.