Physics or something
This commit is contained in:
1 parent
32f912df9e
commit
9a2e3d8b58
12 files changed
+293
-34
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 367 B |
Binary file not shown.
|
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 367 B |
+16
@@ -0,0 +1,16 @@
|
|||||||
|
[gd_scene format=3 uid="uid://ckqable762x8v"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://blbaaqyrt8dtk" path="res://art/block/block.png" id="1_im0tn"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f3sb7"]
|
||||||
|
size = Vector2(16, 16)
|
||||||
|
|
||||||
|
[node name="Block" type="RigidBody2D" unique_id=1409784601]
|
||||||
|
gravity_scale = 0.0
|
||||||
|
freeze = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1866755047]
|
||||||
|
shape = SubResource("RectangleShape2D_f3sb7")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1680278216]
|
||||||
|
texture = ExtResource("1_im0tn")
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dx4pfup3sbk0f"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ckqable762x8v" path="res://block.tscn" id="1_r8bmj"]
|
||||||
|
|
||||||
|
[node name="LongBlock" type="Node2D" unique_id=426800863]
|
||||||
|
|
||||||
|
[node name="Block" parent="." unique_id=1409784601 instance=ExtResource("1_r8bmj")]
|
||||||
|
|
||||||
|
[node name="Block2" parent="." unique_id=1014900089 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(16, 0)
|
||||||
|
|
||||||
|
[node name="Block3" parent="." unique_id=2110446832 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(32, 0)
|
||||||
|
|
||||||
|
[node name="Block4" parent="." unique_id=441908058 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(48, 0)
|
||||||
|
|
||||||
|
[node name="Block5" parent="." unique_id=508575690 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(-48, 0)
|
||||||
|
|
||||||
|
[node name="Block6" parent="." unique_id=185933468 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(-32, 0)
|
||||||
|
|
||||||
|
[node name="Block7" parent="." unique_id=540681257 instance=ExtResource("1_r8bmj")]
|
||||||
|
position = Vector2(-16, 0)
|
||||||
+36
-12
@@ -1,24 +1,48 @@
|
|||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
const SPEED = 400.0
|
||||||
|
|
||||||
const SPEED = 300.0
|
const GRAVITY_MULT = 0.8
|
||||||
const JUMP_VELOCITY = -400.0
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
const JUMP_VELOCITY = -410.0
|
||||||
# Add the gravity.
|
|
||||||
#if not is_on_floor():
|
|
||||||
velocity += get_gravity() * delta
|
|
||||||
|
|
||||||
# Handle jump.
|
var fall_timer = 0.0
|
||||||
#if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
|
||||||
#velocity.y = JUMP_VELOCITY
|
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
var jumps = 0
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
|
||||||
var direction := Input.get_axis("ui_left", "ui_right")
|
func _ready() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("jump"):
|
||||||
|
if is_on_floor():
|
||||||
|
velocity.y = JUMP_VELOCITY
|
||||||
|
elif !is_on_floor() and jumps >= 1:
|
||||||
|
jumps -= 1
|
||||||
|
velocity.y = JUMP_VELOCITY
|
||||||
|
|
||||||
|
if Input.is_action_pressed("jump") and is_on_wall_only():
|
||||||
|
print("WALL HANGING")
|
||||||
|
#velocity.y = 0
|
||||||
|
#velocity.x = 0
|
||||||
|
|
||||||
|
var direction = Input.get_axis("move_left","move_right")
|
||||||
if direction:
|
if direction:
|
||||||
velocity.x = direction * SPEED
|
velocity.x = direction * SPEED
|
||||||
else:
|
else:
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
|
|
||||||
|
fall_timer += 0.001
|
||||||
|
if is_on_floor():
|
||||||
|
fall_timer = 0
|
||||||
|
jumps = 1
|
||||||
|
|
||||||
|
if is_on_wall():
|
||||||
|
jumps = 1
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
|
if not is_on_floor():
|
||||||
|
velocity += (get_gravity() * GRAVITY_MULT) * delta
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
[gd_scene format=3 uid="uid://pmnwck5v0ntm"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cojhnj15psd2x" path="res://player_2d.gd" id="1_sy00s"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ccxq1fh72bsdk" path="res://art/player.png" id="2_p3026"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fj7yv"]
|
||||||
|
size = Vector2(16, 16)
|
||||||
|
|
||||||
|
[node name="Player2D" type="CharacterBody2D" unique_id=889851478]
|
||||||
|
script = ExtResource("1_sy00s")
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=962368438]
|
||||||
|
zoom = Vector2(1.2, 1.2)
|
||||||
|
position_smoothing_enabled = true
|
||||||
|
position_smoothing_speed = 0.5
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=77404965]
|
||||||
|
texture = ExtResource("2_p3026")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1294571021]
|
||||||
|
shape = SubResource("RectangleShape2D_fj7yv")
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
[gd_scene format=3 uid="uid://pmnwck5v0ntm"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cojhnj15psd2x" path="res://player_2d.gd" id="1_sy00s"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ccxq1fh72bsdk" path="res://art/player.png" id="2_p3026"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fj7yv"]
|
||||||
|
size = Vector2(16, 16)
|
||||||
|
|
||||||
|
[node name="Player2D" type="CharacterBody2D" unique_id=889851478]
|
||||||
|
script = ExtResource("1_sy00s")
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=962368438]
|
||||||
|
position_smoothing_enabled = true
|
||||||
|
position_smoothing_speed = 0.5
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=77404965]
|
||||||
|
texture = ExtResource("2_p3026")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1294571021]
|
||||||
|
shape = SubResource("RectangleShape2D_fj7yv")
|
||||||
+114
-1
@@ -35,6 +35,40 @@ move_right={
|
|||||||
"axis": 0,
|
"axis": 0,
|
||||||
"axis_value": 1.0,
|
"axis_value": 1.0,
|
||||||
"script": null
|
"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": 0,
|
||||||
|
"physical_keycode": 4194321,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 0,
|
||||||
|
"location": 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": 0,
|
||||||
|
"physical_keycode": 68,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 100,
|
||||||
|
"location": 0,
|
||||||
|
"echo": false,
|
||||||
|
"script": null
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
move_left={
|
move_left={
|
||||||
@@ -46,9 +80,43 @@ move_left={
|
|||||||
"axis": 0,
|
"axis": 0,
|
||||||
"axis_value": -1.0,
|
"axis_value": -1.0,
|
||||||
"script": null
|
"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": 0,
|
||||||
|
"physical_keycode": 4194319,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 0,
|
||||||
|
"location": 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": 0,
|
||||||
|
"physical_keycode": 65,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 97,
|
||||||
|
"location": 0,
|
||||||
|
"echo": false,
|
||||||
|
"script": null
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
single_jump={
|
jump={
|
||||||
"deadzone": 0.2,
|
"deadzone": 0.2,
|
||||||
"events": [Object(InputEventJoypadButton,
|
"events": [Object(InputEventJoypadButton,
|
||||||
"resource_local_to_scene": false,
|
"resource_local_to_scene": false,
|
||||||
@@ -58,6 +126,51 @@ single_jump={
|
|||||||
"pressure": 0.0,
|
"pressure": 0.0,
|
||||||
"pressed": false,
|
"pressed": false,
|
||||||
"script": null
|
"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": 0,
|
||||||
|
"physical_keycode": 4194309,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 0,
|
||||||
|
"location": 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": 0,
|
||||||
|
"physical_keycode": 32,
|
||||||
|
"key_label": 0,
|
||||||
|
"unicode": 32,
|
||||||
|
"location": 0,
|
||||||
|
"echo": false,
|
||||||
|
"script": null
|
||||||
|
), null]
|
||||||
|
}
|
||||||
|
move_horizontal={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventJoypadMotion,
|
||||||
|
"resource_local_to_scene": false,
|
||||||
|
"resource_name": "",
|
||||||
|
"device": -1,
|
||||||
|
"axis": 0,
|
||||||
|
"axis_value": -1.0,
|
||||||
|
"script": null
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
extends RichTextLabel
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
text = "FALL TIMER: " + str(%Player2D.fall_timer)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://boovn4st1uq41
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bos6oh7nwyeca"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ckqable762x8v" path="res://block.tscn" id="1_noju1"]
|
||||||
|
|
||||||
|
[node name="VerticalLongBlock" type="RigidBody2D" unique_id=925152188]
|
||||||
|
rotation = 1.5707964
|
||||||
|
gravity_scale = 0.0
|
||||||
|
freeze = true
|
||||||
|
|
||||||
|
[node name="Block" parent="." unique_id=1409784601 instance=ExtResource("1_noju1")]
|
||||||
|
|
||||||
|
[node name="Block2" parent="." unique_id=54235726 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(15.999999, -9.536743e-07)
|
||||||
|
|
||||||
|
[node name="Block3" parent="." unique_id=474997430 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(-15, 0)
|
||||||
|
|
||||||
|
[node name="Block4" parent="." unique_id=1125897933 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(32, -1.9073486e-06)
|
||||||
|
|
||||||
|
[node name="Block5" parent="." unique_id=1104682129 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(-31, 0)
|
||||||
|
|
||||||
|
[node name="Block6" parent="." unique_id=200247655 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(48, -1.9073486e-06)
|
||||||
|
|
||||||
|
[node name="Block7" parent="." unique_id=519163182 instance=ExtResource("1_noju1")]
|
||||||
|
position = Vector2(-47, 3.8146973e-06)
|
||||||
+23
-21
@@ -1,33 +1,35 @@
|
|||||||
[gd_scene format=3 uid="uid://iivvrut0lfsr"]
|
[gd_scene format=3 uid="uid://iivvrut0lfsr"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://blbaaqyrt8dtk" path="res://art/block/block.png" id="1_f3sb7"]
|
[ext_resource type="Script" uid="uid://boovn4st1uq41" path="res://rich_text_label.gd" id="1_036b0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ccxq1fh72bsdk" path="res://art/player.png" id="1_fj7yv"]
|
[ext_resource type="PackedScene" uid="uid://pmnwck5v0ntm" path="res://player_2d.tscn" id="1_aqk2v"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ckqable762x8v" path="res://block.tscn" id="2_036b0"]
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fj7yv"]
|
[ext_resource type="PackedScene" uid="uid://dx4pfup3sbk0f" path="res://long_block.tscn" id="3_dwbse"]
|
||||||
size = Vector2(32, 32)
|
[ext_resource type="PackedScene" uid="uid://bos6oh7nwyeca" path="res://vertical_long_block.tscn" id="4_pkg7o"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f3sb7"]
|
|
||||||
size = Vector2(32, 32)
|
|
||||||
|
|
||||||
[node name="World" type="Node2D" unique_id=1327991900]
|
[node name="World" type="Node2D" unique_id=1327991900]
|
||||||
|
process_mode = 3
|
||||||
|
|
||||||
[node name="Player2D" type="RigidBody2D" parent="." unique_id=1313639488]
|
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1982310971]
|
||||||
position = Vector2(272, 88)
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Player2D" unique_id=906437555]
|
[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer" unique_id=63102975]
|
||||||
texture = ExtResource("1_fj7yv")
|
offset_left = 5.0
|
||||||
|
offset_right = 130.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "FALL TIMER:"
|
||||||
|
script = ExtResource("1_036b0")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player2D" unique_id=1856010631]
|
[node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")]
|
||||||
shape = SubResource("RectangleShape2D_fj7yv")
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(55, 59)
|
||||||
|
|
||||||
[node name="Tutorial" type="Node2D" parent="." unique_id=1391494772]
|
[node name="Tutorial" type="Node2D" parent="." unique_id=1391494772]
|
||||||
|
|
||||||
[node name="Block" type="RigidBody2D" parent="Tutorial" unique_id=231931334]
|
[node name="Block" parent="Tutorial" unique_id=1409784601 instance=ExtResource("2_036b0")]
|
||||||
position = Vector2(276, 246)
|
position = Vector2(55, 118)
|
||||||
gravity_scale = 0.0
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tutorial/Block" unique_id=653491508]
|
[node name="LongBlock" parent="Tutorial" unique_id=658573725 instance=ExtResource("3_dwbse")]
|
||||||
shape = SubResource("RectangleShape2D_f3sb7")
|
position = Vector2(166, 200)
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Tutorial/Block" unique_id=2098924431]
|
[node name="VerticalLongBlock" parent="Tutorial" unique_id=925152188 instance=ExtResource("4_pkg7o")]
|
||||||
texture = ExtResource("1_f3sb7")
|
position = Vector2(250, 141)
|
||||||
Reference in new issue
Block a user