gaming
This commit is contained in:
parent
57eeede288
commit
57f147236a
13 changed files with 227 additions and 24 deletions
14
ship.gd
14
ship.gd
|
|
@ -1,7 +1,11 @@
|
|||
extends RigidBody2D
|
||||
|
||||
signal moved
|
||||
|
||||
@export var thrust_power : float = 1
|
||||
@export var turn_power : float = 1
|
||||
@export var particles_l : CPUParticles2D
|
||||
@export var particles_r : CPUParticles2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -10,9 +14,15 @@ func _ready() -> void:
|
|||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var turning : float = Input.get_axis("turn_left","turn_right") * turn_power
|
||||
var thrust : float = Input.get_action_strength("thrust") * thrust_power
|
||||
|
||||
particles_l.emitting = thrust != 0
|
||||
particles_r.emitting = thrust != 0
|
||||
if Input.is_action_just_pressed("thrust"):
|
||||
moved.emit()
|
||||
#pass
|
||||
apply_torque(turning)
|
||||
apply_force(Vector2(-thrust,-thrust) * transform.y )
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue