package main import rl "vendor:raylib" import "core:math/ease" LevelDone :: struct { using state: GameState, position: Vec2, size: Vec2, ready_to_go: bool, } leveldone_init :: proc(prev: ^GameState = nil) -> ^GameState { state := new(LevelDone) state.variant = state state.position = Vec2{WINDOWF.x / 2, WINDOWF.y + 300} state.size = {800, 400} state.update = leveldone_update state.draw = leveldone_draw state.free = leveldone_free state.previous = prev tween_to(&state.position.y, WINDOWF.y / 2, 1, ease.Ease.Back_Out, state, leveldone_ready) return state } leveldone_update :: proc(state: ^GameState, delta: f32) { leveldone := transmute(^LevelDone)state if leveldone.ready_to_go { if rl.IsKeyPressed(rl.KeyboardKey.ENTER) { stack_pop() game := transmute(^Game)stack_top() game.levels_done += 1 if game.levels_done > 0 && game.levels_done % 2 == 0 { game.levelsize += {2, 1} game.levelsize.x = min(game.levelsize.x, 13) game.levelsize.y = min(game.levelsize.y, 8) } game_gen_level(game) } } } leveldone_draw :: proc(state: ^GameState) { leveldone := transmute(^LevelDone)state if state.previous != nil { state.previous->draw() } TitleFontSize :: 96 TitleSpacing :: 3 TitleText :: "УРОВЕНЬ ПРОЙДЕН" TitleSize := rl.MeasureTextEx(FontTitle, TitleText, TitleFontSize, TitleSpacing) SubtitleText :: "Нажмите Enter чтобы продолжить" SubtitleFontSize :: 48 SubtitleSpacing :: 2 SubtitleSize := rl.MeasureTextEx(FontUI, SubtitleText, SubtitleFontSize, SubtitleSpacing) rl.DrawRectangleV(leveldone.position - leveldone.size / 2, leveldone.size, rl.Color{90, 30, 150, 255}) rl.DrawTextPro(FontTitle, TitleText, leveldone.position - {0, 50}, TitleSize / 2, 0, TitleFontSize, TitleSpacing, rl.WHITE) rl.DrawTextPro(FontUI, SubtitleText, leveldone.position + {0, 20}, SubtitleSize / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE) } leveldone_free :: proc(state: ^GameState) { free(state) } leveldone_ready :: proc(state: rawptr) { leveldone := transmute(^LevelDone)state leveldone.ready_to_go = true }