pivoted to top-down RPG style
This commit is contained in:
1 parent
47d9874c36
commit
f9e52d23e5
24 files changed
+5674
-37
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#@tool
|
||||
#@icon
|
||||
#class_name
|
||||
extends CharacterBody2D
|
||||
## Top-down player controller
|
||||
|
||||
## Signals
|
||||
## Enums
|
||||
## Constants
|
||||
## @export variables
|
||||
@export var walking_speed: int = 100
|
||||
@export var running_speed: int = 150
|
||||
@export var turning_speed: float = 0.1
|
||||
## Regular variables
|
||||
var thrust: float = 0.0
|
||||
var rudder: float = 0.0
|
||||
var yaw: float = 0.0
|
||||
var heading: Vector2 = Vector2.UP
|
||||
var is_running: bool = false
|
||||
## @onready variables
|
||||
|
||||
## Overridden built-in virtual methods
|
||||
#func _init() -> void:
|
||||
#func _enter_tree() -> void:
|
||||
#func _ready() -> void:
|
||||
#func _process(_delta: float) -> void:
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
thrust = Input.get_axis("backward", "forward")
|
||||
rudder = Input.get_axis("turn_left", "turn_right")
|
||||
yaw = rudder * turning_speed
|
||||
|
||||
heading = heading.rotated(yaw)
|
||||
rotate(yaw)
|
||||
|
||||
is_running = Input.is_action_pressed("run") and thrust > 0.0
|
||||
if is_running:
|
||||
velocity = thrust * heading * running_speed
|
||||
else:
|
||||
velocity = thrust * heading * walking_speed
|
||||
|
||||
|
||||
move_and_slide()
|
||||
## Remaining virtual methods
|
||||
## Overridden custom methods
|
||||
## Remaining methods
|
||||
## Subclasses
|
||||
@@ -0,0 +1 @@
|
||||
uid://cmggbqdffjgwf
|
||||
@@ -0,0 +1,51 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dyerg4wkjmayq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cmggbqdffjgwf" path="res://spares/player.gd" id="1_4flbx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsmtdok8be7d8" path="res://scenes/debug_label.tscn" id="3_i3pqv"]
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_4flbx")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2(0, -0.16666603)
|
||||
polygon = PackedVector2Array(0, -20, 10, 15, 0, 5, -10, 15)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
zoom = Vector2(4, 4)
|
||||
|
||||
[node name="PlayerDebug" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PlayerDebug"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="ThrustLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "thrust"
|
||||
|
||||
[node name="RudderLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "rudder"
|
||||
|
||||
[node name="YawLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "yaw"
|
||||
|
||||
[node name="HeadingLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "heading"
|
||||
|
||||
[node name="IsRunningLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "is_running"
|
||||
|
||||
[node name="VelocityLabel" parent="PlayerDebug/VBoxContainer" node_paths=PackedStringArray("target") instance=ExtResource("3_i3pqv")]
|
||||
layout_mode = 2
|
||||
target = NodePath("../../..")
|
||||
variable_name = "velocity"
|
||||
Reference in new issue
Block a user