Files
functional-programming-snake/scala/src/pong/View.scala
T

18 lines
765 B
Scala

package snake
package pong
import PongModel.*
/** m11 pong view: the same Scene shapes as the snake view, so the same drawScene and runtime draw it. */
object PongView:
/**
* Describe the match as shapes, drawn in order (all text is "#ffffff", align "center"):
* background `Rect(0, 0, 640, 400, "#111111")`; the player paddle `Rect(PLAYER_X*8, player*8, 8, 64, "#ffffff")`,
* then the cpu paddle the same way at CPU_X; the ball `Rect(x*8, y*8, 8, 8, "#ffeb3b")`;
* the score `Text(320, 30, "<player> <cpu>" (three spaces), size 24)`.
* When Over: `Text(320, 200, "You Win!" if the player has more points, else "CPU Wins", size 32)` and
* `Text(320, 230, "Press R to restart", size 16)`.
*/
def pongView(state: PongState): Scene = ???