Made some changes :)

This commit is contained in:
pennyrigate 2022-12-08 23:28:49 -05:00
parent 038935709f
commit 8f6a068eba
76 changed files with 889 additions and 36 deletions

View file

@ -10,5 +10,6 @@ func _on_Area2D_area_entered(area):
#Collect
if area.is_in_group("player"):
Game.golds += value
Game.score += 5
Game.play_sound(Game.a_gold,Game.ac_collectible)
queue_free()

View file

@ -45,6 +45,7 @@ playing = true
centered = false
[node name="Area2D" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4, 4 )

View file

@ -8,5 +8,7 @@ func _ready():
func _on_Area2D_area_entered(area):
#Collect
if area.is_in_group("player"):
Game.play_sound(Game.a_shard,Game.ac_collectible)
Game.score += 500
Game.shards += value
queue_free()

View file

@ -1,16 +1,34 @@
extends Node2D
export(int, "Red", "Yellow","Green","Blue","Magenta") var color
export var value = 1
onready var sprite = $AnimatedSprite
func _ready():
#Sync all coinframes
$AnimatedSprite.play()
sprite.play()
#Change color
match color:
0:
sprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_red.png"))
1:
sprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_yellow.png"))
2:
sprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_green.png"))
3:
sprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_blue.png"))
4:
sprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_magenta.png"))
func _on_Area2D_area_entered(area):
#Collect
if area.is_in_group("player"):
Game.play_sound(Game.a_star,Game.ac_collectible)
Game.stars += value
Game.score += 100
Game.stars[color] = true
#5 Star reward
if Game.stars == 5: Game.shards += 1
if Game.stars[0] && Game.stars[1] && Game.stars[2] && Game.stars[3] && Game.stars[4]:
Game.play_sound(Game.a_shard,Game.ac_collectible)
Game.shards += 1
Game.score += 500
queue_free()

View file

@ -5,39 +5,40 @@
[ext_resource path="res://objects/collectibles/star.gd" type="Script" id=3]
[ext_resource path="res://graphics/collectibles/star.png" type="Texture" id=4]
[sub_resource type="ShaderMaterial" id=1]
[sub_resource type="ShaderMaterial" id=10]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
shader_param/palette = ExtResource( 1 )
[sub_resource type="AtlasTexture" id=2]
[sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 4 )
region = Rect2( 0, 0, 11, 11 )
[sub_resource type="AtlasTexture" id=3]
[sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 4 )
region = Rect2( 11, 0, 11, 11 )
[sub_resource type="AtlasTexture" id=4]
[sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 4 )
region = Rect2( 22, 0, 11, 11 )
[sub_resource type="AtlasTexture" id=5]
[sub_resource type="AtlasTexture" id=14]
atlas = ExtResource( 4 )
region = Rect2( 33, 0, 11, 11 )
[sub_resource type="AtlasTexture" id=6]
[sub_resource type="AtlasTexture" id=15]
atlas = ExtResource( 4 )
region = Rect2( 44, 0, 11, 11 )
[sub_resource type="AtlasTexture" id=7]
[sub_resource type="AtlasTexture" id=16]
atlas = ExtResource( 4 )
region = Rect2( 55, 0, 11, 11 )
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ],
"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "default",
"speed": 8.0
@ -50,10 +51,10 @@ extents = Vector2( 4, 4 )
script = ExtResource( 3 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = SubResource( 1 )
material = SubResource( 10 )
position = Vector2( -1, -3 )
frames = SubResource( 8 )
frame = 3
frame = 2
playing = true
centered = false

48
objects/enemy/bat.tscn Normal file
View file

@ -0,0 +1,48 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://graphics/enemy/bat.png" type="Texture" id=2]
[ext_resource path="res://objects/enemy/enemy_move_sidesideupdown.gd" type="Script" id=3]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 18, 10 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 18, 0, 18, 10 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "default",
"speed": 8.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 5, 5 )
[node name="Bat" type="Node2D"]
script = ExtResource( 3 )
can_be_killed_by_sword = false
speed = 40
move_direction = 1
flip_sprite = false
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = SubResource( 1 )
frames = SubResource( 4 )
playing = true
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 5 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]

View file

@ -2,6 +2,7 @@ extends Node2D
export var can_be_killed_by_sword = true
export var can_be_squashed = true
export var score_for_killing = 0
func _on_Area2D_area_entered(area):
#Kill player
@ -10,9 +11,15 @@ func _on_Area2D_area_entered(area):
#Die from sword
if area.is_in_group("sword"):
if can_be_killed_by_sword:
queue_free()
die()
else:
Game.instance_node(Game.block_text,global_position.x,global_position.y,get_parent())
#Die from rock/ get squashed
if area.is_in_group("squash"):
var squasher = area.get_parent()
if squasher.position.y + squasher.bottom.position.y < global_position.y:
queue_free()
die()
func die():
Game.score += score_for_killing
queue_free()

View file

@ -32,14 +32,16 @@ extents = Vector2( 5.5, 4.5 )
[node name="Slime" type="Node2D"]
script = ExtResource( 4 )
score_for_killing = 10
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = SubResource( 1 )
position = Vector2( 5, 3 )
position = Vector2( 1, 3 )
frames = SubResource( 4 )
playing = true
[node name="Area2D" type="Area2D" parent="."]
position = Vector2( -4, 0 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4.5, 3.5 )

View file

@ -30,10 +30,12 @@ extents = Vector2( 8, 8 )
[node name="Snake" type="Node2D"]
script = ExtResource( 3 )
score_for_killing = 15
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = SubResource( 1 )
frames = SubResource( 4 )
frame = 1
playing = true
[node name="Area2D" type="Area2D" parent="."]

7
objects/hud/blocktext.gd Normal file
View file

@ -0,0 +1,7 @@
extends Node2D
func _ready():
$AnimationPlayer.play("block")
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free()

View file

@ -0,0 +1,51 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://objects/hud/blocktext.gd" type="Script" id=2]
[ext_resource path="res://graphics/hud/block_text.png" type="Texture" id=3]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="Animation" id=2]
resource_name = "block"
length = 0.3
step = 0.15
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.3 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 0, -8 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Sprite:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.15, 0.3 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
[node name="BlockText" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 1 )
texture = ExtResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/block = SubResource( 2 )
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]

24
objects/hud/hud.gd Normal file
View file

@ -0,0 +1,24 @@
extends Control
onready var gold_counter = $GoldCounter
onready var shard_counter = $ShardCounter
onready var red_star = $RedStar
onready var yellow_star = $YellowStar
onready var green_star = $GreenStar
onready var blue_star = $BlueStar
onready var magenta_star = $MagentaStar
onready var score_counter = $ScoreCounter
func _physics_process(delta):
#Gold Counter
gold_counter.text = "%03d" % Game.golds
#Shard Counter
shard_counter.text = "%02d" % Game.shards
#Star Counter
red_star.visible = Game.stars[0]
yellow_star.visible = Game.stars[1]
green_star.visible = Game.stars[2]
blue_star.visible = Game.stars[3]
magenta_star.visible = Game.stars[4]
#Score Counter
score_counter.text = "%06d" % Game.score

113
objects/hud/hud.tscn Normal file
View file

@ -0,0 +1,113 @@
[gd_scene load_steps=16 format=2]
[ext_resource path="res://scripts/recolor.tres" type="Shader" id=1]
[ext_resource path="res://graphics/collectibles/pal_star_yellow.png" type="Texture" id=2]
[ext_resource path="res://graphics/hud/hud.png" type="Texture" id=3]
[ext_resource path="res://graphics/collectibles/star.png" type="Texture" id=4]
[ext_resource path="res://graphics/collectibles/pal_star_red.png" type="Texture" id=5]
[ext_resource path="res://objects/hud/hud.gd" type="Script" id=6]
[ext_resource path="res://graphics/collectibles/pal_star_green.png" type="Texture" id=7]
[ext_resource path="res://graphics/collectibles/pal_star_blue.png" type="Texture" id=8]
[ext_resource path="res://graphics/collectibles/pal_star_magenta.png" type="Texture" id=9]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=10]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 5 )
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 2 )
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 7 )
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 8 )
[sub_resource type="ShaderMaterial" id=5]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 9 )
[node name="HUD" type="Control"]
margin_top = 1.0
margin_bottom = 1.0
script = ExtResource( 6 )
[node name="Back" type="Sprite" parent="."]
position = Vector2( 128, 8 )
texture = ExtResource( 3 )
[node name="GoldCounter" type="Label" parent="."]
margin_left = 14.0
margin_top = 1.0
margin_right = 54.0
margin_bottom = 21.0
theme = ExtResource( 10 )
text = "000"
[node name="ShardCounter" type="Label" parent="."]
margin_left = 53.0
margin_top = 1.0
margin_right = 93.0
margin_bottom = 21.0
theme = ExtResource( 10 )
text = "00"
[node name="RedStar" type="Sprite" parent="."]
visible = false
material = SubResource( 1 )
position = Vector2( 79, 8 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
[node name="YellowStar" type="Sprite" parent="."]
visible = false
material = SubResource( 2 )
position = Vector2( 92, 8 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
[node name="GreenStar" type="Sprite" parent="."]
visible = false
material = SubResource( 3 )
position = Vector2( 105, 8 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
[node name="BlueStar" type="Sprite" parent="."]
visible = false
material = SubResource( 4 )
position = Vector2( 118, 8 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
[node name="MagentaStar" type="Sprite" parent="."]
visible = false
material = SubResource( 5 )
position = Vector2( 131, 8 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
[node name="ScoreText" type="Label" parent="."]
margin_left = 142.0
margin_top = 1.0
margin_right = 226.0
margin_bottom = 21.0
theme = ExtResource( 10 )
text = "SCORE:"
[node name="ScoreCounter" type="Label" parent="."]
margin_left = 180.0
margin_top = 1.0
margin_right = 264.0
margin_bottom = 21.0
theme = ExtResource( 10 )
text = "000000"

View file

@ -49,6 +49,11 @@ func _physics_process(delta):
if current_state != State.CLIMB: velocity.y += gravity
#Apply velocity
move_and_slide(velocity,Vector2.UP)
#Debug
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())
func _process_idle():
if anims.get_current_animation() != "idle": anims.play("idle")
@ -78,6 +83,7 @@ func _process_idle_walk():
check_jump()
#Goto Sword
if Input.is_action_just_pressed("sword"):
Game.play_sound(Game.a_sword,Game.ac_jump)
current_state = State.SWORD
return
@ -104,11 +110,18 @@ func _process_climb():
anims.set_speed_scale(abs(axis.y))
#Climb
position.y += axis.y * 0.65
#Sound
if axis.y == -1:
if Game.ac_climb.get_stream() != Game.a_climb_up: Game.play_sound(Game.a_climb_up,Game.ac_climb)
if axis.y == 1:
if Game.ac_climb.get_stream() != Game.a_climb_down: Game.play_sound(Game.a_climb_down,Game.ac_climb)
if axis.y == 0: Game.ac_climb.set_stream(null)
#Manual Jump,, only works when holding neutral or away from ladder
if axis.x != sprite.scale.x: check_jump()
#Auto Jump
if climb_ray.get_collider() == null:
velocity.y = -jump_force
Game.ac_climb.set_stream(null)
Game.play_sound(Game.a_jump,Game.ac_jump)
current_state = State.FALL
return
@ -119,7 +132,7 @@ func _process_sword():
velocity.x = 0
sword_sprite.scale.x = sprite.scale.x
#Move hitbox with flip
sword_hitbox.position.x = 10 * sprite.scale.x
sword_hitbox.position.x = sprite.scale.x * 10
#Return to idle after animationplayer end anim signal
@ -127,7 +140,9 @@ func _process_sword():
func check_jump():
if Input.is_action_just_pressed("jump") && !Input.is_action_pressed("ui_down"):
#Detach ladder
if current_state == State.CLIMB: position.x -= sprite.scale.x * 5
if current_state == State.CLIMB:
Game.ac_climb.set_stream(null)
position.x -= sprite.scale.x * 5
anims.set_speed_scale(1)
# Jump
jump_pressure = 0

View file

@ -458,15 +458,17 @@ region_rect = Rect2( 0, 0, 20, 20 )
[node name="SwordSprite" type="Sprite" parent="."]
material = SubResource( 28 )
region_enabled = true
region_rect = Rect2( 32, 0, 32, 32 )
region_rect = Rect2( 0, 0, 32, 32 )
[node name="Area2D" type="Area2D" parent="." groups=["player"]]
visible = false
position = Vector2( 0, 3 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 6 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["sword"]]
visible = false
position = Vector2( 0, 3 )
shape = SubResource( 6 )
@ -487,9 +489,10 @@ anims/stab = SubResource( 32 )
anims/walk = SubResource( 33 )
[node name="SwordArea" type="Area2D" parent="." groups=["sword"]]
visible = false
[node name="SwordHitBox" type="CollisionShape2D" parent="SwordArea"]
position = Vector2( 10, 3 )
position = Vector2( 0, 3 )
shape = SubResource( 34 )
disabled = true