initial commit
This commit is contained in:
commit
bc6eb6f4a6
85 changed files with 2247 additions and 0 deletions
11
Scripts/DeathLabel.gd
Normal file
11
Scripts/DeathLabel.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Label
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
text = str(int(get_node("/root/DataStore").read("coins", 0))-int(get_node("/root/Scorekeeper").score)) + " + " + str(int(get_node("/root/Scorekeeper").score))
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
24
Scripts/Globals/data_store.gd
Normal file
24
Scripts/Globals/data_store.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends Node
|
||||
|
||||
var save_config : ConfigFile
|
||||
|
||||
## Initial load and parse
|
||||
func _ready():
|
||||
save_config = ConfigFile.new()
|
||||
var err = save_config.load("user://save")
|
||||
if err:
|
||||
return
|
||||
|
||||
## Read a value with the given string key
|
||||
func read(key : String, default : Variant):
|
||||
return save_config.get_value("save", key, default)
|
||||
|
||||
## Write a key
|
||||
func write(key : String, value : Variant):
|
||||
save_config.set_value("save",key,value)
|
||||
save_config.save("user://save")
|
||||
|
||||
## Reset the savefile
|
||||
func reset():
|
||||
save_config.clear()
|
||||
save_config.save("user://save")
|
34
Scripts/Globals/scorekeeper.gd
Normal file
34
Scripts/Globals/scorekeeper.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends Node
|
||||
|
||||
var score : float = 0
|
||||
var doScore : bool = false
|
||||
var scoreMult = 0.5
|
||||
|
||||
|
||||
func _ready():
|
||||
var pi = get_node("/root/DataStore").read("coins", 0)
|
||||
if pi:
|
||||
scoreMult = 0.8
|
||||
|
||||
func barrel_destroyed():
|
||||
if doScore:
|
||||
score += 0.2
|
||||
|
||||
func start_scoring():
|
||||
doScore = true
|
||||
score = 0
|
||||
|
||||
func stop_scoring():
|
||||
var coins = get_node("/root/DataStore").read("coins", 0)
|
||||
coins += int(score)
|
||||
get_node("/root/DataStore").write("coins", coins)
|
||||
|
||||
var highscore = get_node("/root/DataStore").read("highscore", 0)
|
||||
if score < highscore:
|
||||
get_node("/root/DataStore").write("highscore", score)
|
||||
|
||||
doScore = false
|
||||
|
||||
func _process(delta):
|
||||
if doScore:
|
||||
score = score + delta * scoreMult
|
10
Scripts/Projectiles.gd
Normal file
10
Scripts/Projectiles.gd
Normal file
|
@ -0,0 +1,10 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
func _physics_process(delta):
|
||||
rotate(15 * delta)
|
||||
var res = move_and_collide(Vector2(200 * delta,0))
|
||||
if res:
|
||||
res.get_collider().call("destroy")
|
||||
queue_free()
|
||||
if position.x > 670:
|
||||
queue_free()
|
7
Scripts/Shop.gd
Normal file
7
Scripts/Shop.gd
Normal file
|
@ -0,0 +1,7 @@
|
|||
extends Control
|
||||
|
||||
@export var coin_label : Label
|
||||
|
||||
func _ready():
|
||||
var coins = get_node("/root/DataStore").read("coins", 0)
|
||||
coin_label.text = str(int(coins))
|
19
Scripts/Startmenu.gd
Normal file
19
Scripts/Startmenu.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends Control
|
||||
|
||||
func start():
|
||||
get_tree().change_scene_to_file("res://Scenes/Game.tscn")
|
||||
|
||||
func exit():
|
||||
get_tree().quit()
|
||||
|
||||
func guide():
|
||||
get_tree().change_scene_to_file("res://Scenes/Guide.tscn")
|
||||
|
||||
func credits():
|
||||
get_tree().change_scene_to_file("res://Scenes/Credits.tscn")
|
||||
|
||||
func main():
|
||||
get_tree().change_scene_to_file("res://Scenes/Startmenu.tscn")
|
||||
|
||||
func store():
|
||||
get_tree().change_scene_to_file("res://Scenes/Shop.tscn")
|
5
Scripts/attack.gd
Normal file
5
Scripts/attack.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends Area2D
|
||||
|
||||
|
||||
func _on_area_entered(area):
|
||||
area.queue_free()
|
18
Scripts/barrel.gd
Normal file
18
Scripts/barrel.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
@export var speed = 200;
|
||||
@export var sprite : Sprite2D
|
||||
|
||||
func _ready():
|
||||
position.x = 800
|
||||
position.y = 60 + randi() % 260
|
||||
|
||||
func _physics_process(delta):
|
||||
if position.x < -50:
|
||||
get_node("/root/Scorekeeper").call("barrel_destroyed")
|
||||
queue_free()
|
||||
var res = move_and_collide(Vector2(-speed * delta, 0))
|
||||
sprite.rotate(-1 * delta * 2)
|
||||
|
||||
func destroy():
|
||||
queue_free()
|
29
Scripts/game.gd
Normal file
29
Scripts/game.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
extends Node
|
||||
@export var curve : Curve
|
||||
@export var toSpawn : PackedScene
|
||||
@export var lbl : Label
|
||||
var timer = 1;
|
||||
var spawn_timer = 0
|
||||
var uncertain = false
|
||||
|
||||
|
||||
func _ready():
|
||||
uncertain = get_node("/root/DataStore").read("barrel_uncertainty",false)
|
||||
get_node("/root/Scorekeeper").start_scoring()
|
||||
randomize()
|
||||
|
||||
|
||||
var stunned_tween : Tween
|
||||
|
||||
func _process(delta):
|
||||
spawn_timer += delta
|
||||
lbl.text = str(round(get_node("/root/Scorekeeper").score))
|
||||
timer = timer - delta
|
||||
|
||||
if timer <= 0:
|
||||
timer = curve.sample(min(spawn_timer/120,1))
|
||||
if uncertain:
|
||||
if randi() % 5 == 1:
|
||||
pass
|
||||
var spwn = toSpawn.instantiate()
|
||||
add_child(spwn)
|
62
Scripts/king.gd
Normal file
62
Scripts/king.gd
Normal file
|
@ -0,0 +1,62 @@
|
|||
extends CharacterBody2D
|
||||
# Behaviour Regarding the king
|
||||
|
||||
@export var speed = 250
|
||||
@export var hor_speed = 60
|
||||
@export var barrier = 600
|
||||
@export var player : AudioStreamPlayer
|
||||
var direction = 1;
|
||||
|
||||
func _ready():
|
||||
var l = get_node("/root/DataStore").read("less_stun", false)
|
||||
if l:
|
||||
stun_time = 0.3
|
||||
var r = get_node("/root/DataStore").read("more_right", false)
|
||||
if not r:
|
||||
barrier = 500
|
||||
var k = get_node("/root/DataStore").read("less_knockback", false)
|
||||
if k:
|
||||
stunned_knockback = 450
|
||||
|
||||
func _physics_process(delta):
|
||||
stunned_sprite.modulate.a = stunned_alpha
|
||||
var res = move_and_collide(
|
||||
Vector2( hor_speed * clamp( 1 -(position.x / barrier), 0, 1) * delta, direction * speed * delta) if stunned_alpha == 0 else Vector2(0,0)
|
||||
+ _stunned_knockback * delta * -1)
|
||||
|
||||
if res:
|
||||
on_knockback(res)
|
||||
|
||||
if position.x < -20:
|
||||
get_node("/root/Scorekeeper").stop_scoring()
|
||||
get_tree().change_scene_to_file("res://Scenes/DeathMenu.tscn")
|
||||
|
||||
|
||||
@export_group("Knockback Settings")
|
||||
## How long the king will be knocked back for
|
||||
@export var knockback_time : float = 0.3
|
||||
## How long the king will stay stunned after a collision
|
||||
@export var stun_time : float = 0.6
|
||||
## How much the user will be knocked back
|
||||
@export var stunned_knockback : float = 650
|
||||
## The stunned Sprite/Animation
|
||||
@export var stunned_sprite : Sprite2D
|
||||
|
||||
var stunned_alpha : float = 0
|
||||
var _stunned_knockback : Vector2 = Vector2(0,0)
|
||||
var stunned_tween : Tween
|
||||
|
||||
# Does stunning and knocking back
|
||||
func on_knockback(res):
|
||||
if res.get_collider_velocity().x !=0:
|
||||
player.play()
|
||||
#Handles the stunning and knockback over time
|
||||
stunned_tween = get_tree().create_tween();
|
||||
_stunned_knockback = Vector2(stunned_knockback,0)
|
||||
stunned_alpha = 1
|
||||
stunned_tween.parallel().tween_property(self, "_stunned_knockback", Vector2(), knockback_time)
|
||||
stunned_tween.parallel().tween_property(self, "stunned_alpha", 0, stun_time)
|
||||
#Destroys the object the king collided with
|
||||
res.get_collider().call("destroy")
|
||||
direction *= -1 #Turn around
|
||||
|
70
Scripts/player.gd
Normal file
70
Scripts/player.gd
Normal file
|
@ -0,0 +1,70 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
@export var speed : float = 10
|
||||
@export var attack : Area2D
|
||||
@export var ability : TextureProgressBar
|
||||
@export var dash_abilit : TextureProgressBar
|
||||
@export var toRotate : Sprite2D
|
||||
@export var projectile : PackedScene
|
||||
var tween : Tween
|
||||
var dash : Tween
|
||||
var dash_timer = 100
|
||||
var timer = 100
|
||||
|
||||
var attack_timer = 1
|
||||
|
||||
func _ready():
|
||||
var q = get_node("/root/DataStore").read("quick_attack",false)
|
||||
if q:
|
||||
attack_timer = 0.5
|
||||
position.x = 500
|
||||
position.y = 300
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
var mov = Input.get_vector("player_left","player_right","player_up","player_down").normalized()
|
||||
velocity = mov * speed * delta * 100
|
||||
move_and_slide()
|
||||
if position.x < 0:
|
||||
position.x = 0
|
||||
|
||||
ability.value = timer
|
||||
dash_abilit.value = dash_timer
|
||||
if Input.is_action_just_pressed("player_action") and timer == 100:
|
||||
#Attack
|
||||
attack.visible = true
|
||||
attack.monitoring = true
|
||||
var _timer = Timer.new()
|
||||
add_child(_timer)
|
||||
_timer.wait_time = 0.1
|
||||
_timer.one_shot = true
|
||||
_timer.start()
|
||||
_timer.timeout.connect(attack_end)
|
||||
|
||||
toRotate.rotation = 0
|
||||
tween = get_tree().create_tween()
|
||||
timer = 0
|
||||
tween.parallel().tween_property(self, "timer", 100, attack_timer)
|
||||
tween.parallel().tween_property(toRotate, "rotation_degrees", 90, 0.1)
|
||||
|
||||
var to_instantiate = projectile.instantiate()
|
||||
owner.add_child(to_instantiate)
|
||||
to_instantiate.position = global_position
|
||||
|
||||
if Input.is_action_just_pressed("player_dash") and dash_timer == 100:
|
||||
dash_timer = 0
|
||||
var base_speed = speed
|
||||
speed = speed * 4
|
||||
dash = get_tree().create_tween()
|
||||
dash.parallel().tween_property(self, "speed", base_speed, 0.3)
|
||||
dash.parallel().tween_property(self, "dash_timer", 100, 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func attack_end():
|
||||
attack.visible = false
|
||||
attack.monitoring = false
|
||||
|
49
Scripts/shopItem.gd
Normal file
49
Scripts/shopItem.gd
Normal file
|
@ -0,0 +1,49 @@
|
|||
@tool
|
||||
extends PanelContainer
|
||||
|
||||
@export_group("Item Variables")
|
||||
@export var id : String = "default"
|
||||
@export var cost : int = 100
|
||||
@export var title : String = "Pettable Dogs"
|
||||
@export_multiline var description : String = "Makes dogs even more pettable"
|
||||
@export var texture : Texture2D = load("res://Assets/Sprites/Common/x64.png")
|
||||
|
||||
@export_group("Intern")
|
||||
@export var item_title_label : Label
|
||||
@export var item_cost_label : Label
|
||||
@export var item_description_label : Label
|
||||
@export var item_icon : TextureRect
|
||||
@export var item_unavailable : Panel
|
||||
@export var sound : AudioStreamPlayer
|
||||
|
||||
var coins : int = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
item_icon.texture = texture
|
||||
item_title_label.text = title
|
||||
item_cost_label.text = str(cost)
|
||||
item_description_label.text = description
|
||||
try_retrieve_coins()
|
||||
if coins >= cost and not Engine.is_editor_hint():
|
||||
item_unavailable.visible = false
|
||||
if get_node("/root/DataStore").read(id, 0):
|
||||
visible = false
|
||||
|
||||
func _process(delta):
|
||||
if not Engine.is_editor_hint():
|
||||
if Input.is_action_just_pressed("player_action") and in_focus and coins >= cost:
|
||||
sound.play()
|
||||
get_node("/root/DataStore").write("coins", coins - cost)
|
||||
get_node("/root/DataStore").write(id,"1")
|
||||
get_tree().change_scene_to_file("res://Scenes/Shop.tscn")
|
||||
|
||||
func try_retrieve_coins():
|
||||
coins = get_node("/root/DataStore").read("coins", 0)
|
||||
|
||||
|
||||
var in_focus : bool = false
|
||||
func on_entered():
|
||||
in_focus = true
|
||||
func on_exited():
|
||||
in_focus = false
|
Reference in a new issue