Very crude movement is now possible. Still needs more analysis and tweaking. Jump is broken.
This commit is contained in:
parent
b755085356
commit
b928b72955
@ -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="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="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
[node name="Polygon2D" type="Polygon2D" parent="StaticBody2D"]
|
[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"]
|
[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)
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
extends Node2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
var x_dir = 0
|
||||||
# var a = 2
|
var moving = false
|
||||||
# var b = "text"
|
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.
|
# Called when the node enters the scene tree for the first time.
|
||||||
@ -14,14 +21,60 @@ func _ready():
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
#velocity.y += 100 * delta
|
## Controls ##
|
||||||
#y += 100 * delta
|
# Movement
|
||||||
if Input.action_press("ui_left"):
|
if Input.is_action_pressed("ui_left"):
|
||||||
move_local_x(-100)
|
moving = true
|
||||||
if Input.action_press("ui_right"):
|
velocity.x += -accel * delta
|
||||||
move_local_x(100)
|
|
||||||
if Input.action_press("ui_up"):
|
if Input.is_action_pressed("ui_right"):
|
||||||
move_local_y(-100)
|
moving = true
|
||||||
if Input.action_press("ui_down"):
|
velocity.x += accel * delta
|
||||||
move_local_y(100)
|
|
||||||
|
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
|
pass
|
||||||
|
@ -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]
|
[sub_resource type="CapsuleShape2D" id="1"]
|
||||||
radius = 53.0
|
radius = 50.0
|
||||||
height = 142.0
|
height = 248.0
|
||||||
|
|
||||||
[node name="player" type="Node2D"]
|
[node name="player" type="CharacterBody2D"]
|
||||||
position = Vector2( 527, 272 )
|
position = Vector2(456, 304)
|
||||||
script = ExtResource( 1 )
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="Polygon2D" type="Polygon2D" parent="."]
|
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||||
position = Vector2( -5.36584, -70 )
|
position = Vector2(39, -75)
|
||||||
scale = Vector2(0.902439, 1)
|
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 )
|
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="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource( 1 )
|
position = Vector2(43, -5)
|
||||||
|
shape = SubResource("1")
|
||||||
|
@ -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]
|
[resource]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 1 )
|
sky = SubResource("1")
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[remap]
|
[remap]
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="CompressedTexture2D"
|
||||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
uid="uid://chl1xl4g1isie"
|
||||||
|
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
@ -10,26 +11,24 @@ metadata={
|
|||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://icon.png"
|
source_file="res://icon.png"
|
||||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_mode=0
|
compress/hdr_compression=1
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
compress/channel_pack=0
|
||||||
flags/filter=true
|
mipmaps/generate=false
|
||||||
flags/mipmaps=false
|
mipmaps/limit=-1
|
||||||
flags/anisotropic=false
|
roughness/mode=0
|
||||||
flags/srgb=2
|
roughness/src_normal=""
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
process/hdr_as_srgb=false
|
||||||
size_limit=0
|
process/hdr_clamp_exposure=false
|
||||||
detect_3d=true
|
process/size_limit=0
|
||||||
svg/scale=1.0
|
detect_3d/compress_to=1
|
||||||
|
@ -6,12 +6,13 @@
|
|||||||
; [section] ; section goes between []
|
; [section] ; section goes between []
|
||||||
; param=value ; assign values to parameters
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
config_version=4
|
config_version=5
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Vax Evader"
|
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"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[gui]
|
[gui]
|
||||||
@ -22,30 +23,30 @@ common/drop_mouse_on_gui_input_disabled=true
|
|||||||
|
|
||||||
ui_left={
|
ui_left={
|
||||||
"deadzone": 0.5,
|
"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(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={
|
ui_right={
|
||||||
"deadzone": 0.5,
|
"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(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={
|
ui_up={
|
||||||
"deadzone": 0.5,
|
"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(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={
|
ui_down={
|
||||||
"deadzone": 0.5,
|
"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(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)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +56,6 @@ common/enable_pause_aware_picking=true
|
|||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
environment/defaults/default_environment="res://default_env.tres"
|
||||||
quality/driver/driver_name="GLES2"
|
quality/driver/driver_name="GLES2"
|
||||||
vram_compression/import_etc=true
|
vram_compression/import_etc=true
|
||||||
vram_compression/import_etc2=false
|
|
||||||
environment/default_environment="res://default_env.tres"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user