package main import "core:math/ease" import "ntween" import rl "vendor:raylib" Pause_Buttons :: enum { RESUME, EXIT, } pause_strings := [Pause_Buttons]cstring { .RESUME = "Продолжить", .EXIT = "Выход", } Pause :: struct { using state: GameState, list: MenuList(Pause_Buttons), } pause_init :: proc(prev: ^GameState = nil) -> ^GameState { state := new(Pause) state.variant = state state.list = MenuList(Pause_Buttons) { position = {-300, 300}, line_size = 60, font_size = 42, elements = &pause_strings, menu_pressed = pause_button_pressed, background = rl.Color{50, 10, 110, 180}, } state.update = pause_update state.draw = pause_draw state.free = pause_free state.previous = prev ntween.animate(&f32tween, &state.list.position.x, 300, 1, ease.Ease.Back_Out) return state } pause_update :: proc(state: ^GameState, delta: f32) { menu := transmute(^Pause)state if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) { stack_pop() return } menu_list_update(&menu.list) } pause_button_pressed :: proc(state: ^GameState, el: Pause_Buttons) { switch el { case .RESUME: stack_pop() case .EXIT: stack_pop() stack_pop() } } pause_draw :: proc(state: ^GameState) { menu := transmute(^Pause)state if state.previous != nil { state.previous->draw() } TitleFontSize :: 96 TitleSpacing :: 3 TitleText :: "ПАУЗА" TitleSize := rl.MeasureTextEx(FontTitle, TitleText, TitleFontSize, TitleSpacing) rl.DrawTextPro( FontTitle, "ПАУЗА", {WINDOWF.x - 50, 50}, {TitleSize.x, 0}, 0, 96, 3, rl.WHITE, ) menu_list_draw(&menu.list) } pause_free :: proc(state: ^GameState) { pause := transmute(^Pause)state free(state) }