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