Very crude movement is now possible. Still needs more analysis and tweaking. Jump is broken.

This commit is contained in:
Hyperling 2023-09-29 21:09:04 -07:00
parent b755085356
commit b928b72955
6 changed files with 122 additions and 66 deletions

View File

@ -1,15 +1,18 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://b6rpb20w1k5k4"]
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
[ext_resource type="PackedScene" uid="uid://50xcswe0qij3" path="res://Player.tscn" id="1"]
[node name="level" type="Node2D"]
[node name="player" parent="." instance=ExtResource( 1 )]
[node name="player" parent="." instance=ExtResource("1")]
position = Vector2(602, 279)
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="Polygon2D" type="Polygon2D" parent="StaticBody2D"]
polygon = PoolVector2Array( 3, 559, 1021, 563, 1023, 601, 2, 599 )
position = Vector2(69, 24)
polygon = PackedVector2Array(3, 559, 1021, 563, 1023, 601, 2, 599)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PoolVector2Array( 3, 560, 2, 595, 1023, 599, 1019, 564 )
position = Vector2(71, 24)
polygon = PackedVector2Array(3, 560, 2, 595, 1023, 599, 1019, 564)

View File

@ -1,8 +1,15 @@
extends Node2D
extends CharacterBody2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var x_dir = 0
var moving = false
var accel = 100
var maxspeed = 125
var friction = 50
var y_dir = 0
var jumping = false
var jump_speed = 1000
var gravity = 250
# Called when the node enters the scene tree for the first time.
@ -14,14 +21,60 @@ func _ready():
# pass
func _physics_process(delta):
#velocity.y += 100 * delta
#y += 100 * delta
if Input.action_press("ui_left"):
move_local_x(-100)
if Input.action_press("ui_right"):
move_local_x(100)
if Input.action_press("ui_up"):
move_local_y(-100)
if Input.action_press("ui_down"):
move_local_y(100)
## Controls ##
# Movement
if Input.is_action_pressed("ui_left"):
moving = true
velocity.x += -accel * delta
if Input.is_action_pressed("ui_right"):
moving = true
velocity.x += accel * delta
if Input.is_action_pressed("ui_up"):
if !jumping:
jumping = true
velocity.y += -jump_speed * delta
if Input.is_action_pressed("ui_down"):
velocity.y += accel * delta
# Combat
#TBD
## Friction ##
if velocity.x != 0:
x_dir = velocity.x / abs(velocity.x)
velocity.x += friction * -x_dir * delta
if round(velocity.x) == 0:
velocity.x = 0
x_dir = 0
moving = false
## Gravity ##
if velocity.y != 0:
y_dir = velocity.y / abs(velocity.y)
if round(velocity.y) == 0:
velocity.y = 0
y_dir = 0
if jumping:
velocity.y -= gravity * -x_dir * delta
else:
jumping = false
## Speed Limits ##
if abs(velocity.x) > maxspeed:
velocity.x = maxspeed * x_dir
if abs(velocity.y) > maxspeed:
velocity.y = maxspeed * y_dir
move_and_slide()
print_debug("X Dir = " + str(x_dir) + ", X Speed = " + str(velocity.x))
print_debug("Y Dir = " + str(y_dir) + ", Y Speed = " + str(velocity.y))
pass

View File

@ -1,19 +1,20 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://50xcswe0qij3"]
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource type="Script" path="res://Player.gd" id="1"]
[sub_resource type="CapsuleShape2D" id=1]
radius = 53.0
height = 142.0
[sub_resource type="CapsuleShape2D" id="1"]
radius = 50.0
height = 248.0
[node name="player" type="Node2D"]
position = Vector2( 527, 272 )
script = ExtResource( 1 )
[node name="player" type="CharacterBody2D"]
position = Vector2(456, 304)
script = ExtResource("1")
[node name="Polygon2D" type="Polygon2D" parent="."]
position = Vector2( -5.36584, -70 )
scale = Vector2( 0.902439, 1 )
polygon = PoolVector2Array( 15, -49, -13, -49, -20, 22, -7, 61, -55, 65, -7, 80, -35.054, 175, 4, 98, 44, 177, 15, 77, 63.5676, 57, 12, 62, 23, 21 )
position = Vector2(39, -75)
scale = Vector2(0.902439, 1)
polygon = PackedVector2Array(15, -49, -13, -49, -20, 22, -7, 61, -55, 65, -7, 80, -35.054, 175, 4, 98, 44, 177, 15, 77, 63.5676, 57, 12, 62, 23, 21)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
position = Vector2(43, -5)
shape = SubResource("1")

View File

@ -1,7 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=2 format=3 uid="uid://cncgkcxp42oy4"]
[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id="1"]
[resource]
background_mode = 2
background_sky = SubResource( 1 )
sky = SubResource("1")

View File

@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://chl1xl4g1isie"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@ -10,26 +11,24 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/hdr_compression=1
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -6,12 +6,13 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
config/name="Vax Evader"
run/main_scene="res://Player.tscn"
run/main_scene="res://Level.tscn"
config/features=PackedStringArray("4.0")
config/icon="res://icon.png"
[gui]
@ -22,31 +23,31 @@ common/drop_mouse_on_gui_input_disabled=true
ui_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":97,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":100,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":119,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":115,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[physics]
@ -55,7 +56,6 @@ common/enable_pause_aware_picking=true
[rendering]
environment/defaults/default_environment="res://default_env.tres"
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"