lots of damage

This commit is contained in:
TaylorB 2025-09-08 20:57:14 -04:00
parent c0b5e099dc
commit 8b90d78c14
18 changed files with 1574 additions and 32 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ff4jab7uxcbx"
path="res://.godot/imported/slime_purple.png-6f377520979ef4c15e65306ba4678a1e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Graphics/Enemies/slime_purple.png"
dest_files=["res://.godot/imported/slime_purple.png-6f377520979ef4c15e65306ba4678a1e.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

View File

@ -7,7 +7,7 @@
size = Vector2(18.0392, 20.8045)
[node name="Crate" type="RigidBody2D" groups=["pushable"]]
rotation = 0.90108
rotation = 1.5708
script = ExtResource("1_qgfyo")
metadata/_edit_group_ = true

View File

@ -96,7 +96,7 @@ animations = [{
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_m55n1"]
radius = 5.0
radius = 2.23607
[node name="coin" type="Area2D"]
texture_filter = 1
@ -106,7 +106,7 @@ script = ExtResource("1_jgi06")
sprite_frames = SubResource("SpriteFrames_qtgto")
animation = &"idle"
autoplay = "idle"
frame_progress = 0.668838
frame_progress = 0.447772
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_m55n1")

File diff suppressed because one or more lines are too long

592
Scenes/reallygoodgame2.tscn Normal file

File diff suppressed because one or more lines are too long

586
Scenes/reallygoodgame3.tscn Normal file

File diff suppressed because one or more lines are too long

74
Scenes/slime.tscn Normal file
View File

@ -0,0 +1,74 @@
[gd_scene load_steps=9 format=3 uid="uid://bp681r4m6n8a6"]
[ext_resource type="Script" uid="uid://da1ki5gcro7rb" path="res://scripts/slime.gd" id="1_swwnm"]
[ext_resource type="Texture2D" uid="uid://ff4jab7uxcbx" path="res://Assets/Graphics/Enemies/slime_purple.png" id="2_aiwxb"]
[sub_resource type="CircleShape2D" id="CircleShape2D_paq7w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_f4si1"]
atlas = ExtResource("2_aiwxb")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_5gljc"]
atlas = ExtResource("2_aiwxb")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_vblni"]
atlas = ExtResource("2_aiwxb")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_e388w"]
atlas = ExtResource("2_aiwxb")
region = Rect2(72, 24, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_r4o34"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_f4si1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5gljc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vblni")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e388w")
}],
"loop": true,
"name": &"default",
"speed": 6.0
}]
[node name="Slime" type="Area2D"]
script = ExtResource("1_swwnm")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_paq7w")
debug_color = Color(0.87451, 0.266667, 0.0705882, 0.419608)
[node name="SlimeGraphic" type="AnimatedSprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -4)
scale = Vector2(1.20833, 1.1875)
sprite_frames = SubResource("SpriteFrames_r4o34")
autoplay = "default"
frame = 2
frame_progress = 0.971417
[node name="right cast" type="RayCast2D" parent="."]
target_position = Vector2(14, 0)
[node name="left cast" type="RayCast2D" parent="."]
target_position = Vector2(-14, 0)
[node name="left down cast" type="RayCast2D" parent="."]
position = Vector2(-8, -3)
target_position = Vector2(0, 13)
[node name="right down cast" type="RayCast2D" parent="."]
position = Vector2(8, -3)
target_position = Vector2(0, 13)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -15,6 +15,10 @@ run/main_scene="uid://ibkufgrwjwro"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
Gamecontroller="*res://scripts/gamecontroller.gd"
[display]
window/size/viewport_width=320

View File

@ -1,7 +1,8 @@
class_name coin extends Area2D
class_name Coin extends Area2D
signal coincollectedsignal(body, coin)
func _on_body_entered(body: Node2D) -> void:
print("coin collision")
coincollectedsignal.emit(body,self)
if body is Player:
coincollectedsignal.emit(body,self)

View File

@ -1,11 +1,44 @@
extends Node2D
signal playerDamage
signal destroySignal(body)
signal levelChangeSignal(level)
var timer = Timer.new()
var timeAvailable:int = 5
var levels = ["res://Scenes/reallygoodgame.tscn", "res://Scenes/reallygoodgame2.tscn", "res://Scenes/reallygoodgame3.tscn"]
var timers = [500,500,500]
var currentLevel = 0
#character stats
var enemy:CharacterStats
var player:CharacterStats
var playerCurrentHealth:int
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
enemy = load("res://scripts/rscs/slimeStats.tres")
player = load("res://scripts/rscs/PlayerStats.tres")
playerCurrentHealth = player.starting_health
# Replace with function body.
add_child(timer)
timer.wait_time = 1
timer.one_shot = false
timer.connect("timeout", secondCounter)
timer.start()
func secondCounter():
timeAvailable -=1
if timeAvailable <=0:
print("you lose")
levelChangeSignal.emit(levels[currentLevel])
func reset():
timeAvailable = timers[currentLevel]
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
@ -20,8 +53,8 @@ func _on_trigger(effect: Variant, body: Variant) -> void:
playerDamage.emit()
if body.name == "world-boundary":
return
if not body is Player:
body.queue_free()
#if not body is Player:
# body.queue_free()
func bulletDamage(target: Node2D, bullet: Node2D):
print("GC sees a hit")
@ -30,5 +63,21 @@ func bulletDamage(target: Node2D, bullet: Node2D):
func coincollected(body, coin):
print("coincollected")
coin.queue_free()
destroySignal.emit(coin)
func totalcoincount(count):
print("GC knows total coins"+str(count))
if count == 0:
currentLevel +=1
if currentLevel >= levels.size():
currentLevel = 0
levelChangeSignal.emit(levels[currentLevel])
func playerAttacked(body, slime):
print("player attacked")
print("damage : "+str(enemy.meleeDamage) )
print("player health : "+str(player.health))
playerCurrentHealth -= enemy.meleeDamage
if playerCurrentHealth <=0:
print("you died")

View File

@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="CharacterStats" load_steps=2 format=3 uid="uid://dwjbdmn7rqrq"]
[ext_resource type="Script" uid="uid://dketxenj4lhi2" path="res://scripts/rscs/characterstats.gd" id="1_sf2cn"]
[resource]
script = ExtResource("1_sf2cn")
health = 100
max_health = 100
starting_health = 100
meleeDamage = 100
rangeDamage = 0
metadata/_custom_type_script = "uid://dketxenj4lhi2"

View File

@ -0,0 +1,10 @@
class_name CharacterStats extends Resource
#health
@export var health:int = 100
@export var max_health:int =100
@export var starting_health:int =100
#damage dealing
@export var meleeDamage:int = 10
@export var rangeDamage:int = 0

View File

@ -0,0 +1 @@
uid://dketxenj4lhi2

View File

@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="CharacterStats" load_steps=2 format=3 uid="uid://biwt82n31llbp"]
[ext_resource type="Script" uid="uid://dketxenj4lhi2" path="res://scripts/rscs/characterstats.gd" id="1_ppipo"]
[resource]
script = ExtResource("1_ppipo")
health = 100
max_health = 100
starting_health = 100
meleeDamage = 100
rangeDamage = 0
metadata/_custom_type_script = "uid://dketxenj4lhi2"

View File

@ -1,19 +1,48 @@
class_name SCENEMANAGER extends Node2D
const bulletscn = preload("res://Scenes/bullet.tscn")
@onready var game: Node2D = $".."
@onready var triggers: Node2D = $"../Triggers"
@onready var coins: Node2D = $"../Coins"
@onready var enemies: Node2D = $"../enemies"
func _ready() -> void:
Gamecontroller.reset()
if triggers:
for obj in triggers.get_children():
if obj is Trigger:
obj.areaTriggerSignal.connect(game._on_trigger)
obj.areaTriggerSignal.connect(Gamecontroller._on_trigger)
if coins:
for obj in coins.get_children():
if obj is coin:
obj.coincollectedsignal.connect(game.coincollected)
Updatecoins()
if enemies:
updateEnemies()
Gamecontroller.destroySignal.connect(destroy)
Gamecontroller.levelChangeSignal.connect(changeScene)
func updateEnemies():
for obj in enemies.get_children():
if obj is Slime:
if not obj.playerDamageSignal.is_connected(Gamecontroller.playerAttacked):
obj.playerDamageSignal.connect(Gamecontroller.playerAttacked)
func Updatecoins():
var coincount = 0
for obj in coins.get_children():
if obj is Coin:
if not obj.coincollectedsignal.is_connected(Gamecontroller.coincollected):
obj.coincollectedsignal.connect(Gamecontroller.coincollected)
print("hooked up")
#connect tree exit
if not obj.tree_exited.is_connected(Updatecoins):
obj.tree_exited.connect(Updatecoins)
coincount +=1
Gamecontroller.totalcoincount(coincount)
var bullets: Array[Bullet] = []
@ -25,7 +54,7 @@ func bulletFactory() -> Bullet:
if len(bullets) < MAX_BULLETS:
# create new bujllet
var b = bulletscn.instantiate()
b.bulletDamageSignal.connect(game.bulletDamage)
b.bulletDamageSignal.connect(Gamecontroller.bulletDamage)
add_child(b)
bullets.append(b)
return b
@ -44,3 +73,9 @@ func makeBullet(pos: Transform2D, dir: int) -> Node2D:
b.setSpeed(dir * 700)
return b
func destroy(body):
body.queue_free()
print("destroy")
func changeScene(level):
get_tree().call_deferred("change_scene_to_file", level)

37
scripts/slime.gd Normal file
View File

@ -0,0 +1,37 @@
class_name Slime extends Area2D
@onready var slime_graphic: AnimatedSprite2D = $SlimeGraphic
@onready var right_cast: RayCast2D = $"right cast"
@onready var left_cast: RayCast2D = $"left cast"
@onready var left_down_cast: RayCast2D = $"left down cast"
@onready var right_down_cast: RayCast2D = $"right down cast"
var speed:int = 100
var direction = 1
signal playerDamageSignal(body, slime)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
position.x += direction * speed * delta
if not right_down_cast.is_colliding():
direction = -1
if not left_down_cast.is_colliding():
direction = 1
if left_cast.is_colliding() && direction == -1:
direction = 1
if right_cast.is_colliding() && direction == 1:
direction = -1
slime_graphic.flip_h = direction == -1
func _on_body_entered(body: Node2D) -> void:
if body is Player:
print("slime attack")
playerDamageSignal.emit(body, self)

1
scripts/slime.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://da1ki5gcro7rb