From 7a567d6796b1491d97af172e5b960e1071e24c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Mon, 10 Jun 2024 08:59:14 -0700 Subject: [PATCH] Started tracking progress with git. --- .gitattributes | 2 + .gitignore | 3 + icon.svg | 1 + icon.svg.import | 37 ++++++ project.godot | 16 +++ scenes/Axolotl.tscn | 237 +++++++++++++++++++++++++++++++++++ scenes/Camera.tscn | 8 ++ scenes/Dojo.tscn | 19 +++ scenes/generic_obstacle.tscn | 15 +++ scripts/Axolotl.gd | 85 +++++++++++++ sprites/Axolotl.png | Bin 0 -> 1892 bytes sprites/Axolotl.png.import | 34 +++++ 12 files changed, 457 insertions(+) create mode 100755 .gitattributes create mode 100755 icon.svg create mode 100755 icon.svg.import create mode 100755 project.godot create mode 100755 scenes/Axolotl.tscn create mode 100755 scenes/Camera.tscn create mode 100755 scenes/Dojo.tscn create mode 100755 scenes/generic_obstacle.tscn create mode 100755 scripts/Axolotl.gd create mode 100755 sprites/Axolotl.png create mode 100755 sprites/Axolotl.png.import diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 822b784..1fd7b60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Godot 4+ specific ignores +.godot/ + # ---> Godot # Godot-specific ignores .import/ diff --git a/icon.svg b/icon.svg new file mode 100755 index 0000000..b370ceb --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100755 index 0000000..2745780 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8sq1ket4sycd" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100755 index 0000000..6738be3 --- /dev/null +++ b/project.godot @@ -0,0 +1,16 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Axolotl" +run/main_scene="res://scenes/Dojo.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" diff --git a/scenes/Axolotl.tscn b/scenes/Axolotl.tscn new file mode 100755 index 0000000..67794d4 --- /dev/null +++ b/scenes/Axolotl.tscn @@ -0,0 +1,237 @@ +[gd_scene load_steps=13 format=3 uid="uid://d4nb1twqrmebx"] + +[ext_resource type="Texture2D" uid="uid://dfh0dpo7iq3eb" path="res://sprites/Axolotl.png" id="1_tbw8a"] +[ext_resource type="Script" path="res://scripts/Axolotl.gd" id="1_uo3dg"] +[ext_resource type="PackedScene" uid="uid://cf24ht1sv1yih" path="res://scenes/Camera.tscn" id="2_fge4g"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_np4lk"] +radius = 6.0 +height = 24.0 + +[sub_resource type="Animation" id="Animation_m4cwp"] +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] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame_coords") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(0, 3)] +} + +[sub_resource type="Animation" id="Animation_hwv1x"] +resource_name = "idle" +length = 0.6 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame_coords") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5] +} + +[sub_resource type="Animation" id="Animation_oelbc"] +resource_name = "munch" +length = 0.6 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame_coords") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(1, 4)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 1, +"values": [24, 25, 26, 27, 28, 29] +} + +[sub_resource type="Animation" id="Animation_7s1x2"] +resource_name = "sprint" +length = 0.5 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame_coords") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(1, 2)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 1, +"values": [12, 13, 14, 15, 16] +} + +[sub_resource type="Animation" id="Animation_rht3k"] +resource_name = "swim" +length = 0.7 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame_coords") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(0, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 1, +"values": [6, 7, 8, 9, 10, 11] +} + +[sub_resource type="Animation" id="Animation_k4uu0"] +resource_name = "turn" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame_coords") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [Vector2i(0, 3)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:frame") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 1, +"values": [18, 19, 20, 21, 22] +} +tracks/2/type = "method" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.4), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"end_turn" +}] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_sojmd"] +_data = { +"RESET": SubResource("Animation_m4cwp"), +"idle": SubResource("Animation_hwv1x"), +"munch": SubResource("Animation_oelbc"), +"sprint": SubResource("Animation_7s1x2"), +"swim": SubResource("Animation_rht3k"), +"turn": SubResource("Animation_k4uu0") +} + +[sub_resource type="AnimationRootNode" id="AnimationRootNode_7r5ga"] + +[node name="Axolotl" type="Node2D"] + +[node name="CharacterBody2D" type="CharacterBody2D" parent="."] +script = ExtResource("1_uo3dg") + +[node name="Camera2D" parent="CharacterBody2D" instance=ExtResource("2_fge4g")] + +[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"] +texture_filter = 1 +texture = ExtResource("1_tbw8a") +hframes = 6 +vframes = 5 +frame = 18 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"] +visible = false +rotation = 1.5708 +shape = SubResource("CapsuleShape2D_np4lk") + +[node name="AnimationTree" type="AnimationTree" parent="CharacterBody2D"] +libraries = { +"": SubResource("AnimationLibrary_sojmd") +} +tree_root = SubResource("AnimationRootNode_7r5ga") +anim_player = NodePath("../AnimationPlayer") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="CharacterBody2D"] +libraries = { +"": SubResource("AnimationLibrary_sojmd") +} diff --git a/scenes/Camera.tscn b/scenes/Camera.tscn new file mode 100755 index 0000000..ba24731 --- /dev/null +++ b/scenes/Camera.tscn @@ -0,0 +1,8 @@ +[gd_scene format=3 uid="uid://cf24ht1sv1yih"] + +[node name="Camera2D" type="Camera2D"] +zoom = Vector2(3, 3) +limit_smoothed = true +position_smoothing_enabled = true +editor_draw_limits = true +editor_draw_drag_margin = true diff --git a/scenes/Dojo.tscn b/scenes/Dojo.tscn new file mode 100755 index 0000000..a23040b --- /dev/null +++ b/scenes/Dojo.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://c8s3or2hskj0i"] + +[ext_resource type="PackedScene" uid="uid://d4nb1twqrmebx" path="res://scenes/Axolotl.tscn" id="1_eysle"] +[ext_resource type="PackedScene" uid="uid://pptrf5oq4k1x" path="res://scenes/generic_obstacle.tscn" id="2_q2aw5"] + +[node name="Dojo" type="Node2D"] + +[node name="Axolotl" parent="." instance=ExtResource("1_eysle")] + +[node name="GenericObstacle" parent="." instance=ExtResource("2_q2aw5")] + +[node name="GenericObstacle4" parent="." instance=ExtResource("2_q2aw5")] +position = Vector2(508, 364) + +[node name="GenericObstacle3" parent="." instance=ExtResource("2_q2aw5")] +position = Vector2(631, 128) + +[node name="GenericObstacle2" parent="." instance=ExtResource("2_q2aw5")] +position = Vector2(245, 226) diff --git a/scenes/generic_obstacle.tscn b/scenes/generic_obstacle.tscn new file mode 100755 index 0000000..9da86b4 --- /dev/null +++ b/scenes/generic_obstacle.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://pptrf5oq4k1x"] + +[ext_resource type="Texture2D" uid="uid://b8sq1ket4sycd" path="res://icon.svg" id="1_dpci1"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_6u7yk"] +size = Vector2(124, 122) + +[node name="GenericObstacle" type="Sprite2D"] +position = Vector2(866, 474) +texture = ExtResource("1_dpci1") + +[node name="StaticBody2D" type="StaticBody2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +shape = SubResource("RectangleShape2D_6u7yk") diff --git a/scripts/Axolotl.gd b/scripts/Axolotl.gd new file mode 100755 index 0000000..a84948f --- /dev/null +++ b/scripts/Axolotl.gd @@ -0,0 +1,85 @@ +extends CharacterBody2D + + +const SPEED = 150.0 +const SPRINT_MAX = 2 + +# Get the gravity from the project settings to be synced with RigidBody nodes. +#var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") + +var sprint = 1 +var gravity = 0 +var turning = false +var anim +var sprite +var direction = Vector2.ZERO + +func _ready(): + anim = $AnimationPlayer + sprite = $Sprite2D + + +func end_turn(): + sprite.flip_h = !sprite.flip_h + turning = false + anim.speed_scale = 1 + print( "turned" ) + + + + +func turn(): + #turning = true + anim.speed_scale = 1 + anim.play("turn") + + +func _physics_process(delta): + + # Add the gravity. + if gravity !=0 and not is_on_floor(): + velocity.y += gravity * delta + + # Handle sprint. + if Input.is_action_just_pressed("ui_accept"): + sprint = SPRINT_MAX + else: + sprint = move_toward( sprint, 1 , 0.01 ) + # Get the input direction and handle the movement/deceleration. + # As good practice, you should replace UI actions with custom gameplay actions. + direction = Vector2 (Input.get_axis("ui_left", "ui_right"),Input.get_axis("ui_up", "ui_down")/2).normalized() + + + if (Input.is_action_just_pressed("ui_right") and sprite.flip_h) or (Input.is_action_just_pressed("ui_left") and !sprite.flip_h): + turn() + pass + + + if direction != Vector2.ZERO and !turning: + if ( direction.x < 0 and sprite.flip_h ) or ( direction.x > 0 and !sprite.flip_h ): + sprite.rotation = 0; + velocity.x = direction.x * SPEED * sprint + + if sprint > 1: + anim.speed_scale = sprint + anim.play("sprint") + else: + anim.speed_scale = 1 + anim.play("swim") + velocity.y = direction.y * SPEED + + if !sprite.flip_h: + sprite.rotation = move_toward(direction.angle(),0, .1) + else: + sprite.rotation = move_toward(direction.angle() - PI,0, -.1) + + else: + velocity.x = move_toward(velocity.x, 0, SPEED) + velocity.y = move_toward(velocity.y, 0, SPEED) + anim.speed_scale = .5 + sprite.rotation = move_toward(sprite.rotation,0, .1) + + $AnimationPlayer.play("idle") + + move_and_slide() + diff --git a/sprites/Axolotl.png b/sprites/Axolotl.png new file mode 100755 index 0000000000000000000000000000000000000000..02ecf8437e2ffdf830b4f5d1fae859a483ec0ea8 GIT binary patch literal 1892 zcmV-q2b=hbP)uKP1YfuXaE&kzqs#p501Cgc-oKO&?;ZeV=kl*@ z{IE6nB|p}F&K+zZ3s8BmI3RVvr{D7~?r;hA5BK<$%cP*-NxtArtu=69e(Q|R04RdY zw=ZiNv0?ayuaTbP>&%tKhdZPND7vC!BItY(z|k$U@-Nvy=F7(I?Z^PBQCxx=uM42N zUF7+d9sR`w)d{#FKvtme8k7W8{H4A6sx&iQUXA4ikl>jRJIF)%eB9?g_FYxY{{&;I0nqHgXMs{rCD< zz_hq2|9)72w13~pz{T$@7oXK0#?Y(8;lGC&fA?6S{}24vjmPG6=L5sy`hbwaxO00* zT>bYvDbRkOe3*?$9&>pj!fest`aBW+y3K5r(Hw z@0u^WfMQ$aplifz?DYlu*8F~1Ok{ateoBzP0(*~q6yskoze`We+`nZ0OAwx~cnxmf z#D8G`gTY`h7z_r3!C)|a5Ko%JS~qmB+zVs>t~JG<>ZER=%V)B9rQxohAB1nqE;s7M zYIKtQ)(->mlecu(&!XuX*z`6!SLny`ag=lJptw9^S_VZ zS%D0;V+CFe^{>m_X_ML<@6+e*dfnX7>JS$acs56IZ1v`H?I+8Eb$7I)twG@W@N zff8RhqiY;M#0V76A5vd%(49$oi%f&{)c+&I=azVk&lOnY_aEplC|CrFbo4*s5%(b` zB7x1pzw`ozNrCa9!d^6Kpv_fqm;FYe_*r2Zdz9cK8ecqLNPGW4*aD!rE#(bi>0tcc zE--vTZ+Ot&j{qVgZ!L}hw0%6E!eDryJb#H+foOanP}A2Szki_jqiB@}@e{dF!uS{Y z%8~ZE>&`q&>%5YoI=;+n_WBr~bB`5%#AgJk_P+Xl1lhK}|K!4m&t<6C=67xNcgHsv e3