Skip to content

Commit 379613d

Browse files
authored
Merge pull request #78 from sam-mfb/fuel-bug
Fix fuel not resetting when dying at end of level
2 parents e36561d + a2b0bfa commit 379613d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/game/levelThunks.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ export const loadLevel =
144144
const shipScreenX = SCRWTH / 2
145145
const shipScreenY = Math.floor((TOPMARG + BOTMARG) / 2)
146146

147+
// Check if ship was dead before loading new level
148+
// If so, we need to reset fuel (fixes bug where dying at end of level doesn't reset fuel)
149+
state = _getState()
150+
const wasShipDead = state.ship.deadCount > 0
151+
147152
dispatch(
148153
shipSlice.actions.initShip({
149154
x: shipScreenX,
150155
y: shipScreenY,
151156
globalx: planet.xstart,
152-
globaly: planet.ystart
157+
globaly: planet.ystart,
158+
resetFuel: wasShipDead // Reset fuel if ship was dead during level transition
153159
})
154160
)
155161

0 commit comments

Comments
 (0)