Commits

Flaise  committed a268702

Fixed the crashing bug that happens when the player restarts while the
question mark is visible.

  • Participants
  • Parent commits 2d61f6b

Comments (0)

Files changed (1)

File squishthebugs/main.py

 	return remove
 
 def on_event_once(predicate, callback):
-	stop = on_event(predicate, lambda a: (callback(a), stop()))
+	stop = on_event(predicate, lambda a: (stop(), callback(a)))
 
 
 def render_text(text, position, anchor, dest_surface, font, color_fill, color_outline):
 	
 	def on_fail():
 		bubble = make_block(block[0], tile_speech, BlockType.SPEECH)
-		on_event_once(lambda a: a.type == AppEvent.INPUT_DIRECTION, lambda a: remove_block(bubble))
+		question = make_block(block[0], tile_question, BlockType.SPEECH)
 		
-		question = make_block(block[0], tile_question, BlockType.SPEECH)
-		on_event_once(lambda a: a.type == AppEvent.INPUT_DIRECTION, lambda a: remove_block(question))
+		def remove(event):
+			if event.type == AppEvent.RESTART:
+				return
+			remove_block(bubble)
+			remove_block(question)
+		on_event_once(lambda a: a.type == AppEvent.INPUT_DIRECTION or a.type == AppEvent.RESTART, remove)
 	
 	dest = sum3d(block[0], delta)
 	above = sum3d(dest, (0, 1, 0))