first Prototype
This commit is contained in:
parent
89503407e7
commit
c887a2168c
78 changed files with 2494 additions and 2 deletions
42
scenes/spaceShip/player/player.gd
Normal file
42
scenes/spaceShip/player/player.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
class_name Player extends "res://scenes/spaceShip/spaceShip.gd"
|
||||
|
||||
@onready var dashCooldown = $dashCooldown
|
||||
@onready var spawnPointPool = $spawnPointPool
|
||||
|
||||
@export var spawnDistance: int = 1000
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Input.is_action_pressed("attack"):
|
||||
attack()
|
||||
|
||||
look_at(get_global_mouse_position())
|
||||
rotation += PI / 2
|
||||
var direction = Input.get_vector("moveLeft", "moveRight", "moveForward", "moveBackward").normalized().rotated(rotation)
|
||||
if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped():
|
||||
dash()
|
||||
velocity = velocity.lerp(direction * speed, acceleration * delta)
|
||||
move_and_slide()
|
||||
if timeGhost != null:
|
||||
moveTimeGhost(global_position, rotation)
|
||||
|
||||
|
||||
func _on_hurt_area_hurt(amount: int) -> void:
|
||||
damage(amount)
|
||||
|
||||
func dash():
|
||||
dashCooldown.start()
|
||||
global_position += Vector2.UP.rotated(rotation) * 1000
|
||||
|
||||
func getRandomSpawnPointPosition() -> Vector2:
|
||||
var rng = RandomNumberGenerator.new()
|
||||
print(deg_to_rad(rng.randi_range(0, 360)))
|
||||
print(Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance)
|
||||
return global_position + Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance
|
||||
#return spawnPointPool.get_children()[rng.randi_range(0, spawnPointPool.get_children().size()-1)].global_position
|
||||
1
scenes/spaceShip/player/player.gd.uid
Normal file
1
scenes/spaceShip/player/player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0i8gdbb8f6ic
|
||||
53
scenes/spaceShip/player/player.tscn
Normal file
53
scenes/spaceShip/player/player.tscn
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bmc2exqutt6vu"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_nnn47"]
|
||||
[ext_resource type="Script" uid="uid://0i8gdbb8f6ic" path="res://scenes/spaceShip/player/player.gd" id="2_acneu"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_0gv45"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0gv45"]
|
||||
radius = 56.5685
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0gv45"]
|
||||
size = Vector2(112, 112)
|
||||
|
||||
[node name="Player" groups=["player"] instance=ExtResource("1_nnn47")]
|
||||
collision_layer = 12
|
||||
collision_mask = 3
|
||||
motion_mode = 1
|
||||
script = ExtResource("2_acneu")
|
||||
spawnDistance = 1000
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("CircleShape2D_0gv45")
|
||||
|
||||
[node name="CollisionShape2D" parent="hurtArea" index="0"]
|
||||
shape = SubResource("RectangleShape2D_0gv45")
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("3_0gv45")
|
||||
|
||||
[node name="dashCooldown" type="Timer" parent="." index="5"]
|
||||
wait_time = 10.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." index="6"]
|
||||
|
||||
[node name="spawnPointPool" type="Node2D" parent="." index="7"]
|
||||
|
||||
[node name="spawnPoint" type="Marker2D" parent="spawnPointPool" index="0"]
|
||||
position = Vector2(360, -176)
|
||||
|
||||
[node name="spawnPoint2" type="Marker2D" parent="spawnPointPool" index="1"]
|
||||
position = Vector2(392, 256)
|
||||
|
||||
[node name="spawnPoint3" type="Marker2D" parent="spawnPointPool" index="2"]
|
||||
position = Vector2(-416, 224)
|
||||
|
||||
[node name="spawnPoint4" type="Marker2D" parent="spawnPointPool" index="3"]
|
||||
position = Vector2(-408, -168)
|
||||
|
||||
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
|
||||
[connection signal="timeout" from="dashCooldown" to="." method="_on_dash_cooldown_timeout"]
|
||||
|
||||
[editable path="hurtArea"]
|
||||
9
scenes/spaceShip/player/spawnPoint/spawnPoint.tscn
Normal file
9
scenes/spaceShip/player/spawnPoint/spawnPoint.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ih6mpdh1paql"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_oytj4"]
|
||||
radius = 64.0
|
||||
|
||||
[node name="SpawnPoint" type="Area2D"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_oytj4")
|
||||
Loading…
Add table
Add a link
Reference in a new issue