this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

simplify start image draw

voigt.tngl.sh 086b1e26 01a0a966

verified
+7 -40
+2
README.md
··· 25 25 - [x] Toggle Save Block 26 26 - [x] Make Column/Row count configurable, this allows for way bigger playing fields 27 27 - [x] Add modern multiplayer, where you have to clear the game together 28 + - [x] Config persistence 28 29 - [ ] Toggle T-Spins 29 30 - [ ] Points for perfect clears 31 + - [ ] Scoreboard/Leaderboard 30 32 - [ ] Add classic Tetris multiplayer (deleted rows will be a penalty for the opponent)
+5 -40
screen_start.go
··· 15 15 } 16 16 17 17 type StartScreen struct { 18 - SplashImage ff.Image 19 - currentFrame int 20 - frameCounter int 21 - totalFrames int 22 - framesPerSprite int 23 - spriteWidth int 24 - spriteHeight int 18 + SplashImage ff.Image 19 + spriteWidth int 25 20 26 21 // Menu 27 22 MenuList []MenuItem ··· 38 33 } 39 34 40 35 func (ss *StartScreen) OnEnter() { 41 - // Configuration for the sprite animation 42 - ss.totalFrames = 1 // 4 sprites in the sheet 43 - ss.framesPerSprite = 30 // Change sprite every 60 frames 44 - ss.currentFrame = 0 45 - ss.frameCounter = 0 46 36 47 37 // Load once; reuse the allocation on subsequent OnEnter calls. 48 38 if ss.spriteWidth == 0 { 49 39 ss.SplashImage = ff.LoadFile("start", nil).Image() 50 - ss.spriteWidth = ss.SplashImage.Width() / ss.totalFrames 51 - ss.spriteHeight = ss.SplashImage.Height() 40 + ss.spriteWidth = ss.SplashImage.Width() 52 41 } 53 42 54 43 // Menu setup ··· 75 64 } 76 65 77 66 func (ss *StartScreen) OnExit() { 78 - ss.currentFrame = 0 79 - ss.frameCounter = 0 80 - ss.totalFrames = 0 81 - ss.framesPerSprite = 0 82 67 ss.MenuList = nil 83 68 ss.MenuListState = 0 84 69 ss.maxTextWidthInList = 0 ··· 90 75 } 91 76 92 77 func (ss *StartScreen) Draw() { 93 - // Calculate which sprite to show based on frame counter 94 - spriteIndex := (ss.frameCounter / ss.framesPerSprite) % ss.totalFrames 95 - 96 - // Calculate the position to extract the sprite from the sheet 97 - spriteX := spriteIndex * ss.spriteWidth 98 - spriteY := 0 99 - 100 - // Create a sub-image for the current sprite 101 - subImage := ss.SplashImage.Sub( 102 - ff.Point{X: spriteX, Y: spriteY}, 103 - ff.Size{W: ss.spriteWidth, H: ss.spriteHeight}, 104 - ) 105 - 106 - // Center the sprite on screen 107 - centerX := (ff.Width - ss.spriteWidth) / 2 108 - centerY := (ff.Height-ss.spriteHeight)/2 - 10 109 - 110 - // Draw the current sprite frame 111 - ff.DrawSubImage(subImage, ff.Point{X: centerX, Y: centerY}) 78 + ff.DrawImage(ss.SplashImage, ff.Point{X: 0, Y: 0}) 112 79 113 80 // Draw commit hash at bottom-left 114 81 ff.DrawText(versionText, VERSIONFONT, ff.Point{X: 3, Y: ff.Height - 5}, ff.ColorLightGray) ··· 117 84 ff.DrawRect( 118 85 ff.P((ff.Width/2)-5, ff.Height/4+25), 119 86 ff.S(60, 40), 120 - ff.Style{ff.ColorWhite, ff.ColorNone, 1}, 87 + ff.Style{FillColor: ff.ColorWhite, StrokeColor: ff.ColorNone, StrokeWidth: 1}, 121 88 ) 122 89 123 90 // Draw Menu ··· 234 201 } 235 202 236 203 func (ss *StartScreen) Update() { 237 - // Increment frame counter for animation 238 - ss.frameCounter++ 239 204 ss.HandleInput() 240 205 } 241 206