AugGodotGameCourse/indigogameone/scripts/bullet.gd

24 lines
1.0 KiB
GDScript

extends Area2D
@onready var bulletsprite: Sprite2D = $Sprite2D
var speed := 700 #implied type colon equal it looks at what you're trying to store in memory and put similar things together which is much faster for your operating system to process
signal hit(bullet, body)
#make signal that when it hits something gonna send a bit of info
func setSpeed(speedVal):
#by default will be 700, but can change here if we want
speed = speedVal
if speedVal < 0:
bulletsprite.flip_h = true
else:
bulletsprite.flip_h = false
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta
#we directly manipulating that transform but only on the x.. then we are multiplying it by speed and this physics process func will be called over and over again ..delta is the amt of time that has passed between physics process being called.. it's our fps basically..so person on low frame rate will move a bit farther.. variance between frame rates..
func _on_body_entered(body: Node2D) -> void:
print("I done some hittin")