Compare commits
No commits in common. "9b11f3b2200983d36dff0e0d5ef18619e608619d" and "53ac3840baf207b5c983535a3fbf69a11f4b7a52" have entirely different histories.
9b11f3b220
...
53ac3840ba
3 changed files with 6 additions and 70 deletions
|
|
@ -1,14 +0,0 @@
|
|||
package assets
|
||||
|
||||
const (
|
||||
LOGO_STRIDE = 20
|
||||
LOGO_HEIGHT = 5
|
||||
)
|
||||
|
||||
var Logo = [LOGO_HEIGHT * LOGO_STRIDE]byte{
|
||||
1, 1, 1, 0, 2, 2, 0, 3, 3, 3, 0, 4, 4, 0, 0, 5, 0, 6, 6, 6,
|
||||
0, 1, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 4, 0, 5, 0, 6, 0, 0,
|
||||
0, 1, 0, 0, 2, 2, 0, 0, 3, 0, 0, 4, 4, 0, 0, 5, 0, 0, 6, 0,
|
||||
0, 1, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 4, 0, 5, 0, 0, 0, 6,
|
||||
0, 1, 0, 0, 2, 2, 0, 0, 3, 0, 0, 4, 0, 4, 0, 5, 0, 6, 6, 6,
|
||||
}
|
||||
|
|
@ -1,45 +1,25 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"tetris/assets"
|
||||
"tetris/engine/audio"
|
||||
"tetris/engine/core"
|
||||
"tetris/engine/render"
|
||||
"tetris/game/state"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
type GameOver struct {
|
||||
blinkTimer core.IntervalTimer
|
||||
textColor color.RGBA
|
||||
}
|
||||
type GameOver struct{}
|
||||
|
||||
func (GameOver *GameOver) Enter() {
|
||||
func (GameOver) Enter() {
|
||||
audio.Play(assets.SFX_GAME_OVER)
|
||||
GameOver.blinkTimer = core.NewIntervalTimer(0.2)
|
||||
GameOver.textColor = rl.White
|
||||
}
|
||||
|
||||
func (GameOver) Exit() {
|
||||
}
|
||||
|
||||
func (GameOver) soundDone() bool {
|
||||
return !audio.IsPlaying(assets.SFX_GAME_OVER)
|
||||
}
|
||||
|
||||
func (GameOver *GameOver) Update(fsm state.Transitioner, delta float32) {
|
||||
if GameOver.blinkTimer.UpdateReset(delta) {
|
||||
if GameOver.textColor == rl.Red {
|
||||
GameOver.textColor = rl.White
|
||||
} else {
|
||||
GameOver.textColor = rl.Red
|
||||
}
|
||||
}
|
||||
|
||||
if GameOver.soundDone() {
|
||||
func (GameOver GameOver) Update(fsm state.Transitioner, delta float32) {
|
||||
if !audio.IsPlaying(assets.SFX_GAME_OVER) {
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
fsm.Switch("gameplay")
|
||||
} else if rl.IsKeyPressed(rl.KeyQ) {
|
||||
|
|
@ -48,12 +28,8 @@ func (GameOver *GameOver) Update(fsm state.Transitioner, delta float32) {
|
|||
}
|
||||
}
|
||||
|
||||
func (GameOver GameOver) Render() {
|
||||
func (GameOver *GameOver) Render() {
|
||||
render.Begin(rl.Black)
|
||||
render.DrawTextCenter(340, 200, 32, "Game Over", GameOver.textColor)
|
||||
if GameOver.soundDone() {
|
||||
render.DrawTextCenter(340, 290, 16, "Press ENTER to restart", rl.White)
|
||||
render.DrawTextCenter(340, 316, 16, "Press Q to return to menu", rl.White)
|
||||
}
|
||||
render.DrawTextCenter(340, 200, 32, "Game Over", rl.White)
|
||||
render.End()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"tetris/assets"
|
||||
"tetris/engine/audio"
|
||||
"tetris/engine/render"
|
||||
"tetris/game"
|
||||
"tetris/game/state"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
|
|
@ -54,33 +53,8 @@ func (menu *Menu) Update(fsm state.Transitioner, delta float32) {
|
|||
}
|
||||
}
|
||||
|
||||
func (Menu) renderLogo(offset_x, offset_y int32) {
|
||||
for y := range assets.LOGO_HEIGHT {
|
||||
for x := range assets.LOGO_STRIDE {
|
||||
index := assets.Logo[x+(y*assets.LOGO_STRIDE)]
|
||||
block := game.Block(index)
|
||||
|
||||
if block == game.BLOCK_EMPTY {
|
||||
continue
|
||||
}
|
||||
|
||||
src := block.Tile().GetTexRect()
|
||||
|
||||
render.DrawTextureRec(src, rl.Rectangle{
|
||||
X: float32(offset_x) + (float32(x) * src.Width * 2),
|
||||
Y: float32(offset_y) + (float32(y) * src.Height * 2),
|
||||
Width: src.Width * 2,
|
||||
Height: src.Height * 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (menu Menu) Render() {
|
||||
render.Begin(rl.Black)
|
||||
|
||||
menu.renderLogo(20, 150)
|
||||
|
||||
y := int32(400)
|
||||
for i, entry := range menu.entries {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue