Bullets, Baddies, and Booms


Added a bad guy to shoot at and things to shoot with. Nothing looks too great yet but fixed some of my bad starfield problems.

CPUParticles2D was a little weird to figure out. When you define an emission shape with “Extents” it seems double the size I expect. Had same issue with CollisionShape, so I must be thinking about it wrong. A little trial and error fixed that. Trial and error on Speed and Lifetime causes the stars to move at the rate I want and despawn after they’ve cleared the viewport. Preprocess roughly equal to Lifetime prepopulates the viewport with starts.

Settled on a fixed viewport size, at least for the jam. That made a lot of things easier.

Found out Kinematics2D is NOT what I want. I’m going to implement all the physics stuff myself, cause I don’t understand Godot’s physics yet AND this game has super easy physics. I’ve got everything switched to Area2D and that made collisions really easy. Layer’s and masks weren’t obvious to me but somebody on discord said, “Layers are where you are, masks are where you’re looking.” Oooooooh. That helps. Thanks guys!

Used timers and signals for spawning the baddie bullets. So far this tutorial has covered everything: https://docs.godotengine.org/en/stable/getting_started/step_by_step/your_first_game.html.

One weird thing is that I wanted to use a single node for bullets and have the player or the baddie just tweak some variables when instancing. Right now the player runs this code:

	var newBullet = pewpewBullet.instance()
	newBullet.position.x = position.x
	newBullet.position.y = position.y
	newBullet.velocity.y = -1
	newBullet.speed = 400
	newBullet.color = Color(1, 1, 0)
	newBullet.collision_layer = 0b100000000
	newBullet.collision_mask = 1
	$"..".add_child(newBullet)

Setting color stymied me for a while. Then I stuck this in the bullet’s top node:

export var color = Color(1, 0.65, 0.40)
func _ready():
	$Line2D.default_color = color

Ha! Gotcha. Probly a more elegant way to do that but it works.

We’re making progress now!

Files

spacejam.zip Play in browser
Sep 03, 2021

Leave a comment

Log in with itch.io to leave a comment.