82 lines
1.5 KiB
Odin
82 lines
1.5 KiB
Odin
package main
|
|
|
|
import rl "vendor:raylib"
|
|
import "core:math/ease"
|
|
|
|
|
|
Menu_Buttons :: enum {
|
|
START,
|
|
HOW_TO_PLAY,
|
|
FULLSCREEN,
|
|
EXIT
|
|
}
|
|
|
|
menu_strings := [Menu_Buttons]cstring {
|
|
.START = "Старт",
|
|
.HOW_TO_PLAY = "Как играть?",
|
|
.FULLSCREEN = "Полный экран",
|
|
.EXIT = "Выход"
|
|
}
|
|
|
|
Menu :: struct {
|
|
using state: GameState,
|
|
|
|
list: MenuList(Menu_Buttons),
|
|
|
|
}
|
|
|
|
menu_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
|
state := new(Menu)
|
|
state.variant = state
|
|
state.list = MenuList(Menu_Buttons){
|
|
state = state,
|
|
position = {300, 300},
|
|
line_size = 60,
|
|
font_size = 42,
|
|
elements = &menu_strings,
|
|
menu_pressed = menu_button_pressed
|
|
}
|
|
state.update = menu_update
|
|
state.draw = menu_draw
|
|
state.free = menu_free
|
|
state.previous = prev
|
|
|
|
return state
|
|
}
|
|
|
|
menu_update :: proc(state: ^GameState, delta: f32) {
|
|
menu := transmute(^Menu)state
|
|
|
|
menu_list_update(&menu.list)
|
|
}
|
|
|
|
menu_button_pressed :: proc(state: ^GameState, el: Menu_Buttons) {
|
|
switch el {
|
|
case .START:
|
|
game := game_init(state)
|
|
stack_push(game)
|
|
case .FULLSCREEN:
|
|
case .HOW_TO_PLAY:
|
|
case .EXIT:
|
|
WindowShouldExit = true
|
|
return
|
|
}
|
|
}
|
|
|
|
menu_draw :: proc(state: ^GameState) {
|
|
menu := transmute(^Menu)state
|
|
|
|
TitleFontSize :: 96
|
|
TitleSpacing :: 3
|
|
TitleText :: "ARKADODGE"
|
|
TitleSize := rl.MeasureTextEx(FontTitle, TitleText, TitleFontSize, TitleSpacing)
|
|
rl.DrawTextPro(FontTitle, "ARKADODGE", {WINDOWF.x - 50, 50}, {TitleSize.x, 0}, 0, 96, 3, rl.WHITE)
|
|
|
|
menu_list_draw(&menu.list)
|
|
|
|
}
|
|
|
|
menu_free :: proc(state: ^GameState) {
|
|
free(state)
|
|
}
|