Skip to content

Commit

Permalink
reinitializes scene when respawning or switching scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
mswieboda committed Sep 18, 2019
1 parent d5c73d1 commit 84e5ce5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/buzzle/scene_manager.cr
Expand Up @@ -7,11 +7,13 @@ module Buzzle
def initialize(@player : Player)
@scene_index = 0

@scenes = [] of Scene
@scenes << Scenes::Scene1.new(@player)
@scenes << Scenes::Playground.new(@player)
@scenes = [] of Scene.class
@scenes << Scenes::Scene1
@scenes << Scenes::Playground

@scene = @scenes[0]
puts @scenes.class

@scene = @scenes[0].new(@player)

@respawn_timer = Timer.new(RESPAWN_TIMER)
end
Expand All @@ -24,7 +26,8 @@ module Buzzle

if @respawn_timer.done?
@respawn_timer.reset
respawn
@player.revive
@scene.initialize(@player)
end
end

Expand All @@ -44,12 +47,7 @@ module Buzzle
end

@scene.unload
@scene = @scenes[@scene_index]
end

def respawn
@player.revive
@scene.load
@scene = @scenes[@scene_index].new(@player)
end
end
end

0 comments on commit 84e5ce5

Please sign in to comment.