105 lines
2.2 KiB
Odin
105 lines
2.2 KiB
Odin
package main
|
||
|
||
import "core:fmt"
|
||
import "core:slice"
|
||
import "ntween"
|
||
import rl "vendor:raylib"
|
||
import rlgl "vendor:raylib/rlgl"
|
||
|
||
import "core:math/ease"
|
||
|
||
Vec2 :: [2]f32
|
||
Vec2i :: [2]i32
|
||
|
||
WINDOW: Vec2i
|
||
WINDOWF: Vec2
|
||
|
||
FontTitle: rl.Font
|
||
FontUI: rl.Font
|
||
|
||
WindowShouldExit := false
|
||
|
||
f32tween: ntween.Tween_Map(f32)
|
||
v2tween: ntween.Tween_Map(Vec2)
|
||
|
||
|
||
main :: proc() {
|
||
rl.SetConfigFlags(rl.ConfigFlags{.FULLSCREEN_MODE, .VSYNC_HINT})
|
||
monitor := rl.GetCurrentMonitor()
|
||
rl.InitWindow(0, 0, "SinePong")
|
||
rl.SetTargetFPS(9999)
|
||
|
||
|
||
f32tween = ntween.init(f32)
|
||
v2tween = ntween.init(Vec2)
|
||
defer {
|
||
ntween.destroy_tweens(&f32tween)
|
||
ntween.destroy_tweens(&v2tween)
|
||
}
|
||
|
||
FontUI = rl.LoadFontEx("assets/monogram-extended.ttf", 96, nil, 2048)
|
||
// FontUI = rl.LoadFont("assets/monogram-extended.ttf")
|
||
FontTitle = rl.LoadFontEx("assets/monogram-extended.ttf", 96 * 2, nil, 2048)
|
||
defer rl.UnloadFont(FontTitle)
|
||
defer rl.UnloadFont(FontUI)
|
||
rl.SetTextureFilter(FontUI.texture, rl.TextureFilter.POINT)
|
||
rl.SetTextureFilter(FontTitle.texture, rl.TextureFilter.POINT)
|
||
|
||
WINDOW.x = rl.GetScreenWidth()
|
||
WINDOW.y = rl.GetScreenHeight()
|
||
WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)}
|
||
|
||
stack_init()
|
||
|
||
defer {
|
||
for state, i in state_stack {
|
||
state->free()
|
||
}
|
||
}
|
||
|
||
game := game_init()
|
||
menu := menu_init()
|
||
append(&state_stack, menu)
|
||
|
||
for (!WindowShouldExit) {
|
||
if rl.IsWindowResized() {
|
||
WINDOW.x = rl.GetScreenWidth()
|
||
WINDOW.y = rl.GetScreenHeight()
|
||
WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)}
|
||
}
|
||
|
||
current_state := state_stack[len(state_stack) - 1]
|
||
|
||
delta := rl.GetFrameTime()
|
||
ntween.process(&f32tween, delta)
|
||
ntween.process(&v2tween, delta)
|
||
|
||
current_state->update(delta)
|
||
{
|
||
rl.BeginDrawing()
|
||
defer rl.EndDrawing()
|
||
rl.ClearBackground(rl.Color{40, 10, 90, 255})
|
||
current_state->draw()
|
||
rlgl.PopMatrix()
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/*
|
||
|
||
TODO:
|
||
[ ] Уничтожение биты от попадания кирпича
|
||
[ ] Проверка завершения уровня
|
||
[ ] Генерация уровней
|
||
[ ] (Опционально) редактор уровней с сохранением в файл
|
||
[x] Меню
|
||
[ ] Гейм овер
|
||
[ ] Бонусы
|
||
[ ] Визуальное оформление
|
||
[ ] Интерфейс игры
|
||
[ ] Звуки
|
||
|
||
*/
|
||
|