From b6a33d017f718659a5b21f2d80b8c706d4ee28be Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 15 Sep 2025 08:47:18 +0200 Subject: [PATCH] feat: show score and increment when lines are cleared --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4f1e61d..8b4ad71 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "image/color" "tetris/assets" @@ -16,6 +17,7 @@ import ( var ( shape game.Shape shape_pos core.Vec2i8 + score game.Score dropTimer = core.NewIntervalTimer(0.3) moveTimer = core.NewIntervalTimer(0.1) grid = game.Grid{} @@ -82,7 +84,7 @@ func Update(delta float32) { // Update position if it does not collide if game.CheckShapeCollision(new_pos, &shape, &grid) { LockShape() - grid.ClearFullRows() + score.Lines(grid.ClearFullRows()) SpawnShape() } else { shape_pos = new_pos @@ -96,7 +98,7 @@ func Render() { draw.DrawShape(rl.NewVector2(25, 25), shape_pos, shape) r.DrawFrame(rl.RectangleInt32{X: 400, Y: 25, Width: 250, Height: 100}) r.DrawHeaderText(410, 30, "Score") - r.DrawText(410, 65, "999999") + r.DrawText(410, 65, fmt.Sprintf("%.7d", score)) r.DrawFrame(rl.RectangleInt32{X: 400, Y: 150, Width: 250, Height: 200}) render.End() }