mirror of
https://github.com/jorgevasquezp/GodotAsteroids.git
synced 2026-08-16 15:31:12 +00:00
Started implementing the ship's control scheme
This commit is contained in:
+2
-3
@@ -2,7 +2,6 @@
|
||||
|
||||
[ext_resource path="res://Scripts/Ship.gd" type="Script" id=1]
|
||||
|
||||
|
||||
[node name="Ship" type="Node2D" index="0"]
|
||||
|
||||
script = ExtResource( 1 )
|
||||
@@ -10,9 +9,9 @@ __meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
max_speed = 5
|
||||
accel = 0.1
|
||||
accel = 1.1
|
||||
radial_max_speed = 1
|
||||
radial_accel = 0.1
|
||||
radial_accel = 0.05
|
||||
|
||||
[node name="ShipShape" type="Polygon2D" parent="." index="0"]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Ship.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="Space" type="Node2D"]
|
||||
|
||||
[node name="Ship" parent="." index="0" instance=ExtResource( 1 )]
|
||||
|
||||
position = Vector2( 577, 440 )
|
||||
|
||||
|
||||
+6
-1
@@ -7,6 +7,7 @@ export (float) var radial_accel
|
||||
|
||||
var speed
|
||||
var radial_speed
|
||||
var angle
|
||||
|
||||
# class member variables go here, for example:
|
||||
# var a = 2
|
||||
@@ -14,7 +15,8 @@ var radial_speed
|
||||
|
||||
func _ready():
|
||||
speed = 0
|
||||
radial_speed = 0
|
||||
radial_speed = 0
|
||||
angle = 0
|
||||
|
||||
# Called when the node is added to the scene for the first time.
|
||||
# Initialization here
|
||||
@@ -37,6 +39,9 @@ func _process(delta):
|
||||
speed = drag(speed,.9)
|
||||
radial_speed = drag(radial_speed,.9)
|
||||
|
||||
rotation += angle + radial_speed
|
||||
position += Vector2( speed * sin( rotation ) , speed * cos ( rotation ) )
|
||||
|
||||
print( str(speed) + "," + str(radial_speed) )
|
||||
# # Called every frame. Delta is time since last frame.
|
||||
# # Update game logic here.
|
||||
|
||||
@@ -11,6 +11,7 @@ config_version=3
|
||||
[application]
|
||||
|
||||
config/name="Asteroids"
|
||||
run/main_scene="res://Scenes/Space.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[rendering]
|
||||
|
||||
Reference in New Issue
Block a user