Repository navigation
Scene map_system code structure
ZachNalepa edited this page Nov 8, 2023
·
6 revisions
- var current_map : str
- class variable storing the name of the current map
- used in conjunction with the available_maps dictionary to retrieve map files
- map files have a stored variable for the next room, to retrieve, use current_map.nextRoom
- var available_maps : dictionary
- dictionary of n length storing map name and absolute file path
- this dictionary can be appended to like any other dictionary
- note that specific maps are referenced in map files, so maps should not be removed
- var num_enemies : int
- count of number of alive enemies
- count is instantiated in transition()
- count is reduced when an enemy is defeated and removed from the scene tree
- var enemy_array : array
- enemy array to keep track of enemy instances for runtime changes
- enemy instances can be referenced for despawn
- every enemy has a unique id, simply by using the id as an index in the array, an enemy can be referenced
- var player_dead : bool
- boolean to keep track of if the player had died or not
- var main : tree
- variable storing the scene tree and child nodes
- this variable can be used to reference other nodes and scenes in the tree
- var player_instance : node
- instance of the player to be added to the scene tree during transition
- similar to enemy instances, the player instance may be changed at runtime or de-instanced
- transition(nextRoom:str)
- method to change rooms either during instantiation or when the player leaves the current room
- this method returns nothing, rather de-instances the current room and instantiates a new room scene
- nextRoom corresponds to a filepath in the available_rooms dictionary
- transition_current()
- method to re-instance the current room and restart
- similar to transition(nextRoom:str), except no arguments are taken
- the method uses the current_map variable to reference the dictionary instead of being passed a name
- spawn_enemies()
- method to spawn enemies, all relevant data is stored in map files
- this method employs a loop to spawn an enemy count corresponding to the num_enemies variable
- enemies are instanced and placed in the enemy_array for referencing in runtime