Compare commits

...

3 Commits

Author SHA1 Message Date
Ervan Lefevre 8152546bf2 Adds FMS script, implemented in a new player node 2 years ago
Ervan Lefevre 9b79c05a7b Adds a tileset 2 years ago
Ervan Lefevre b927efeb1a Main menu with 2 button (play & quit) 2 years ago
  1. BIN
      assets/tilesets/cave_tileset.png
  2. 34
      assets/tilesets/cave_tileset.png.import
  3. 65
      nodes/player/player.gd
  4. 27
      nodes/player/player.tscn
  5. BIN
      nodes/player/temp.png
  6. 34
      nodes/player/temp.png.import
  7. 8
      nodes/tileset/tileset.tscn
  8. 9
      project.godot
  9. 47
      scenes/main_menu.tscn
  10. 222
      scenes/poc.tscn
  11. 49
      scripts/ia/fsm.gd
  12. 8
      scripts/ui/change_scene_button.gd
  13. 5
      scripts/ui/quit_button.gd

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cfq8pma4bpgq"
path="res://.godot/imported/cave_tileset.png-1dd6f101c39817003a8319546b693c11.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/tilesets/cave_tileset.png"
dest_files=["res://.godot/imported/cave_tileset.png-1dd6f101c39817003a8319546b693c11.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

@ -0,0 +1,65 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
const STATES= [
"spawn",
"idle",
"walk",
"jump",
"die"
]
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _ready():
$fsm.set_states(STATES)
func _enter_spawn():
$fsm.set_next_state("idle")
func on_enter_idle_state():
velocity.x = 0.0
func idle_state(_delta):
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
$fsm.set_next_state("walk")
elif Input.is_action_just_pressed("ui_accept") and is_on_floor():
$fsm.set_next_state("jump")
func walk_state(_delta):
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
$fsm.set_next_state("idle")
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
$fsm.set_next_state("jump")
func on_enter_jump_state():
velocity.y = JUMP_VELOCITY
func jump_state(_delta):
var direction = Input.get_axis("ui_left", "ui_right")
velocity.x = move_toward(velocity.x, direction * SPEED, SPEED)
if is_on_floor():
if direction:
$fsm.set_next_state("walk")
else:
$fsm.set_next_state("idle")
func after_state(delta):
if $fsm.current_state in ["idle", "walk"]:
move_and_slide()
if not is_on_floor():
velocity.y += gravity * delta

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=3 uid="uid://c5rmt3jeffjx7"]
[ext_resource type="Script" path="res://nodes/player/player.gd" id="1_exx2i"]
[ext_resource type="Texture2D" uid="uid://cm4rn4vgyjd1b" path="res://nodes/player/temp.png" id="1_s33dc"]
[ext_resource type="Script" path="res://scripts/ia/fsm.gd" id="2_ix1o4"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w17ly"]
radius = 7.9984
height = 31.9936
[node name="player" type="CharacterBody2D"]
script = ExtResource("1_exx2i")
[node name="fsm" type="Node2D" parent="." node_paths=PackedStringArray("root")]
script = ExtResource("2_ix1o4")
root = NodePath("..")
[node name="sprite" type="Sprite2D" parent="."]
texture = ExtResource("1_s33dc")
[node name="shape" type="CollisionShape2D" parent="."]
rotation = 1.55081
shape = SubResource("CapsuleShape2D_w17ly")
metadata/_edit_group_ = true
[node name="camera" type="Camera2D" parent="."]
zoom = Vector2(2, 2)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cm4rn4vgyjd1b"
path="res://.godot/imported/temp.png-1af0064fad142262002520a17592c851.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://nodes/player/temp.png"
dest_files=["res://.godot/imported/temp.png-1af0064fad142262002520a17592c851.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

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://bp0gocsewqr1t"]
[ext_resource type="Texture2D" uid="uid://cfq8pma4bpgq" path="res://assets/tilesets/cave_tileset.png" id="1_1w2wu"]
[node name="tileset" type="Node2D"]
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_1w2wu")

@ -11,9 +11,18 @@ config_version=5
[application]
config/name="LD54"
run/main_scene="res://scenes/main_menu.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/icon="res://icon.svg"
[display]
window/size/viewport_width=1920
window/size/viewport_height=1080
window/size/mode=2
window/size/initial_screen=1
window/stretch/mode="viewport"
[rendering]
renderer/rendering_method="gl_compatibility"

@ -0,0 +1,47 @@
[gd_scene load_steps=3 format=3 uid="uid://xjo01yx3nybo"]
[ext_resource type="Script" path="res://scripts/ui/change_scene_button.gd" id="1_2rx5y"]
[ext_resource type="Script" path="res://scripts/ui/quit_button.gd" id="2_fjtya"]
[node name="root" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="panel" type="Panel" parent="."]
layout_mode = 0
offset_right = 1928.0
offset_bottom = 1088.0
[node name="titre" type="Label" parent="panel"]
layout_mode = 2
offset_left = 1.0
offset_top = 2.0
offset_right = 961.0
offset_bottom = 107.0
scale = Vector2(2, 2)
text = "Ant Underwater Odyssey"
horizontal_alignment = 1
vertical_alignment = 1
[node name="play" type="Button" parent="."]
layout_mode = 0
offset_left = 624.0
offset_top = 776.0
offset_right = 1279.0
offset_bottom = 853.0
text = "Play"
script = ExtResource("1_2rx5y")
TARGET_SCENE = "res://scenes/main_menu.tscn"
[node name="quit" type="Button" parent="."]
layout_mode = 0
offset_left = 629.0
offset_top = 875.0
offset_right = 1284.0
offset_bottom = 952.0
text = "Quit"
script = ExtResource("2_fjtya")

File diff suppressed because one or more lines are too long

@ -0,0 +1,49 @@
extends Node2D
class_name FSM
@export var root : Node
var states = ['idle']
var current_state = null
var previous_state = null
var next_state = null
func set_states(new_states):
self.states = new_states
func _ready():
if current_state == null:
next_state = states[0]
_transition()
func _physics_process(delta):
if "before_state" in root:
root.call("before_state", delta)
var current_state_method = current_state + "_state"
if current_state_method in root:
root.call(current_state_method, delta)
if "after_state" in root:
root.call("after_state", delta)
_transition()
func _transition():
if next_state != null:
previous_state = current_state
current_state = next_state
next_state = null
var on_exit_state_method = "on_exit_" + current_state + "_state"
if on_exit_state_method in root:
root.call(on_exit_state_method)
var on_enter_state_method = "on_enter_" + current_state + "_state"
if on_enter_state_method in root:
root.call(on_enter_state_method)
func set_next_state(state):
next_state = state

@ -0,0 +1,8 @@
extends Button
class_name SceneChanger
@export_file("*.tscn") var TARGET_SCENE;
func _pressed():
print("Changing scene to: " + TARGET_SCENE)
get_tree().change_scene(TARGET_SCENE)

@ -0,0 +1,5 @@
extends Button
class_name QuitButton
func _pressed():
get_tree().quit()
Loading…
Cancel
Save