Skip to content

Commit

Permalink
removed gravity shield per #28, started light debugging for #30, and …
Browse files Browse the repository at this point in the history
…candy stats for #7
  • Loading branch information
dreammelter committed Oct 12, 2023
1 parent dfb5fa8 commit 1d830f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 19 additions & 0 deletions characters/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extends CharacterBody2D

## Emitted when the animated sprite flips its horizontal direction
signal direction_changed(direction: float)
## Emitted when a stat (Candy, Super Mode) is updated
signal stat_changed(stat_name: String, stat_value: float)

const SPEED := 200.0
const JUMP_VELOCITY := -400.0
Expand All @@ -16,15 +18,27 @@ var gravity: float = ProjectSettings.get_setting("physics/2d/default_gravity")

var _jump_count: int = 0

# A power bar sort of doubling as health
var _candy: float = 0.0

# Maxed candy bar?
var _is_super := false

@onready var animated_sprite = $AnimatedSprite as AnimatedSprite2D


func _ready():
pass


func _physics_process(delta: float) -> void:
# Add the gravity
if not is_on_floor():
# print("PLAYER is in air")
velocity.y += gravity * delta
# play falling animation
if animated_sprite.animation == "dbl_jump" and not animated_sprite.is_playing():
print("PLAYER is falling")
animated_sprite.play("fall")
else:
# reset jump count when we land on the ground
Expand All @@ -35,8 +49,10 @@ func _physics_process(delta: float) -> void:
velocity.y = JUMP_VELOCITY
_jump_count += 1
if _jump_count > 1:
print("PLAYER is double jumping!")
animated_sprite.play("dbl_jump")
else:
print("PLAYER is jumping!")
animated_sprite.play("jump")

# Get the input direction and handle the movement/deceleration.
Expand All @@ -60,3 +76,6 @@ func _change_anim_direction(direction: float) -> void:
animated_sprite.flip_h = true

emit_signal("direction_changed", direction)


## Adjust candy bar meter + activate super if it's maxed
6 changes: 1 addition & 5 deletions characters/player.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://ds84qxkphasfw"]
[gd_scene load_steps=5 format=3 uid="uid://ds84qxkphasfw"]

[ext_resource type="Script" path="res://characters/player.gd" id="1_tnduw"]
[ext_resource type="SpriteFrames" uid="uid://c43u1y0kp5uyw" path="res://resources/player_sprite_frames.tres" id="2_s2pa3"]
[ext_resource type="PackedScene" uid="uid://bwytxnuxk7tei" path="res://components/block_breaker/cannon_point.tscn" id="3_t1t3n"]
[ext_resource type="PackedScene" uid="uid://vrcabtyar02" path="res://components/block_breaker/gravity_shield.tscn" id="4_6wni1"]

[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_yvg7s"]
height = 32.0
Expand All @@ -24,6 +23,3 @@ metadata/_edit_lock_ = true

[node name="CannonPoint" parent="." instance=ExtResource("3_t1t3n")]
visible = false

[node name="GravityShield" parent="." instance=ExtResource("4_6wni1")]
gravity_space_override = 2

0 comments on commit 1d830f4

Please sign in to comment.