Skip to content

Commit

Permalink
Properly reset intro after restarting.
Browse files Browse the repository at this point in the history
  • Loading branch information
immortalx74 committed Aug 25, 2024
1 parent 1e4d164 commit c1b50c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ METRICS = {
BALL_SPEED_NORMAL = 2.8,
BALL_SPEED_SLOW = 1.8,

DOH_STRENGTH = 4
DOH_STRENGTH = 15
}

obj_arkanoid_logo = nil
Expand Down
1 change: 1 addition & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function lovr.update( dt )
if level_intro_timer:get_elapsed() > 3 then
local ball = gameobject( vec3( -0.8, 1.6, -1 ), ASSET_TYPE.BALL )
player.flashing_timer:start()
level_intro_timer:stop()
game_state = GAME_STATE.PLAY
end
elseif game_state == GAME_STATE.PLAY then
Expand Down
10 changes: 9 additions & 1 deletion typewriter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function typewriter:new( text, position, interval, auto_start )
obj.interval = interval
obj.cursor = 1
obj.started = auto_start or false
obj.timer = timer( auto_start)
obj.timer = timer( auto_start )
obj.finished = false
return obj
end
Expand All @@ -23,6 +23,14 @@ function typewriter:start()
self.timer:start()
end

function typewriter:reset()
self.started = false
self.timer:stop()
self.text_writer = ""
self.cursor = 1
self.finished = false
end

function typewriter:has_finished()
return self.finished
end
Expand Down
27 changes: 25 additions & 2 deletions util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ function util.create_start_screen()
player.score = 0
player.doh_hits = 0
powerup.timer:stop()
phrases_intro.idx = 1
phrases_ending.idx = 1
phrases_intro.between_timer:stop()
phrases_intro.last_timer:stop()
phrases_ending.between_timer:stop()
phrases_ending.last_timer:stop()
for i, v in ipairs( phrases_intro ) do
v:reset()
if i == 1 then
v:start()
end
end

for i, v in ipairs( phrases_ending ) do
v:reset()
if i == 1 then
v:start()
end
end

obj_arkanoid_logo = gameobject( vec3( 0, 2, -2 ), ASSET_TYPE.ARKANOID_LOGO )
obj_taito_logo = gameobject( vec3( 0, 0.65, -2 ), ASSET_TYPE.TAITO_LOGO )
Expand Down Expand Up @@ -198,7 +217,11 @@ function util.create_mothership_intro( hand, invincible )
obj_enemy_ship = gameobject( vec3( 0, -0.8, -3 ), ASSET_TYPE.ENEMY_SHIP )
obj_enemy_laser_beam = gameobject( vec3( 0, -0.8, -3 ), ASSET_TYPE.ENEMY_LASER_BEAM )
obj_paddle_escape = gameobject( vec3( 0, -0.87, -3 ), ASSET_TYPE.PADDLE_ESCAPE )
enemy_ship_timer = timer( true )
if not enemy_ship_timer then
enemy_ship_timer = timer( true )
else
enemy_ship_timer:start()
end

assets[ ASSET_TYPE.SND_MOTHERSHIP_INTRO ]:stop()
assets[ ASSET_TYPE.SND_MOTHERSHIP_INTRO ]:play()
Expand All @@ -208,7 +231,7 @@ end

function util.create_ending()
gameobject.destroy_all()

obj_mothership = gameobject( vec3( 0, -0.8, -3 ), ASSET_TYPE.MOTHERSHIP )
obj_mothership.pose:rotate( -0.8, 0, 1, 0 )

Expand Down

0 comments on commit c1b50c8

Please sign in to comment.