package main import rl "vendor:raylib" import "core:math/ease" Menu_Buttons :: enum { START, HOW_TO_PLAY, EXIT } menu_strings := [Menu_Buttons]cstring { .START = "Старт", .HOW_TO_PLAY = "Как играть?", .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 = {100, WSize.y / 2}, line_size = 60, font_size = 48, elements = &menu_strings, menu_pressed = menu_button_pressed, background = rl.Color{50, 10, 110, 10} } 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.position.y = WSize.y / 2 menu_list_update(&menu.list) } menu_button_pressed :: proc(state: ^GameState, el: Menu_Buttons) { switch el { case .START: stack_pop() case .HOW_TO_PLAY: // howtoplay := howtoplay_init(state) // stack_push(howtoplay) case .EXIT: WindowShouldExit = true return } } menu_draw :: proc(state: ^GameState) { menu := transmute(^Menu)state menu.previous.draw(menu.previous) TitleFontSize :: 96 TitleSpacing :: 3 TitleText :: "Ragnarøkkr" TitleSize := rl.MeasureTextEx(FontTitle, TitleText, TitleFontSize, TitleSpacing) rl.DrawTextPro(FontTitle, TitleText, {WSize.x - 50, 50}, {TitleSize.x, 0}, 0, 96, 3, rl.WHITE) menu_list_draw(&menu.list) } menu_free :: proc(state: ^GameState) { free(state) }