This commit is contained in:
2025-09-03 17:36:59 +02:00
commit 8468769d70
36 changed files with 746 additions and 0 deletions

44
ship.gd Normal file
View File

@@ -0,0 +1,44 @@
extends CharacterBody2D
@export var MAX_SPEED: float = 200
@export var SHOOT_NODE: PackedScene
const SPEED = 25.0
const JUMP_VELOCITY = -400.0
var mouse_position: Vector2 = Vector2.ZERO
var horizontal : float
var vertical : float
var vector_temp:= Vector2(1, 0)
var rota_temp: float
var delay := 0.0
func _input(event):
pass
if event is InputEventMouseMotion:
mouse_position = event.position
func _physics_process(delta: float) -> void:
delay += delta
if Input.is_action_pressed("ui_accept") and delay >= 0.5:
shoot()
delay = 0
horizontal = Input.get_axis("ui_up", "ui_down")
vertical = Input.get_axis("ui_left", "ui_right")
velocity.x = move_toward(velocity.x, MAX_SPEED * vertical, SPEED)
velocity.y = move_toward(velocity.y, MAX_SPEED * horizontal, SPEED)
if horizontal != 0 or vertical != 0:
vector_temp = Vector2(vertical, horizontal)
rotation = atan2(vector_temp.y, vector_temp.x)
move_and_slide()
func shoot()->void:
var new = SHOOT_NODE.instantiate()
new.direction = vector_temp
new.position = position + (18 * vector_temp.normalized())
get_parent().add_child(new)