Skip to content

Commit

Permalink
modified for basic testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneeIbeji committed May 29, 2024
1 parent 3186095 commit 57c773d
Show file tree
Hide file tree
Showing 20 changed files with 266 additions and 5 deletions.
Binary file added Assets/Art/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Assets/Art/minus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cy6oy1bruk12e"
path="res://.godot/imported/minus.png-5b934ef2dd2ce7bbd9bede3d39f75148.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Assets/Art/minus.png"
dest_files=["res://.godot/imported/minus.png-5b934ef2dd2ce7bbd9bede3d39f75148.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
Binary file added Assets/Art/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Assets/Art/plus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://be3omv1f48wvf"
path="res://.godot/imported/plus.png-619c97f9cfae2c390e6f66fd16af065c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Assets/Art/plus.png"
dest_files=["res://.godot/imported/plus.png-619c97f9cfae2c390e6f66fd16af065c.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
8 changes: 7 additions & 1 deletion Scenes/!Main/GameOverlay.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ func _ready():

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
var currentPotion : int = GameVariables.PlayerNode.PotionThrowerSystem.currentPotion
if currentPotion == 0:
$PotionLabel.text = "Next Potion: Heal"
else:
$PotionLabel.text = "Next Potion: Hurt"

$ScoreLabel.text = "Score: " + str(GameVariables.score)

func connectUIToGame() -> void:
GameVariables.PlayerNode.HealthSystem.HealthChanged.connect(updatePlayerHealth)
Expand Down
18 changes: 18 additions & 0 deletions Scenes/!Main/GameOverlay.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ offset_bottom = 205.0
theme_override_font_sizes/normal_font_size = 50
text = "Health"

[node name="PotionLabel" type="RichTextLabel" parent="."]
layout_mode = 0
offset_left = 300.0
offset_top = 108.0
offset_right = 759.0
offset_bottom = 251.0
theme_override_font_sizes/normal_font_size = 50
text = "Next potion: Heal"

[node name="ScoreLabel" type="RichTextLabel" parent="."]
layout_mode = 0
offset_left = 1295.0
offset_top = 57.0
offset_right = 1754.0
offset_bottom = 200.0
theme_override_font_sizes/normal_font_size = 90
text = "Score: 40"

[node name="HealthLabel" type="RichTextLabel" parent="."]
layout_mode = 0
offset_left = 56.0
Expand Down
2 changes: 2 additions & 0 deletions Scenes/!Main/World.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func LoadLevel(levelData : LevelData) -> void:
currentLevel = levelData
for child in get_children():
child.queue_free()
GameVariables.score = 0

var newPlayerScene : Player = playerScene.instantiate() as Player
newPlayerScene.position = levelData.startPoint
Expand All @@ -38,6 +39,7 @@ func LoadLevel(levelData : LevelData) -> void:
func ReloadLevel() -> void:
for child in get_children():
child.queue_free()
GameVariables.score = 0

var newPlayerScene : Player = playerScene.instantiate() as Player
newPlayerScene.position = currentLevel.startPoint
Expand Down
16 changes: 16 additions & 0 deletions Scenes/Effects/effect.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Node2D

@export var floatspeed : float
@export_range(0, 10, 1, "or_greater", "or_less") var appeartime : float

# Called when the node enters the scene tree for the first time.
func _ready():
get_tree().create_timer(appeartime).timeout.connect(endEffect)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
position.y -= floatspeed * delta

func endEffect():
queue_free()
14 changes: 14 additions & 0 deletions Scenes/Effects/healEffect.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://befhsuoc3yl7n"]

[ext_resource type="Script" path="res://Scenes/Effects/effect.gd" id="1_7rrqt"]
[ext_resource type="Texture2D" uid="uid://be3omv1f48wvf" path="res://Assets/Art/plus.png" id="2_hd0ar"]

[node name="heal effect" type="Node2D"]
script = ExtResource("1_7rrqt")
floatspeed = 100.0
appeartime = 1.0

[node name="Sprite2D" type="Sprite2D" parent="."]
z_index = 6
scale = Vector2(4, 4)
texture = ExtResource("2_hd0ar")
14 changes: 14 additions & 0 deletions Scenes/Effects/hurtEffect.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://cvfx11oksqwwa"]

[ext_resource type="Texture2D" uid="uid://cy6oy1bruk12e" path="res://Assets/Art/minus.png" id="1_g30kn"]
[ext_resource type="Script" path="res://Scenes/Effects/effect.gd" id="1_j5hlh"]

[node name="hurt effect" type="Node2D"]
script = ExtResource("1_j5hlh")
floatspeed = 100.0
appeartime = 1.0

[node name="Sprite2D" type="Sprite2D" parent="."]
z_index = 6
scale = Vector2(4, 4)
texture = ExtResource("1_g30kn")
6 changes: 6 additions & 0 deletions Scenes/Entities/Player/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ func _physics_process(delta : float) -> void:
MovementSystem.carryOutMovement(delta)


func entityHeal() -> void:
pass

func entityHurt() -> void:
pass

func playerDead() -> void:
Global.PlayerDied()

29 changes: 29 additions & 0 deletions Scenes/Entities/Player/Potions/testHealPotion.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[gd_scene load_steps=6 format=3 uid="uid://bgvujvuvf1w17"]

[ext_resource type="Script" path="res://Scenes/Entities/Player/Potions/testPotion.gd" id="1_t7wa0"]
[ext_resource type="PackedScene" uid="uid://qeqitvy8ovcn" path="res://Scenes/Entities/Player/Potions/testHealSplash.tscn" id="2_gsdik"]
[ext_resource type="Texture2D" uid="uid://b2d8chun5wo47" path="res://icon.png" id="3_ow4n1"]
[ext_resource type="Script" path="res://Scenes/Entities/Player/Potions/PotionSprite.gd" id="4_137vr"]

[sub_resource type="SpriteFrames" id="SpriteFrames_ifxp8"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_ow4n1")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[node name="TestHealPotion" type="Node2D"]
z_index = 3
script = ExtResource("1_t7wa0")
splashScene = ExtResource("2_gsdik")

[node name="PotionSprite" type="AnimatedSprite2D" parent="."]
modulate = Color(0.235294, 0.572549, 0.45098, 1)
position = Vector2(1, -1)
scale = Vector2(0.773438, 0.773438)
sprite_frames = SubResource("SpriteFrames_ifxp8")
script = ExtResource("4_137vr")
44 changes: 44 additions & 0 deletions Scenes/Entities/Player/Potions/testHealSplash.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[gd_scene load_steps=7 format=3 uid="uid://qeqitvy8ovcn"]

[ext_resource type="Script" path="res://Scenes/Entities/Player/Potions/testSplash.gd" id="1_xkjtr"]
[ext_resource type="Script" path="res://Scenes/Entity systems/Health system/AttackResource.gd" id="2_7qahc"]
[ext_resource type="Texture2D" uid="uid://b2d8chun5wo47" path="res://icon.png" id="3_is0x8"]

[sub_resource type="Resource" id="Resource_151t7"]
script = ExtResource("2_7qahc")
HealthChange = 10

[sub_resource type="SpriteFrames" id="SpriteFrames_f6cvd"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_is0x8")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_25eby"]
size = Vector2(133, 133)

[node name="TestHealSplash" type="Node2D"]
z_index = 1
script = ExtResource("1_xkjtr")
attack = SubResource("Resource_151t7")

[node name="SplashSprite" type="AnimatedSprite2D" parent="."]
modulate = Color(0.235294, 0.572549, 0.45098, 1)
visibility_layer = 2
sprite_frames = SubResource("SpriteFrames_f6cvd")

[node name="SplashCollision" type="Area2D" parent="."]
collision_layer = 3
collision_mask = 3

[node name="CollisionShape2D" type="CollisionShape2D" parent="SplashCollision"]
position = Vector2(-0.5, -1.5)
shape = SubResource("RectangleShape2D_25eby")

[connection signal="body_shape_entered" from="SplashCollision" to="." method="_on_splash_collision_body_shape_entered"]
[connection signal="body_shape_exited" from="SplashCollision" to="." method="_on_splash_collision_body_shape_exited"]
4 changes: 3 additions & 1 deletion Scenes/Entities/Player/player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://ddqbu6qtmex1o"]
[gd_scene load_steps=12 format=3 uid="uid://ddqbu6qtmex1o"]

[ext_resource type="Script" path="res://Scenes/Entities/Player/Player.gd" id="1_02c8r"]
[ext_resource type="Texture2D" uid="uid://b2d8chun5wo47" path="res://icon.png" id="1_wc45e"]
Expand All @@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://yowr31ouivqs" path="res://Scenes/Entities/Player/potionThrower.tscn" id="4_n2kfp"]
[ext_resource type="PackedScene" uid="uid://uca5j0sqca4w" path="res://Scenes/Entities/Player/Potions/testPotion.tscn" id="5_2en5c"]
[ext_resource type="Script" path="res://Scenes/Entities/Player/Player_Normal.gd" id="5_p8y61"]
[ext_resource type="PackedScene" uid="uid://bgvujvuvf1w17" path="res://Scenes/Entities/Player/Potions/testHealPotion.tscn" id="6_ngvyh"]
[ext_resource type="Script" path="res://Scenes/Entities/Player/Player_PotionThrown.gd" id="6_rxkab"]
[ext_resource type="Script" path="res://Scenes/Entity systems/Health system/EntityHealth.gd" id="9_y64nf"]

Expand All @@ -28,6 +29,7 @@ shape = SubResource("RectangleShape2D_x2mbq")

[node name="PotionThrower" parent="." instance=ExtResource("4_n2kfp")]
testPotion = ExtResource("5_2en5c")
testHealPotion = ExtResource("6_ngvyh")

[node name="Statemachine" type="Node" parent="."]
script = ExtResource("4_8g3my")
Expand Down
13 changes: 12 additions & 1 deletion Scenes/Entities/Player/potionThrower.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ class_name PotionThrower
extends Node

@export var testPotion : PackedScene
@export var testHealPotion : PackedScene

var currentPotion : int = potion.Hurt
enum potion {Heal, Hurt}


func _ready() -> void:
var entity : Entity = get_parent() as Entity
entity.PotionThrowerSystem = self


func throw(direction : Vector2) -> void:
var thisPotion = testPotion.instantiate()
var thisPotion : Potion
if currentPotion == potion.Hurt:
thisPotion = testPotion.instantiate()
elif currentPotion == potion.Heal:
thisPotion = testHealPotion.instantiate()

thisPotion.position = get_parent().position
thisPotion.setDirection(direction)
GameVariables.WorldNode.add_child(thisPotion)
currentPotion = randi() % 2
11 changes: 10 additions & 1 deletion Scenes/Entity systems/Health system/EntityHealth.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ class_name EntityHealth
extends Node

signal EntityDied
signal EntityHeal
signal EntityHurt

signal HealthChanged(newHealth : int)

@export var MAXHEALTH : int
Expand All @@ -13,7 +16,7 @@ func getCurrentHealth() -> int:

func setCurrentHealth(value : int) -> void:
health = value
clamp(health, 0, MAXHEALTH)
health = clamp(health, 0, MAXHEALTH)
HealthChanged.emit(health)

func changeCurrentHealth(value : int) -> void:
Expand All @@ -29,6 +32,12 @@ func setup() -> void:

func impactHealth(attack : Attack) -> void:
if(entityDead): return

if(attack.HealthChange > 0):
emit_signal("EntityHeal")
elif (attack.HealthChange < 0):
emit_signal("EntityHurt")

changeCurrentHealth(attack.HealthChange)
checkDeath()

Expand Down
7 changes: 6 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ GameVariables="*res://scripts/GameVariables.gd"

window/size/viewport_width=1920
window/size/viewport_height=1080
window/size/mode=2
window/size/mode=3
window/size/resizable=false
window/canvas_textures/default_texture_filter=0

[file_customization]

Expand Down Expand Up @@ -87,3 +88,7 @@ ACTION_THROWRIGHT={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"echo":false,"script":null)
]
}

[rendering]

textures/canvas_textures/default_texture_filter=0
1 change: 1 addition & 0 deletions scripts/EnemyClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ func reset() -> void:
print(position)

func killed() -> void:
GameVariables.score += 1
queue_free()
15 changes: 15 additions & 0 deletions scripts/EntityClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ var HealthSystem : EntityHealth
var MovementSystem : EntityMovement
var PotionThrowerSystem : PotionThrower

var hurtEffect : PackedScene = preload("res://Scenes/Effects/hurtEffect.tscn")
var healEffect : PackedScene = preload("res://Scenes/Effects/healEffect.tscn")

func setup() -> void:
if(HealthSystem):
HealthSystem.setup()
HealthSystem.EntityHurt.connect(entityHurt)
HealthSystem.EntityHeal.connect(entityHeal)


func reset() -> void:
Expand All @@ -23,6 +28,16 @@ func reset() -> void:
if(MovementSystem):
MovementSystem.reset()

func entityHurt() -> void:
var effect : Node2D = hurtEffect.instantiate()
effect.position = position
get_parent().add_child(effect)

func entityHeal() -> void:
var effect : Node2D = healEffect.instantiate()
effect.position = position
get_parent().add_child(effect)

func knockback(direction : Vector2, force : float, delta : float) -> void:
MovementSystem.applyKnockback(direction, force)
MovementSystem.carryOutMovement(delta)
Loading

0 comments on commit 57c773d

Please sign in to comment.