2024-10-05 20:44:32 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
|
|
|
import "core:math/ease"
|
|
|
|
import "core:fmt"
|
|
|
|
|
|
|
|
|
|
|
|
GameOver :: struct {
|
|
|
|
using state: GameState,
|
|
|
|
position: vec2,
|
|
|
|
size: vec2,
|
|
|
|
ready_to_go: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
gameover_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
|
|
|
state := new(GameOver)
|
|
|
|
state.variant = state
|
|
|
|
state.position = vec2{WSize.x / 2, WSize.y + 300}
|
|
|
|
state.size = {700, 500}
|
|
|
|
state.update = gameover_update
|
|
|
|
state.draw = gameover_draw
|
|
|
|
state.free = gameover_free
|
|
|
|
|
|
|
|
state.previous = prev
|
|
|
|
tween_to(&state.position.y, WSize.y / 2, 1, ease.Ease.Back_Out, state, gameover_ready)
|
|
|
|
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
|
|
|
|
gameover_update :: proc(state: ^GameState, delta: f32) {
|
|
|
|
gameover := transmute(^GameOver)state
|
|
|
|
if gameover.ready_to_go {
|
|
|
|
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
|
|
|
gameover.ready_to_go = false
|
|
|
|
rl.StopMusicStream(current_music)
|
|
|
|
tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, nil, proc(data: rawptr) {
|
|
|
|
stack_pop()
|
|
|
|
state := transmute(^GameState)stack_top()
|
|
|
|
fmt.println(state.variant)
|
|
|
|
game := transmute(^Game)stack_top()
|
|
|
|
game_setup(game)
|
|
|
|
menu := menu_init(game)
|
|
|
|
stack_push(menu)
|
|
|
|
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gameover_draw :: proc(state: ^GameState) {
|
|
|
|
gameover := transmute(^GameOver)state
|
|
|
|
|
|
|
|
if state.previous != nil {
|
|
|
|
state.previous->draw()
|
|
|
|
}
|
|
|
|
|
|
|
|
TitleFontSize :: 96
|
|
|
|
TitleSpacing :: 3
|
|
|
|
TitleText :: "GAME OVER"
|
|
|
|
TitleSize := rl.MeasureTextEx(Res.Fonts.Title, TitleText, TitleFontSize, TitleSpacing)
|
|
|
|
|
|
|
|
SubtitleText := [?]cstring{"Нажмите Escape чтобы выйти"}
|
|
|
|
SubtitleFontSize :: 48
|
|
|
|
|
|
|
|
|
|
|
|
rl.DrawRectangleV(gameover.position - gameover.size / 2, gameover.size, rl.Color{90, 30, 150, 10})
|
|
|
|
|
2024-10-05 21:11:57 +03:00
|
|
|
draw_text_centered(Res.Fonts.Title, TitleText, gameover.position - {0, 100}, TitleFontSize, 1, rl.WHITE)
|
2024-10-05 20:44:32 +03:00
|
|
|
for c, i in SubtitleText {
|
2024-10-05 21:11:57 +03:00
|
|
|
draw_text_centered(Res.Fonts.UI, c, gameover.position - {0, f32(10 - i * 50)}, SubtitleFontSize, 1, rl.WHITE)
|
|
|
|
// rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE)
|
2024-10-05 20:44:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gameover_free :: proc(state: ^GameState) {
|
|
|
|
free(state)
|
|
|
|
}
|
|
|
|
|
|
|
|
gameover_ready :: proc(state: rawptr) {
|
|
|
|
gameover := transmute(^GameOver)state
|
|
|
|
gameover.ready_to_go = true
|
|
|
|
}
|