man has entered the forest

This commit is contained in:
Kevin O Gorman 2025-02-10 19:19:43 -05:00
parent f6ad5142bf
commit f31033dd59
9 changed files with 330 additions and 92 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c1l8de3i0kljl"
path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/death/Player Death 64x64.png"
dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.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 not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d0osk3f111068"
path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/hurt/Player Hurt 48x48.png"
dest_files=["res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.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

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=4 uid="uid://dxvvtcldbhsac"]
[gd_scene load_steps=15 format=4 uid="uid://dxvvtcldbhsac"]
[ext_resource type="Texture2D" uid="uid://dordo7deet5y0" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="1_fca7k"]
[ext_resource type="Texture2D" uid="uid://cukevm4avtgnp" path="res://assets/graphics/terrains/backgrounds/sky.png" id="2_7a0hu"]
@ -9,6 +9,7 @@
[ext_resource type="Script" path="res://scripts/trigger.gd" id="7_vcera"]
[ext_resource type="PackedScene" uid="uid://djkjmi7bo58uv" path="res://scenes/crate.tscn" id="8_q5n2b"]
[ext_resource type="PackedScene" uid="uid://cey0ymp1n0iqe" path="res://scenes/coin.tscn" id="9_iql8u"]
[ext_resource type="PackedScene" uid="uid://bk0pk4m1ln716" path="res://scenes/badguy.tscn" id="10_w2bl5"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v72u6"]
texture = ExtResource("5_qoo1j")
@ -456,21 +457,21 @@ rotation = -0.0982481
[node name="RigidBody2D" parent="crates" instance=ExtResource("8_q5n2b")]
position = Vector2(501, 265)
[node name="enemies" type="Node2D" parent="."]
[node name="Area2D" parent="enemies" instance=ExtResource("10_w2bl5")]
position = Vector2(79, 415)
[node name="Area2D2" parent="enemies" instance=ExtResource("10_w2bl5")]
position = Vector2(215, 415)
[node name="coins" type="Node2D" parent="."]
[node name="Area2D" parent="coins" instance=ExtResource("9_iql8u")]
position = Vector2(72, 107)
script = null
[node name="Area2D2" parent="coins" instance=ExtResource("9_iql8u")]
position = Vector2(-42, 11)
script = null
[node name="Area2D3" parent="coins" instance=ExtResource("9_iql8u")]
position = Vector2(-55, 295)
[node name="Area2D4" parent="coins" instance=ExtResource("9_iql8u")]
position = Vector2(321, 198)
position = Vector2(-178, 75)
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

View File

@ -1,7 +1,9 @@
[gd_scene load_steps=28 format=3 uid="uid://b2hyqfqh02ep6"]
[gd_scene load_steps=44 format=3 uid="uid://b2hyqfqh02ep6"]
[ext_resource type="Script" path="res://scripts/charController.gd" id="1_4o8do"]
[ext_resource type="Texture2D" uid="uid://c1l8de3i0kljl" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_alp3v"]
[ext_resource type="Texture2D" uid="uid://bfhqvl875is6f" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_yfuca"]
[ext_resource type="Texture2D" uid="uid://d0osk3f111068" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="3_5pi5t"]
[ext_resource type="Texture2D" uid="uid://c2s48joyna11q" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_p8gbr"]
[ext_resource type="Texture2D" uid="uid://bvat1vqwtua2p" path="res://assets/graphics/player/run/player run 48x48.png" id="3_y36hw"]
@ -9,6 +11,62 @@
radius = 9.93
height = 35.0
[sub_resource type="AtlasTexture" id="AtlasTexture_iomdd"]
atlas = ExtResource("2_alp3v")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qlc64"]
atlas = ExtResource("2_alp3v")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_r8feb"]
atlas = ExtResource("2_alp3v")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_pchcp"]
atlas = ExtResource("2_alp3v")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ekkmw"]
atlas = ExtResource("2_alp3v")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_aenr4"]
atlas = ExtResource("2_alp3v")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_c2bld"]
atlas = ExtResource("2_alp3v")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_556cp"]
atlas = ExtResource("2_alp3v")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_hf6j1"]
atlas = ExtResource("2_alp3v")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_pvct1"]
atlas = ExtResource("2_alp3v")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_0ae2b"]
atlas = ExtResource("3_5pi5t")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_0i34p"]
atlas = ExtResource("3_5pi5t")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_k17h1"]
atlas = ExtResource("3_5pi5t")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_1nyuv"]
atlas = ExtResource("3_5pi5t")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_cdvw1"]
atlas = ExtResource("2_yfuca")
region = Rect2(0, 0, 48, 48)
@ -97,6 +155,58 @@ region = Rect2(336, 0, 48, 48)
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_iomdd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qlc64")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r8feb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pchcp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ekkmw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aenr4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_c2bld")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_556cp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hf6j1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pvct1")
}],
"loop": false,
"name": &"playerDeath",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0ae2b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0i34p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_k17h1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1nyuv")
}],
"loop": false,
"name": &"playerHurt",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_cdvw1")
}, {
"duration": 1.0,
@ -203,5 +313,9 @@ texture_filter = 1
position = Vector2(-1, -3)
scale = Vector2(1.29167, 1.29167)
sprite_frames = SubResource("SpriteFrames_52pno")
animation = &"playerIdle"
animation = &"playerDeath"
autoplay = "playerIdle"
frame = 9
frame_progress = 1.0
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_finished"]

View File

@ -21,80 +21,108 @@ var bullet = preload("res://scenes/bullet.tscn")
var isJumping = false
var living = true
var animPlaying = "idle"
signal deathAnimDone
func hurtPlayer(_amt):
if living:
animPlaying = "playerHurt"
animation.play(animPlaying)
func killPlayer():
if living:
living = false
print("Oh no")
animPlaying = "playerDeath"
animation.play(animPlaying)
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
isJumping = false
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
isJumping = true
velocity.y = JUMP_VELOCITY
if pushTarget:
if Input.is_action_just_pressed("Shove") && pushLeftEnabled && faceLeft:
print("shove left")
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 10)
pushLeftEnabled = false
if Input.is_action_just_pressed("Shove") && pushRightEnabled && not faceLeft:
print("shove right")
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 15)
pushRightEnabled = false
if Input.is_action_just_pressed("Shoot"):
if faceLeft:
var _myBullet = %SceneManager.makeBullet(marker_left.global_transform, -700)
if living and not animPlaying == "playerHurt":
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
var _myBullet = %SceneManager.makeBullet(marker_right.global_transform, 700)
isJumping = false
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
if direction < 0:
faceLeft = true
if direction > 0:
faceLeft = false
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
isJumping = true
velocity.y = JUMP_VELOCITY
animation.flip_h = faceLeft
if not isJumping:
animation.play("playerRun")
else:
animation.play("playerJump")
velocity.x = direction * SPEED
else:
if not isJumping:
animation.play("playerIdle")
else:
animation.play("playerJump")
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in (get_slide_collision_count()):
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal()*BUMP_FORCE)
pushTarget = false
if left_ray.is_colliding():
var collider = left_ray.get_collider()
if collider is Node:
if collider.is_in_group("pushables"):
pushLeftEnabled = true
pushTarget = collider
else:
if pushTarget:
if Input.is_action_just_pressed("Shove") && pushLeftEnabled && faceLeft:
print("shove left")
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 10)
pushLeftEnabled = false
if right_ray.is_colliding():
var collider = right_ray.get_collider()
if collider is Node:
if collider.is_in_group("pushables"):
pushRightEnabled = true
pushTarget = collider
else:
if Input.is_action_just_pressed("Shove") && pushRightEnabled && not faceLeft:
print("shove right")
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 15)
pushRightEnabled = false
if Input.is_action_just_pressed("Shoot"):
if faceLeft:
var _myBullet = %SceneManager.makeBullet(marker_left.global_transform, -700)
else:
var _myBullet = %SceneManager.makeBullet(marker_right.global_transform, 700)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
if direction < 0:
faceLeft = true
if direction > 0:
faceLeft = false
animation.flip_h = faceLeft
if not isJumping:
animation.play("playerRun")
else:
animation.play("playerJump")
velocity.x = direction * SPEED
else:
if not isJumping:
animation.play("playerIdle")
else:
animation.play("playerJump")
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in (get_slide_collision_count()):
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal()*BUMP_FORCE)
pushTarget = false
if left_ray.is_colliding():
var collider = left_ray.get_collider()
if collider is Node:
if collider.is_in_group("pushables"):
pushLeftEnabled = true
pushTarget = collider
else:
pushLeftEnabled = false
if right_ray.is_colliding():
var collider = right_ray.get_collider()
if collider is Node:
if collider.is_in_group("pushables"):
pushRightEnabled = true
pushTarget = collider
else:
pushRightEnabled = false
func _on_animated_finished() -> void:
if animPlaying == "playerHurt":
animPlaying = "playerIdle"
if animPlaying == "playerDeath":
# emit death signal
deathAnimDone.emit()

View File

@ -12,12 +12,14 @@ var player:Resource
# level info
var levels = ["res://scenes/game.tscn", "res://scenes/level2.tscn"]
var timers = [30, 30]
var timers = [90, 90]
var currentLevel = 0
#Gamecontroller signals
signal destroyBox(body)
signal levelComplete(leveltoLoad)
signal playerHurt(amt)
signal playerDeath()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -29,9 +31,12 @@ func _ready() -> void:
timer.one_shot = false
timer.connect("timeout", secondCounter)
timer.start()
func reset():
secondCount = timers[currentLevel]
player.health = player.starting_health
func secondCounter():
print("time left: ", secondCount)
@ -40,17 +45,23 @@ func secondCounter():
print("TIME IS UP")
levelComplete.emit(levels[currentLevel])
func playerDamaged():
print("GC knows player took damage")
player.health = max(player.health-10, 0)
player.health = max(player.health-20, 0)
print("Player Health: "+str(player.health))
if player.health > 0:
playerHurt.emit(player.health)
else:
playerDeath.emit()
func coinCollected():
totalCoinsCollected += 1
print("DING! Coins collected: "+ str(totalCoinsCollected) )
func bulletHit(body):
print("Game controller knows bullet hit something")
if body.is_in_group("destructables"):
@ -66,14 +77,21 @@ func bulletHit(body):
levelComplete.emit(levels[currentLevel])
else:
print("Crates Remaining: "+str(totalCrates) )
# Coming from scenemanager
func countCrates(value):
totalCrates = value
func countCoins(value):
totalCoins = value
func countBadGuys(value):
totalBadGuys = value
func playerDead():
print("GC knows player is dead")
levelComplete.emit(levels[currentLevel])

View File

@ -5,6 +5,8 @@ extends Node
@onready var coins: Node2D = $"../coins"
@onready var enemies: Node2D = $"../enemies"
@onready var player: CharacterBody2D = $"../CharacterBody2D"
var theBullet = preload("res://scenes/bullet.tscn")
var bulletArray:Array = []
@ -33,8 +35,15 @@ func _ready() -> void:
GameController.countBadGuys(totalEnemies)
GameController.countCrates(totalCrates)
# Player interactions
GameController.playerHurt.connect(player.hurtPlayer)
GameController.playerDeath.connect(player.killPlayer)
# Subscribe to signals
GameController.levelComplete.connect(changeLevel)
player.deathAnimDone.connect(GameController.playerDead)
GameController.reset()
func changeLevel(level):
print("New level")