Fixed some resize bugs

This commit is contained in:
Nefrace 2024-10-12 18:26:14 +03:00
parent d58af131f5
commit 4990a0c1bc
7 changed files with 54 additions and 39 deletions

View File

@ -6,13 +6,13 @@
## Запуск ## Запуск
Можно скачать репозиторий целиком и запустить Ragnarokkr.exe, или скачать архив из релизов: https://git.codenrock.com/xakaton-sineus-2024-1210/cnrprod1728028803-team-80721/1-6186/-/releases/Final Можно скачать репозиторий целиком и запустить Ragnarokkr.exe, или скачать архив из релизов, если он там есть
## Соответствие теме ## Соответствие теме "Мифология как искусство"
Из темы я взял только слово "Мифология", так как слишком долго не мог придумать ничего связанного с искусством Из темы я взял только слово "Мифология", так как слишком долго не мог придумать ничего связанного с искусством
¯\_(ツ)_/¯ ¯\\_(ツ)_/¯
## Геймплей ## Геймплей

BIN
Ragnarokkr Executable file

Binary file not shown.

View File

@ -19,8 +19,6 @@ Game :: struct {
camera: rl.Camera3D, camera: rl.Camera3D,
camera_offset: vec3, camera_offset: vec3,
score: u32, score: u32,
background: rl.Texture,
plane: rl.Model,
bullets: [dynamic]Bullet, bullets: [dynamic]Bullet,
snake_max_health: int, snake_max_health: int,
snake_health: int, snake_health: int,
@ -62,13 +60,8 @@ game_init :: proc(prev: ^GameState = nil) -> ^GameState {
state.draw = game_draw state.draw = game_draw
state.update = game_update state.update = game_update
state.free = game_free state.free = game_free
rlgl.DisableBackfaceCulling() // rlgl.DisableBackfaceCulling()
img := rl.GenImageChecked(1024, 1024, 128, 128, rl.Color{60, 255, 255, 255}, rl.Color{30, 220, 220, 255})
state.background = rl.LoadTextureFromImage(img)
state.plane = rl.LoadModel(".\\assets\\models\\background.obj")
rl.UnloadImage(img)
game_setup(state) game_setup(state)
return state return state
@ -173,7 +166,7 @@ game_draw :: proc(state: ^GameState) {
using game using game
rl.BeginMode3D(camera) rl.BeginMode3D(camera)
rl.DrawModel(game.plane, {0, 0, 500}, 1000, rl.WHITE) rl.DrawModel(Res.Models.Background, {0, 0, 500}, 1000, rl.WHITE)
yy : i32 = 0 yy : i32 = 0
@ -235,7 +228,6 @@ draw_hbar :: proc(text: cstring, value: f32, pos, size: vec2, color: rl.Color) {
game_free :: proc(state: ^GameState) { game_free :: proc(state: ^GameState) {
game := transmute(^Game)state game := transmute(^Game)state
rl.UnloadTexture(game.background)
free(state) free(state)
} }

View File

@ -59,19 +59,34 @@ Resources :: struct {
Res : Resources Res : Resources
res_paths := map[typeid]string{
rl.Music = "music",
rl.Sound = "sfx",
rl.Model = "models",
}
get_path :: proc(name: string, $T: typeid) -> cstring{
p := filepath.join([]string{"./assets", res_paths[T], name})
cstr := strings.clone_to_cstring(p)
return cstr
}
load_model :: proc(name: string) -> rl.Model {
p := get_path(name, rl.Model)
mdl := rl.LoadModel(p)
return mdl
}
load_sfx :: proc(name: string, volume: f32 = 1) -> rl.Sound { load_sfx :: proc(name: string, volume: f32 = 1) -> rl.Sound {
p := filepath.join([]string{"./assets/sfx/", name}) p := get_path(name, rl.Sound)
cstr := strings.clone_to_cstring(p) snd := rl.LoadSound(p)
snd := rl.LoadSound(cstr)
rl.SetSoundVolume(snd, volume) rl.SetSoundVolume(snd, volume)
return snd return snd
} }
load_music :: proc(name: string, volume: f32 = 1) -> rl.Music { load_music :: proc(name: string, volume: f32 = 1) -> rl.Music {
p := filepath.join([]string{"./assets/music/", name}) p := get_path(name, rl.Music)
cstr := strings.clone_to_cstring(p) snd := rl.LoadMusicStream(p)
snd := rl.LoadMusicStream(cstr)
rl.SetMusicVolume(snd, volume) rl.SetMusicVolume(snd, volume)
return snd return snd
} }
@ -89,23 +104,28 @@ load_resources :: proc() {
Res.Fonts.Title = rl.LoadFontEx("./assets/fonts/norse.otf", 96*2, nil, 2048) Res.Fonts.Title = rl.LoadFontEx("./assets/fonts/norse.otf", 96*2, nil, 2048)
Res.Fonts.UI = rl.LoadFontEx("./assets/fonts/PTSerif-Regular.ttf", 96, nil, 2048) Res.Fonts.UI = rl.LoadFontEx("./assets/fonts/PTSerif-Regular.ttf", 96, nil, 2048)
Res.Models.PlayerModel = rl.LoadModel("./assets/models/chariot.glb") Res.Models = {
Res.Models.SnakeHeadTop = rl.LoadModel("./assets/models/snake_head_top.obj") PlayerModel = load_model("chariot.glb"),
Res.Models.SnakeHeadJaw = rl.LoadModel("./assets/models/snake_jaw.obj") SnakeHeadTop = load_model("snake_head_top.obj"),
Res.Models.SnakeBody = rl.LoadModel("./assets/models/snake_body.obj") SnakeHeadJaw = load_model("snake_jaw.obj"),
SnakeBody = load_model("snake_body.obj"),
Background = load_model("background.obj"),
}
Res.Sfx.Drums = load_sfx("drums.ogg") Res.Sfx = {
Res.Sfx.Lightning = load_sfx("lightning.ogg", 0.5) Drums = load_sfx("drums.ogg"),
Res.Sfx.LightningHit = load_sfx("lightning-hit.ogg", 0.3) Lightning = load_sfx("lightning.ogg", 0.5),
Res.Sfx.Rocket = load_sfx("rocket.ogg", 0.5) LightningHit = load_sfx("lightning-hit.ogg", 0.3),
Res.Sfx.PlayerHit = load_sfx("player-hit.ogg", 0.5) Rocket = load_sfx("rocket.ogg", 0.5),
Res.Sfx.PlayerSwoosh = load_sfx("player-swoosh.ogg") PlayerHit = load_sfx("player-hit.ogg", 0.5),
Res.Sfx.PlayerDead = load_sfx("player-dead.ogg") PlayerSwoosh = load_sfx("player-swoosh.ogg"),
Res.Sfx.SnakeGrowl = load_sfx("snake-growl.ogg", 0.7) PlayerDead = load_sfx("player-dead.ogg"),
Res.Sfx.SnakeRoarBlast = load_sfx("snake-roar-blast.ogg", 0.8) SnakeGrowl = load_sfx("snake-growl.ogg", 0.7),
Res.Sfx.SnakeBeam = load_sfx("snake-beam.ogg") SnakeRoarBlast = load_sfx("snake-roar-blast.ogg", 0.8),
Res.Sfx.SnakeSegmentExplode = load_sfx("snake-segment-explode.ogg", 0.8) SnakeBeam = load_sfx("snake-beam.ogg"),
Res.Sfx.SnakeEarthHit = load_sfx("snake-earth-hit.ogg", 0.6) SnakeSegmentExplode = load_sfx("snake-segment-explode.ogg", 0.8),
SnakeEarthHit = load_sfx("snake-earth-hit.ogg", 0.6),
}
Res.Music.First = load_music("alexander-nakarada-mjolnir.mp3", 0.7) Res.Music.First = load_music("alexander-nakarada-mjolnir.mp3", 0.7)
Res.Music.Second = load_music("alexander-nakarada-the-northern-path.mp3", 0.7) Res.Music.Second = load_music("alexander-nakarada-the-northern-path.mp3", 0.7)
@ -115,10 +135,10 @@ Fullscreen := true
main :: proc() { main :: proc() {
rl.SetConfigFlags(rl.ConfigFlags{.MSAA_4X_HINT, .FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE}) rl.SetConfigFlags(rl.ConfigFlags{.MSAA_4X_HINT, .FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE})
rl.SetWindowMinSize(800, 480)
rl.InitWindow(0, 0, "Ragnarøkkr") rl.InitWindow(0, 0, "Ragnarøkkr")
rl.InitAudioDevice() rl.InitAudioDevice()
rl.SetWindowMinSize(800, 480)
rl.HideCursor() rl.HideCursor()
Cursor = rl.LoadTexture("./assets/gfx/crosshair.png") Cursor = rl.LoadTexture("./assets/gfx/crosshair.png")

View File

@ -68,6 +68,7 @@ menu_button_pressed :: proc(state: ^GameState, el: Menu_Buttons) {
game := transmute(^Game)state.previous game := transmute(^Game)state.previous
change_track(Res.Music.First) change_track(Res.Music.First)
stack_pop() stack_pop()
return
case .TUTORIAL: case .TUTORIAL:
NeedTutorial = !NeedTutorial NeedTutorial = !NeedTutorial
case .KEYBOARD_ONLY: case .KEYBOARD_ONLY:
@ -99,5 +100,5 @@ menu_draw :: proc(state: ^GameState) {
} }
menu_free :: proc(state: ^GameState) { menu_free :: proc(state: ^GameState) {
free(state) //free(state)
} }

View File

@ -66,12 +66,14 @@ pause_button_pressed :: proc(state: ^GameState, el: Pause_Buttons) {
case .EXIT: case .EXIT:
pause.active = false pause.active = false
rl.StopMusicStream(current_music) rl.StopMusicStream(current_music)
tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, pause, proc(data: rawptr) { tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, state, proc(data: rawptr) {
state := transmute(^GameState)data
stack_pop() stack_pop()
game := transmute(^Game)stack_top() game := transmute(^Game)stack_top()
game_setup(game) game_setup(game)
menu := menu_init(game) menu := menu_init(game)
stack_push(menu) stack_push(menu)
//free(state)
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out) tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
}) })
} }
@ -93,5 +95,4 @@ pause_draw :: proc(state: ^GameState) {
} }
pause_free :: proc(state: ^GameState) { pause_free :: proc(state: ^GameState) {
free(state)
} }

View File

@ -36,6 +36,7 @@ stack_pop :: proc() -> (bool) {
} }
state := pop(&state_stack) state := pop(&state_stack)
state->free() state->free()
//free(state)
return true return true
} }