Continuing with ShooterCarnival

It’s been a few weeks since I contributed to ShooterCarnival, and it was fun to see where they had taken it in that time. Slowly, but surely, they were updating the project and adding features, such as the shooting and enemies spawning.

I decided to g…


This content originally appeared on DEV Community and was authored by Kyle Homen

It's been a few weeks since I contributed to ShooterCarnival, and it was fun to see where they had taken it in that time. Slowly, but surely, they were updating the project and adding features, such as the shooting and enemies spawning.

I decided to go in and try to add some new features as well. I found this issue open that was asking for someone to implement the bullet and player collisions with the enemy sprites, which felt like a step up from my last contribution and a good opportunity to learn more GDScript.

I started by learning how to add the sprite node and rig it as an animation, which I actually did through the Godot editor and not through code. It was simply easier to make the new node and select the animation frames this way.

The rest of the work was through the code. I implemented the die() function that swapped the enemy sprite to the explosion sprite, disabled collisions and played the animation:

func die() -> void:
    if is_dying:
        return

    # Mark as dying
    is_dying = true
    speed = 0

    # Disable collision
    collision_shape.set_deferred("disabled", true)

    # Play explosion animation
    sprite.visible = false
    explosion_sprite.visible = true
    explosion_sprite.play("explode")
    explosion_sprite.connect("animation_finished", _on_explosion_sprite_animation_finished)

Next was triggering the die function when the bullet or player touched an enemy. When two Area2D nodes overlap, they emit signals. We use area_entered(area) to look for when another Area2D node enters the area to trigger the dying animation, as well as remove the bullet (or player).

func _on_area_entered(target: Node2D) -> void:
    # Bullet collision handling
    if target.is_in_group("bullets"):
        # Remove the bullet
        target.queue_free()
        # Explode the enemy
        die()

    # Player collision handling
    if target.is_in_group("player"):
        # Explode the enemy
        die()
        # Hide player
        target.hide()
        # TODO: Game over, or notify player of hit

For now, the issue just asks to hide the player, so that is how I implemented it.

After setting up the groups and writing the area entered logic for bullets as well, we get this, which looks ready for a pull request.


This content originally appeared on DEV Community and was authored by Kyle Homen


Print Share Comment Cite Upload Translate Updates
APA

Kyle Homen | Sciencx (2025-11-18T22:14:26+00:00) Continuing with ShooterCarnival. Retrieved from https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/

MLA
" » Continuing with ShooterCarnival." Kyle Homen | Sciencx - Tuesday November 18, 2025, https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/
HARVARD
Kyle Homen | Sciencx Tuesday November 18, 2025 » Continuing with ShooterCarnival., viewed ,<https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/>
VANCOUVER
Kyle Homen | Sciencx - » Continuing with ShooterCarnival. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/
CHICAGO
" » Continuing with ShooterCarnival." Kyle Homen | Sciencx - Accessed . https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/
IEEE
" » Continuing with ShooterCarnival." Kyle Homen | Sciencx [Online]. Available: https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/. [Accessed: ]
rf:citation
» Continuing with ShooterCarnival | Kyle Homen | Sciencx | https://www.scien.cx/2025/11/18/continuing-with-shootercarnival/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.