2024-10-05 20:44:32 +03:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import "core:fmt"
|
2024-11-04 17:28:34 +03:00
|
|
|
|
import "core:math/ease"
|
|
|
|
|
import "ntween"
|
|
|
|
|
import rl "vendor:raylib"
|
2024-10-05 20:44:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Winning :: struct {
|
|
|
|
|
using state: GameState,
|
2024-11-04 17:28:34 +03:00
|
|
|
|
position: vec2,
|
|
|
|
|
size: vec2,
|
2024-10-05 20:44:32 +03:00
|
|
|
|
ready_to_go: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winning_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
|
|
|
|
state := new(Winning)
|
|
|
|
|
state.variant = state
|
|
|
|
|
state.position = vec2{WSize.x / 2, WSize.y + 300}
|
|
|
|
|
state.size = {700, 500}
|
|
|
|
|
state.update = winning_update
|
|
|
|
|
state.draw = winning_draw
|
|
|
|
|
state.free = winning_free
|
|
|
|
|
|
|
|
|
|
state.previous = prev
|
2024-11-04 17:28:34 +03:00
|
|
|
|
ntween.animate(
|
|
|
|
|
&vec2_tweens,
|
|
|
|
|
&state.position,
|
|
|
|
|
WSize / 2,
|
|
|
|
|
1,
|
|
|
|
|
ease.Ease.Back_Out,
|
|
|
|
|
state,
|
|
|
|
|
winning_ready,
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-05 20:44:32 +03:00
|
|
|
|
return state
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winning_update :: proc(state: ^GameState, delta: f32) {
|
|
|
|
|
winning := transmute(^Winning)state
|
|
|
|
|
if winning.ready_to_go {
|
|
|
|
|
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
|
|
|
|
winning.ready_to_go = false
|
|
|
|
|
rl.StopMusicStream(current_music)
|
2024-11-04 17:28:34 +03:00
|
|
|
|
ntween.animate(
|
|
|
|
|
&f32_tweens,
|
|
|
|
|
&Overlay_Opacity,
|
|
|
|
|
1.0,
|
|
|
|
|
0.5,
|
|
|
|
|
ease.Ease.Cubic_Out,
|
|
|
|
|
nil,
|
|
|
|
|
proc(data: rawptr) {
|
|
|
|
|
state := transmute(^GameState)data
|
|
|
|
|
stack_pop()
|
|
|
|
|
game := transmute(^Game)state.previous
|
|
|
|
|
game_setup(game)
|
|
|
|
|
menu := menu_init(game)
|
|
|
|
|
stack_push(menu)
|
|
|
|
|
free(state)
|
|
|
|
|
ntween.animate(&f32_tweens, &Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
|
|
|
|
},
|
|
|
|
|
)
|
2024-10-05 20:44:32 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
winning_draw :: proc(state: ^GameState) {
|
|
|
|
|
winning := transmute(^Winning)state
|
2024-11-04 17:28:34 +03:00
|
|
|
|
|
2024-10-05 20:44:32 +03:00
|
|
|
|
if state.previous != nil {
|
|
|
|
|
state.previous->draw()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TitleFontSize :: 96
|
|
|
|
|
TitleSpacing :: 3
|
|
|
|
|
TitleText :: "GAME OVER"
|
|
|
|
|
|
2024-11-04 17:28:34 +03:00
|
|
|
|
SubtitleText := [?]cstring {
|
|
|
|
|
"Тор смог спасти Асгард",
|
|
|
|
|
"от Рагнарёка!",
|
|
|
|
|
"Нажмите Escape чтобы выйти",
|
|
|
|
|
}
|
2024-10-05 20:44:32 +03:00
|
|
|
|
SubtitleFontSize :: 48
|
|
|
|
|
|
2024-11-04 17:28:34 +03:00
|
|
|
|
|
2024-10-05 20:44:32 +03:00
|
|
|
|
rl.DrawRectangleV(winning.position - winning.size / 2, winning.size, rl.Color{90, 30, 150, 10})
|
|
|
|
|
|
2024-11-04 17:28:34 +03:00
|
|
|
|
draw_text_centered(
|
|
|
|
|
Res.Fonts.Title,
|
|
|
|
|
TitleText,
|
|
|
|
|
winning.position - {0, 100},
|
|
|
|
|
TitleFontSize,
|
|
|
|
|
1,
|
|
|
|
|
rl.WHITE,
|
|
|
|
|
)
|
2024-10-05 20:44:32 +03:00
|
|
|
|
for c, i in SubtitleText {
|
2024-11-04 17:28:34 +03:00
|
|
|
|
draw_text_centered(
|
|
|
|
|
Res.Fonts.UI,
|
|
|
|
|
c,
|
|
|
|
|
winning.position - {0, f32(10 - i * 50)},
|
|
|
|
|
SubtitleFontSize,
|
|
|
|
|
1,
|
|
|
|
|
rl.WHITE,
|
|
|
|
|
)
|
2024-10-05 21:11:57 +03:00
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winning_free :: proc(state: ^GameState) {
|
2024-10-06 00:42:22 +03:00
|
|
|
|
// free(state)
|
2024-10-05 20:44:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winning_ready :: proc(state: rawptr) {
|
|
|
|
|
winning := transmute(^Winning)state
|
|
|
|
|
winning.ready_to_go = true
|
|
|
|
|
}
|