forked from team-sg/hero-mark-2
game.gd cleaning and partial results screen implementation
This commit is contained in:
parent
b126484109
commit
e2b3db0b93
16 changed files with 425 additions and 436 deletions
|
@ -38,9 +38,9 @@ func _physics_process(delta):
|
|||
if not nodes.empty():
|
||||
var player = nodes[0]
|
||||
var mouse_position = SceneManager.viewport.get_mouse_position() / SceneManager.viewport_container.rect_scale
|
||||
mouse_position.x = clamp(mouse_position.x, 8.0, Game.resolution.x - 8.0)
|
||||
mouse_position.y = clamp(mouse_position.y, 8.0, Game.resolution.y - 8.0)
|
||||
var world_position = mouse_position + Game.current_sector * Game.resolution
|
||||
mouse_position.x = clamp(mouse_position.x, 8.0, Game.RESOLUTION.x - 8.0)
|
||||
mouse_position.y = clamp(mouse_position.y, 8.0, Game.RESOLUTION.y - 8.0)
|
||||
var world_position = mouse_position + Game.current_sector * Game.RESOLUTION
|
||||
player.position = world_position
|
||||
|
||||
# Game.get_map().get_node("Player").position = get_viewport().get_mouse_position()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extends Node
|
||||
|
||||
|
||||
## difficulty levels
|
||||
enum Difficulty {
|
||||
SWEET, # slower enemies, infinite lives
|
||||
SALTY, # normal enemies, infinite lives
|
||||
|
@ -7,51 +9,57 @@ enum Difficulty {
|
|||
PUNGENT, # faster enemies, 3 lives
|
||||
}
|
||||
|
||||
enum Bonuses {
|
||||
Collection_Bonus,
|
||||
Time_Bonus,
|
||||
Life_Bonus,
|
||||
Perfect_Bonus
|
||||
}
|
||||
|
||||
const DIFFICULTY_NAMES = ["Sweet","Salty","Spicy","Pungent"]
|
||||
## resolution the game renders at
|
||||
const RESOLUTION := Vector2(256,192)
|
||||
const DIFFICULTY_NAMES := ["Sweet","Salty","Spicy","Pungent"]
|
||||
|
||||
var resolution = Vector2(256,192)
|
||||
var current_sector = Vector2(0,0)
|
||||
#Onreadys
|
||||
#Collectibles
|
||||
var keys = 0
|
||||
var stars = [false,false,false,false,false]
|
||||
var shards = 0
|
||||
var arrows = 0
|
||||
var score = 0
|
||||
var final_score = 0
|
||||
var high_score = 0
|
||||
var bonuses = [0,0,0,0]
|
||||
var lives = 2
|
||||
var deaths = 0
|
||||
var time = 0.0
|
||||
#Objects
|
||||
const block_text = preload("res://objects/hud/blocktext.tscn")
|
||||
const pause_screen = preload("res://objects/hud/pause_screen.tscn")
|
||||
#Game info
|
||||
var respawn_point = Vector2(32,166) #Respawn point
|
||||
var current_level = 0 #Current level being played
|
||||
var current_file = 1 #Current save file
|
||||
var shards_collected = [false,false,false,false,false,false,false,false,false,false]
|
||||
var is_marathon_mode = false
|
||||
|
||||
#== collectibles ==#
|
||||
var keys: int = 0 # collected keys
|
||||
## which stars are collected
|
||||
var stars_collected := [false,false,false,false,false]
|
||||
var stars : int setget , _get_stars # total stars
|
||||
## which stars are collected
|
||||
var shards_collected := [false,false,false,false,false,false,false,false]
|
||||
## how many shards collected
|
||||
var shards: int setget , _get_shards # total shards
|
||||
var arrows: int = 0 # current arrows
|
||||
#== stats ==#
|
||||
var lives: int = 2
|
||||
var deaths: int = 0
|
||||
var time: float = 0.0
|
||||
#== score ==#
|
||||
var score: int = 0
|
||||
var collection_bonus: int = 0
|
||||
var time_bonus: int = 0
|
||||
var life_bonus: int = 0
|
||||
var perfect_bonus: int = 0
|
||||
var final_score: int = 0
|
||||
#== state ==#
|
||||
var current_sector := Vector2.ZERO
|
||||
var respawn_point := Vector2(32,166)
|
||||
var current_level: int = 0
|
||||
var difficulty: int = Difficulty.SPICY setget _set_difficulty
|
||||
var enemy_speed_factor: float = 1.0 # multiplier of enemy speed
|
||||
var is_easy_mode = false # whether to do easy-specific behaviors
|
||||
var easy_mode_speed_factor = 0.75 # DEPRECATED: speed enemies go in easy mode
|
||||
var use_lives = false
|
||||
var can_pause = true
|
||||
var current_palette = "default"
|
||||
var is_easy_mode: bool = false # whether to do easy-specific behaviors
|
||||
var use_lives: bool = false
|
||||
var can_pause: bool = true
|
||||
var current_palette: String = "default"
|
||||
|
||||
|
||||
func _ready():
|
||||
pause_mode = Node.PAUSE_MODE_PROCESS
|
||||
|
||||
|
||||
func _get_stars() -> int:
|
||||
return stars_collected.count(true)
|
||||
|
||||
|
||||
func _get_shards() -> int:
|
||||
return shards_collected.count(true)
|
||||
|
||||
|
||||
# stuff to change when setting difficulty
|
||||
func _set_difficulty(value: int) -> void:
|
||||
difficulty = value
|
||||
|
@ -81,14 +89,50 @@ func instance_node(node:PackedScene,x:float,y:float,parent):
|
|||
|
||||
#Get position in sectors
|
||||
func get_sector(pos):
|
||||
return (pos / resolution).floor()
|
||||
return (pos / RESOLUTION).floor()
|
||||
|
||||
#Return the current Map
|
||||
func get_map():
|
||||
return get_tree().get_nodes_in_group("map")[0]
|
||||
|
||||
|
||||
## tally up scores
|
||||
func tally_scores() -> void:
|
||||
var map = get_map()
|
||||
# collection bonus
|
||||
if keys >= 50:
|
||||
collection_bonus += 500
|
||||
if keys >= 5:
|
||||
collection_bonus += 500
|
||||
# 100% collection
|
||||
if keys >= 50 and shards >= 5:
|
||||
collection_bonus += 250
|
||||
shards_collected[5] = true
|
||||
# 100% time bonus
|
||||
if time < map.target_time_100:
|
||||
time_bonus = max(2500 - 2500 * int(time / map.target_time_100), 0)
|
||||
shards_collected[6] = true
|
||||
else:
|
||||
# any% time bonus
|
||||
if time < map.target_time_any:
|
||||
time_bonus = max(2500 - 2500 * int(time / map.target_time_any), 0)
|
||||
shards_collected[6] = true
|
||||
# life bonus
|
||||
if deaths == 0:
|
||||
life_bonus = 500
|
||||
shards_collected[7] = true
|
||||
elif deaths == 1:
|
||||
life_bonus = 1500
|
||||
# perfect bonus
|
||||
if shards_collected[5] and shards_collected[6] and shards_collected[7]:
|
||||
perfect_bonus += 1000
|
||||
# final score
|
||||
final_score = score + collection_bonus + time_bonus + life_bonus + perfect_bonus
|
||||
Game.save()
|
||||
|
||||
|
||||
#Go to new map
|
||||
func change_map(map: PackedScene):
|
||||
func change_map(map: PackedScene) -> void:
|
||||
get_tree().paused = true
|
||||
can_pause = false
|
||||
Fade.fade_out(0.4)
|
||||
|
@ -105,15 +149,21 @@ func change_map(map: PackedScene):
|
|||
SceneManager.current_scene = map.instance()
|
||||
|
||||
#Clear data
|
||||
func clear_collectibles():
|
||||
score = 0
|
||||
func clear_collectibles() -> void:
|
||||
# collectibles
|
||||
keys = 0
|
||||
stars = [false,false,false,false,false]
|
||||
shards = 0
|
||||
shards_collected = [false,false,false,false,false,false,false,false,false,false]
|
||||
stars_collected.fill(false)
|
||||
shards_collected.fill(false)
|
||||
arrows = 0
|
||||
lives = 2
|
||||
deaths = 0
|
||||
# score
|
||||
score = 0
|
||||
collection_bonus = 0
|
||||
time_bonus = 0
|
||||
life_bonus = 0
|
||||
perfect_bonus = 0
|
||||
final_score = 0
|
||||
|
||||
#Save
|
||||
func save():
|
||||
|
@ -126,7 +176,7 @@ func save():
|
|||
save_data.score_100 = max(save_data.score_100, final_score)
|
||||
save_data.time_100 = min(save_data.time_100, time)
|
||||
else:
|
||||
save_data.score_any = max(save_data.score_100, final_score)
|
||||
save_data.score_any = max(save_data.score_any, final_score)
|
||||
save_data.time_any = min(save_data.time_any, time)
|
||||
|
||||
# set shards
|
||||
|
@ -158,11 +208,10 @@ func timeify(input):
|
|||
|
||||
#Restart level
|
||||
func restart_level():
|
||||
if score > high_score: high_score = score
|
||||
score = 0
|
||||
keys = 0
|
||||
stars = [false,false,false,false,false]
|
||||
shards = 0
|
||||
stars_collected.fill(false)
|
||||
shards_collected.fill(false)
|
||||
arrows = 0
|
||||
lives = 2
|
||||
Audio.ac_climb.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue