Skip to content

Commit

Permalink
Better implementation of speed_ratio and new exit inputs
Browse files Browse the repository at this point in the history
Add working exit inputs to the menu
speed_ratio is now a global variabl in config.gd
Changed some little key assignments
@bojidar-bg : added back this FUCKING EMPTY LINE
:cat2:
:cat2:
:cat2:
  • Loading branch information
ObaniGemini committed May 30, 2017
1 parent 024b230 commit f726e3f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
6 changes: 3 additions & 3 deletions engine.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version_build=""

[autoload]

config="res://shared/config.gd"
config="*res://shared/config.gd"
SaveManager="*res://shared/save_manager.gd"
ScreenManager="*res://shared/screen_manager.gd"
ScenesManager="*res://shared/scenes_manager.gd"
Expand All @@ -41,12 +41,12 @@ gen_mipmaps=true

[input]

retry=[key(R), jbutton(0, 10), key(F1)]
exit=[key(Escape), jbutton(0, 11)]
btn_right=[key(Right), key(D), jbutton(0, 15), jaxis(0, 1)]
btn_left=[key(Left), key(A), jbutton(0, 14), jaxis(0, 0)]
btn_down=[key(Down), key(S), jbutton(0, 13), jaxis(0, 3)]
btn_up=[key(Up), key(W), jbutton(0, 12), jaxis(0, 2)]
retry=[key(R), jbutton(0, 10)]
to_menu=[key(M), jbutton(0, 11)]
next_level=[key(N), jbutton(0, 2)]
btn_space=[key(Space), jbutton(0, 0)]
place_bomb=[key(Space), jbutton(0, 0)]
Expand Down
4 changes: 1 addition & 3 deletions entities/entity.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ var wait_frames = 3
var push_direction = ""
var enabled = true

var speed_ratio = 1

onready var tilemap = get_node(tilemap_path)
onready var level_holder = get_node(level_holder_path)
onready var positional_audio = get_node("positional_audio")
Expand Down Expand Up @@ -93,7 +91,7 @@ func _fixed_process(delta):
if ray_status.has(movement_check_collision) and ray_status[movement_check_collision] != null and ray_status[movement_check_collision].get("speed_multiplier") != null:
speed_multiplier = min(speed_multiplier, ray_status[movement_check_collision].speed_multiplier)

var speed = movement_speed * delta * speed_multiplier * speed_ratio
var speed = movement_speed * delta * speed_multiplier * config.speed_ratio
if movement.length_squared() > speed.length_squared():
speed = speed * movement.normalized()
movement -= speed
Expand Down
19 changes: 7 additions & 12 deletions main/gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const GOAL_TYPES = ["box", "flower", "artefact"]

var allow_next_level = false
var popup_running = false
var speed = 1

onready var timer = get_node("timer")
onready var popup = get_node("popup")
Expand Down Expand Up @@ -50,11 +49,11 @@ func _ready():
set_process_input(true)

func _input(event):
if event.is_action("retry") && event.is_pressed() && !event.is_echo():
if event.is_action_pressed("retry"):
popup_button_pressed("retry")
if event.is_action("next_level") && event.is_pressed() && !event.is_echo():
if event.is_action_pressed("next_level"):
popup_button_pressed("next")
if event.is_action("to_menu") && event.is_pressed() && !event.is_echo():
if event.is_action_pressed("exit"):
popup_button_pressed("menu")

func update_counters():
Expand Down Expand Up @@ -115,10 +114,11 @@ func popup_button_pressed(name): # Actions for different popup buttons
var toggled = get_node("top_left_buttons/look").is_pressed()
lookaround.set_enabled(toggled)
elif name == "speed":
speed *= 2
var speed = config.speed_ratio*2
if speed > 4:
speed = 1
update_speed(speed)
config.speed_ratio = speed
get_node("top_left_buttons/speed/text").set_text(str("x", str(config.speed_ratio)))
if name == "retry":
check_hide_popup()
level_holder.retry_level()
Expand All @@ -130,6 +130,7 @@ func popup_button_pressed(name): # Actions for different popup buttons
else:
return
elif name == "menu":
get_tree().set_pause(false)
ScenesManager.load_scene("res://menu/menu.tscn")

func check_hide_popup():
Expand All @@ -141,9 +142,3 @@ func check_hide_popup():
func hide_popup(): # Hide the popup
popup_running = false
popup.hide()

func update_speed(value):
get_node("../player_holder/player").speed_ratio = value
get_node("../level_holder").update_speed_values(value)
get_node("top_left_buttons/speed/text").set_text(str("x", str(value)))
speed = value
7 changes: 1 addition & 6 deletions main/level_holder.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ onready var player = get_node("../player_holder/player")
onready var raw_packs = FileManager.get_file_lines("res://levels/packs.txt")

func _ready():
config.speed_ratio = 1
set_process(true)
get_node("/root").connect("size_changed",self,"window_resize")

Expand Down Expand Up @@ -89,7 +90,6 @@ func load_level(pack, level): # Load level from pack
while(tilemap.get_cell(tile_map_acid_x_end, tile_map_acid_y) == 2 && tile_map_acid_x_end < 3000):
tile_map_acid_x_end += 1

get_node("../gui").update_speed(1)
window_resize()

func window_resize():
Expand Down Expand Up @@ -170,8 +170,3 @@ func retry_level(): # Retry the current level

func next_level(): # Go to the next level
load_level(current_pack, int(current_level) + 1)

func update_speed_values(speed):
for node in get_child(0).get_children():
if node extends preload("res://entities/entity.gd"):
node.speed_ratio = speed
11 changes: 5 additions & 6 deletions main/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ __meta__ = {
[node name="gui" type="CanvasLayer" parent="."]

process/pause_mode = 2
editor/display_folded = true
layer = 0
offset = Vector2( 0, 0 )
rotation = 0.0
Expand Down Expand Up @@ -1028,9 +1027,9 @@ focus/ignore_mouse = false
focus/stop_mouse = false
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 824.0
margin/left = 854.0
margin/top = 0.0
margin/right = 924.0
margin/right = 954.0
margin/bottom = 100.0
toggle_mode = true
enabled_focus_mode = 2
Expand All @@ -1045,9 +1044,9 @@ focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 924.0
margin/left = 954.0
margin/top = 0.0
margin/right = 1024.0
margin/right = 1054.0
margin/bottom = 100.0
toggle_mode = false
enabled_focus_mode = 2
Expand All @@ -1067,7 +1066,7 @@ modulate = Color( 0.5, 0.8, 1, 1 )
[node name="backdrop1" type="Sprite" parent="gui/top_left_buttons"]

visibility/behind_parent = true
transform/pos = Vector2( 824, 0 )
transform/pos = Vector2( 854, 0 )
transform/scale = Vector2( 100, 50 )
texture = ExtResource( 22 )
centered = false
Expand Down
9 changes: 8 additions & 1 deletion menu/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ onready var credits = get_node("credits")
onready var tween = get_node("tween")

func _ready():
get_tree().set_pause(false)
# Main menu buttons
for node in get_node("main/buttons").get_children():
if node extends BaseButton:
Expand Down Expand Up @@ -41,8 +40,16 @@ func _ready():

# Prepare to move thing when the aspect ratio changes
connect("resized", self, "reposition_screens")
set_process_input(true)
reposition_screens()

func _input(event):
if event.is_action_pressed("exit"):
if current_screen == "start":
get_tree().quit()
else:
go_to_target("start", true)

func reposition_screens():
var size = get_size()

Expand Down
2 changes: 2 additions & 0 deletions shared/config.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

extends Node

var speed_ratio = 1

func _ready():
# Seed the random generator
randomize()
Expand Down

0 comments on commit f726e3f

Please sign in to comment.