diff --git a/assets/textures/spring/spring.png b/assets/textures/spring/spring.png new file mode 100644 index 0000000..72b2612 Binary files /dev/null and b/assets/textures/spring/spring.png differ diff --git a/assets/textures/spring/spring.png.import b/assets/textures/spring/spring.png.import new file mode 100644 index 0000000..21b40de --- /dev/null +++ b/assets/textures/spring/spring.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bobpl8pwm216q" +path="res://.godot/imported/spring.png-cae14fb9765a887d13337bda8e0038e7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/spring/spring.png" +dest_files=["res://.godot/imported/spring.png-cae14fb9765a887d13337bda8e0038e7.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 diff --git a/maps/level1.tscn b/maps/level1.tscn index a2d9168..bc631eb 100644 --- a/maps/level1.tscn +++ b/maps/level1.tscn @@ -1,3 +1,24 @@ -[gd_scene format=3 uid="uid://bbnq7ptk8hhxa"] +[gd_scene load_steps=5 format=3 uid="uid://bbnq7ptk8hhxa"] + +[ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_gk4ur"] +[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="2_kip56"] +[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="3_4td23"] +[ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="4_a3xei"] [node name="Level1" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +modulate = Color(1, 0, 1, 1) +position = Vector2(144, 108) +texture = ExtResource("1_gk4ur") + +[node name="Player" parent="." instance=ExtResource("2_kip56")] +position = Vector2(31, 139) + +[node name="TileMap" type="TileMap" parent="."] +tile_set = ExtResource("3_4td23") +format = 2 +layer_0/tile_data = PackedInt32Array(720896, 0, 0, 720897, 0, 0, 720898, 0, 0, 720899, 0, 0, 720900, 0, 0, 720901, 0, 0, 720902, 0, 0, 720903, 0, 0, 720904, 0, 0, 720905, 0, 0, 720906, 0, 0, 720907, 0, 0, 720908, 0, 0, 720909, 0, 0, 720910, 0, 0, 720911, 0, 0, 720912, 0, 0, 720913, 0, 0) + +[node name="Spring" parent="." instance=ExtResource("4_a3xei")] +position = Vector2(144, 176) diff --git a/objects/spring/spring.gd b/objects/spring/spring.gd new file mode 100644 index 0000000..8be72a7 --- /dev/null +++ b/objects/spring/spring.gd @@ -0,0 +1,18 @@ +extends Node2D + +@export var bounce_power = 240.0 + +# 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: + pass + + +func _on_area_2d_body_entered(body: Node2D) -> void: + if body is Player: + body.velocity.y = -bounce_power + %AnimationPlayer.play("bounce") diff --git a/objects/spring/spring.tscn b/objects/spring/spring.tscn new file mode 100644 index 0000000..5b26ab0 --- /dev/null +++ b/objects/spring/spring.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=7 format=3 uid="uid://68lav5rke5ag"] + +[ext_resource type="Script" path="res://objects/spring/spring.gd" id="1_05bif"] +[ext_resource type="Texture2D" uid="uid://bobpl8pwm216q" path="res://assets/textures/spring/spring.png" id="1_s1olr"] + +[sub_resource type="Animation" id="Animation_8kq4q"] +resource_name = "bounce" +length = 0.3 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame") +tracks/0/interp = 0 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.0666667, 0.1, 0.133333, 0.166667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 1, +"values": [1, 2, 3, 2, 0] +} + +[sub_resource type="Animation" id="Animation_pa4d8"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_2p5yk"] +_data = { +"RESET": SubResource("Animation_pa4d8"), +"bounce": SubResource("Animation_8kq4q") +} + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_c7407"] +size = Vector2(16, 11) + +[node name="Spring" type="Node2D"] +script = ExtResource("1_05bif") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(0, -8) +texture = ExtResource("1_s1olr") +hframes = 4 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_2p5yk") +} + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2(0, -5.5) +shape = SubResource("RectangleShape2D_c7407") + +[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] +[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/project.godot b/project.godot index a8aa7dd..13f685c 100644 --- a/project.godot +++ b/project.godot @@ -40,3 +40,4 @@ folder_colors={ textures/canvas_textures/default_texture_filter=0 renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +2d/snap/snap_2d_transforms_to_pixel=true