- adding coins

- performance improvements
- shake effect
- keyboard support
This commit is contained in:
megamichi 2024-11-04 19:10:10 +01:00
parent 78b4a3bba2
commit 45193fc27f
48 changed files with 609 additions and 74 deletions

View file

@ -0,0 +1,23 @@
extends Marker2D
var speed
func _ready() -> void:
speed = $"/root/Global".speed #get_parent().speed
func _spawn() -> void:
var hindernis = preload("res://scenes/hurdle/hurdle.tscn").instantiate()
speed = $"/root/Global".speed
hindernis.speed = speed
var v1 = 1.5 - (speed / 260)
var v2 = 2.0 - (speed / 260)
#print(str(v1)," ",str(v2))
$"../SpawnTimer".wait_time = randf_range(v1,v2)
add_child(hindernis)
func del_all():
for child in get_children():
child.queue_free()

19
scenes/hurdle/hurdle.gd Normal file
View file

@ -0,0 +1,19 @@
extends CharacterBody2D
@onready var speed = 0
func _ready() -> void:
$"Sprite".frame_coords.x = randi_range(0,4)
if $"/root/Global".active_biom == "w":
$"Sprite".frame_coords.y = 1
elif $"/root/Global".active_biom == "s":
$"Sprite".frame_coords.y = 2
else:
$"Sprite".frame_coords.y = 0
func _process(delta: float) -> void:
speed = $"/root/Global".speed
global_position.x -= speed*delta
if global_position.x < -30:
queue_free()

BIN
scenes/hurdle/hurdle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bp48x77dixrme"
path="res://.godot/imported/hurdle.png-68dde4d9f095a6d006bd2c90c4279ac6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://scenes/hurdle/hurdle.png"
dest_files=["res://.godot/imported/hurdle.png-68dde4d9f095a6d006bd2c90c4279ac6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

39
scenes/hurdle/hurdle.tscn Normal file
View file

@ -0,0 +1,39 @@
[gd_scene load_steps=5 format=3 uid="uid://cp43g3amm8a6f"]
[ext_resource type="Script" path="res://scenes/hurdle/hurdle.gd" id="1_e0hqe"]
[ext_resource type="Texture2D" uid="uid://bp48x77dixrme" path="res://scenes/hurdle/hurdle.png" id="2_thg8w"]
[sub_resource type="CircleShape2D" id="CircleShape2D_orpyb"]
radius = 5.0
[sub_resource type="CircleShape2D" id="CircleShape2D_r1tmj"]
radius = 5.0
[node name="hurdle" type="CharacterBody2D"]
collision_layer = 3
collision_mask = 3
script = ExtResource("1_e0hqe")
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -8)
texture = ExtResource("2_thg8w")
offset = Vector2(0, 0.5)
hframes = 5
vframes = 3
frame = 14
region_enabled = true
region_rect = Rect2(0, 0, 80, 48)
[node name="collision" type="CollisionShape2D" parent="."]
position = Vector2(0, -7)
shape = SubResource("CircleShape2D_orpyb")
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(0, -7)
collision_layer = 3
collision_mask = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_r1tmj")
debug_color = Color(0.906661, 0.254677, 0.42413, 0.42)