From 74a56caf0677390b1baa8f27b96962979db997b0 Mon Sep 17 00:00:00 2001 From: bjornregnell Date: Tue, 11 Jun 2024 20:23:03 +0200 Subject: [PATCH] improve docs of BlockGame, fix Documentattion for gameloop is missing #41 --- src/main/scala/introprog/BlockGame.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/scala/introprog/BlockGame.scala b/src/main/scala/introprog/BlockGame.scala index 9b443f8..ed91703 100644 --- a/src/main/scala/introprog/BlockGame.scala +++ b/src/main/scala/introprog/BlockGame.scala @@ -2,7 +2,9 @@ package introprog import java.awt.Color -/** A class for creating games with block-based graphics. +/** A class for creating games with block-based graphics. + * See example usage in [`introprog.examples.TestBlockGame`](https://github.com/lunduniversity/introprog-scalalib/blob/master/src/main/scala/introprog/examples/TestBlockGame.scala#L7). + * * @constructor Create a new game. * @param title the title of the window * @param dim the (width, height) of the window in number of blocks @@ -84,6 +86,8 @@ abstract class BlockGame( /** The game loop that continues while not `stopWhen` is true. * It draws only updated blocks aiming at the desired frame rate. * It calls each `onXXX` method if a corresponding event is detected. + * Use the call-by-name `stopWhen` to pass a condition that ends the loop if false. + * See example usage in `introprog.examples.TestBlockGame`. */ protected def gameLoop(stopWhen: => Boolean): Unit = while !stopWhen do import PixelWindow.Event