space-vroom

A SkyRoads clone with only one boring "level" written in Godot Engine version 3.
git clone https://kaka.farm/~git/spacevroom
Log | Files | Refs | LICENSE

Level1.gd (1542B)


      1 extends Spatial
      2 
      3 
      4 # Space Vroom, an unoriginal space racer.
      5 # Copyright (C) 2021  Yuval Langer
      6 #
      7 # This program is free software: you can redistribute it and/or modify
      8 # it under the terms of the GNU Affero General Public License as
      9 # published by the Free Software Foundation, either version 3 of the
     10 # License, or (at your option) any later version.
     11 #
     12 # This program is distributed in the hope that it will be useful,
     13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 # GNU Affero General Public License for more details.
     16 #
     17 # You should have received a copy of the GNU Affero General Public License
     18 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     19 
     20 
     21 onready var boxes := $Boxes
     22 
     23 
     24 func _ready() -> void:
     25 	var level_text_file: File = File.new()
     26 	var file_open_error := level_text_file.open("res://level1.txt", File.READ)
     27 	if file_open_error:
     28 		push_error("Level open error: %s" % file_open_error)
     29 	var level_text := level_text_file.get_as_text()
     30 	level_text_file.close()
     31 	var loaded_boxes := LevelLoader.load_level(level_text)
     32 	boxes.add_child(loaded_boxes)
     33 
     34 
     35 func _input(event: InputEvent) -> void:
     36 	if event.is_action("quit_level"):
     37 		get_tree().change_scene("res://LevelSelection.tscn")
     38 	if event.is_action("reset_level"):
     39 		get_tree().reload_current_scene()
     40 
     41 
     42 func _on_Player_off_the_deep_end() -> void:
     43 	get_tree().reload_current_scene()
     44 
     45 
     46 func _on_Player_reached_goal() -> void:
     47 	get_tree().change_scene("res://LevelSelection.tscn")