diff --git a/graphics/objects/mushroom_32x64.png b/graphics/objects/mushroom_32x64.png index 957e816..81212df 100644 Binary files a/graphics/objects/mushroom_32x64.png and b/graphics/objects/mushroom_32x64.png differ diff --git a/graphics/objects/veg_32x32.png b/graphics/objects/veg_32x32.png index 4e09fa9..5bbf314 100644 Binary files a/graphics/objects/veg_32x32.png and b/graphics/objects/veg_32x32.png differ diff --git a/project.godot b/project.godot index 8bf18b8..82cb4ab 100644 --- a/project.godot +++ b/project.godot @@ -22,10 +22,10 @@ GameController="*res://scripts/game_controller.gd" [display] -window/size/viewport_width=320 -window/size/viewport_height=180 -window/size/window_width_override=640 -window/size/window_height_override=360 +window/size/viewport_width=480 +window/size/viewport_height=270 +window/size/window_width_override=1280 +window/size/window_height_override=720 window/stretch/mode="viewport" [file_customization] diff --git a/scenes/game.tscn b/scenes/level_1.tscn similarity index 100% rename from scenes/game.tscn rename to scenes/level_1.tscn diff --git a/scenes/player.tscn b/scenes/player.tscn index 6e9716e..3c2f63a 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=58 format=3 uid="uid://d3y1iqmpknpyo"] +[gd_scene load_steps=56 format=3 uid="uid://d3y1iqmpknpyo"] [ext_resource type="Script" uid="uid://d3hp5rjoph7hg" path="res://scripts/player.gd" id="1_3vyb7"] [ext_resource type="Texture2D" uid="uid://dr3rp5hv7rexv" path="res://graphics/animations/player_idle/Player Idle 48x48.png" id="2_g2els"] @@ -132,10 +132,6 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("4_qlg0r") region = Rect2(336, 0, 48, 48) -[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"] -atlas = ExtResource("5_tuyoq") -region = Rect2(0, 0, 48, 48) - [sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"] atlas = ExtResource("5_tuyoq") region = Rect2(48, 0, 48, 48) @@ -164,6 +160,10 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("5_tuyoq") region = Rect2(336, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"] +atlas = ExtResource("5_tuyoq") +region = Rect2(0, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"] atlas = ExtResource("6_fjrip") region = Rect2(0, 0, 48, 48) @@ -196,14 +196,6 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("6_fjrip") region = Rect2(336, 0, 48, 48) -[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"] -atlas = ExtResource("6_fjrip") -region = Rect2(384, 0, 48, 48) - -[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"] -atlas = ExtResource("6_fjrip") -region = Rect2(432, 0, 48, 48) - [sub_resource type="SpriteFrames" id="SpriteFrames_3vyb7"] animations = [{ "frames": [{ @@ -323,9 +315,6 @@ animations = [{ }, { "frames": [{ "duration": 1.0, -"texture": SubResource("AtlasTexture_f1ej7") -}, { -"duration": 1.0, "texture": SubResource("AtlasTexture_l71n6") }, { "duration": 1.0, @@ -345,6 +334,9 @@ animations = [{ }, { "duration": 1.0, "texture": SubResource("AtlasTexture_wqfne") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_f1ej7") }], "loop": false, "name": &"shoot_run", @@ -374,12 +366,6 @@ animations = [{ }, { "duration": 1.0, "texture": SubResource("AtlasTexture_t4otl") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_j2b1d") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_cs1tg") }], "loop": false, "name": &"shoot_still", @@ -411,13 +397,12 @@ position = Vector2(-16, -7) [node name="PlayerSprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_3vyb7") -animation = &"punch" +animation = &"shoot_still" autoplay = "idle" -frame = 9 -frame_progress = 1.0 [node name="Camera2D" type="Camera2D" parent="."] offset = Vector2(0, -50) +position_smoothing_enabled = true [node name="DebugInfo" type="CanvasLayer" parent="."] diff --git a/scripts/game_controller.gd b/scripts/game_controller.gd index 7e347c0..f08d3c3 100644 --- a/scripts/game_controller.gd +++ b/scripts/game_controller.gd @@ -2,7 +2,7 @@ extends Node2D var coins_collected : int = 0 var total_coins : int = 0 -var levels = ["res://scenes/game.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"] +var levels = ["res://scenes/level_1.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"] var timers = [10, 15, 20] var time_available : int = 0 var current_level = 0 diff --git a/scripts/player.gd b/scripts/player.gd index 7814c64..6a0037e 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -18,17 +18,17 @@ enum State { PUNCH } -const JUMP_VELOCITY = -500.0 -const SPEED = 200.0 +const JUMP_VELOCITY := -500.0 ## Power applied for jumping +const SPEED := 200.0 ## (Max) movement speed @export var BUMP_POWER := 50 ## Power from bumping into objects @export var PUNCH_POWER := 300 ## Power from shoving objects @export var ACCELERATION := 10 ## Amount of "slide-y-ness" in side-to-side-movement @export var HARD_GRAVITY := 2 ## Factor applied during FALL state -var current_state: State = State.IDLE -var facing : FaceDirection = FaceDirection.RIGHT -var direction : float = 0.0 +var current_state: State = State.IDLE ## Player state for FSM +var facing : FaceDirection = FaceDirection.RIGHT ## Facing direction for animation orientation +var direction : float = 0.0 var punch_target : RigidBody2D var punch_enabled : bool = false var jump_buffer_timer : Timer @@ -42,6 +42,7 @@ var shoot_cooldown_timer : Timer func _ready() -> void: jump_buffer_timer = Timer.new() + jump_buffer_timer.one_shot = true add_child(jump_buffer_timer) shoot_cooldown_timer = Timer.new() shoot_cooldown_timer.one_shot = true @@ -95,28 +96,22 @@ func handle_input() -> void: current_state = State.SHOOT_RUN else: current_state = State.SHOOT_STILL - print("pew-pew") match facing: FaceDirection.RIGHT: %SceneManager.make_bullet(right_spawn.global_transform, 700) - print("shoot right") FaceDirection.LEFT: %SceneManager.make_bullet(left_spawn.global_transform, -700) - print("shoot left") shoot_cooldown_timer.start(0.2) else: print("can't shoot right now because there are %s seconds left in the cooldown timer" % shoot_cooldown_timer.time_left) # Handle throwing grenades if Input.is_action_just_pressed("throw"): - print("grenade!") match facing: FaceDirection.RIGHT: %SceneManager.make_grenade(right_spawn.global_transform, 1.0) - print("throwing right") FaceDirection.LEFT: %SceneManager.make_grenade(left_spawn.global_transform, -1.0) - print("throwing left") func handle_movement(delta) -> void: # Left-right movement. Use acceleration for smoothing