Fixed some resize bugs
This commit is contained in:
parent
d58af131f5
commit
4990a0c1bc
|
@ -6,13 +6,13 @@
|
|||
|
||||
## Запуск
|
||||
|
||||
Можно скачать репозиторий целиком и запустить Ragnarokkr.exe, или скачать архив из релизов: https://git.codenrock.com/xakaton-sineus-2024-1210/cnrprod1728028803-team-80721/1-6186/-/releases/Final
|
||||
Можно скачать репозиторий целиком и запустить Ragnarokkr.exe, или скачать архив из релизов, если он там есть
|
||||
|
||||
## Соответствие теме
|
||||
## Соответствие теме "Мифология как искусство"
|
||||
|
||||
Из темы я взял только слово "Мифология", так как слишком долго не мог придумать ничего связанного с искусством
|
||||
|
||||
¯\_(ツ)_/¯
|
||||
¯\\_(ツ)_/¯
|
||||
|
||||
## Геймплей
|
||||
|
||||
|
|
Binary file not shown.
12
game.odin
12
game.odin
|
@ -19,8 +19,6 @@ Game :: struct {
|
|||
camera: rl.Camera3D,
|
||||
camera_offset: vec3,
|
||||
score: u32,
|
||||
background: rl.Texture,
|
||||
plane: rl.Model,
|
||||
bullets: [dynamic]Bullet,
|
||||
snake_max_health: int,
|
||||
snake_health: int,
|
||||
|
@ -62,13 +60,8 @@ game_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
|||
state.draw = game_draw
|
||||
state.update = game_update
|
||||
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)
|
||||
return state
|
||||
|
@ -173,7 +166,7 @@ game_draw :: proc(state: ^GameState) {
|
|||
using game
|
||||
|
||||
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
|
||||
|
||||
|
@ -235,7 +228,6 @@ draw_hbar :: proc(text: cstring, value: f32, pos, size: vec2, color: rl.Color) {
|
|||
|
||||
game_free :: proc(state: ^GameState) {
|
||||
game := transmute(^Game)state
|
||||
rl.UnloadTexture(game.background)
|
||||
free(state)
|
||||
}
|
||||
|
||||
|
|
66
main.odin
66
main.odin
|
@ -59,19 +59,34 @@ Resources :: struct {
|
|||
|
||||
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 {
|
||||
p := filepath.join([]string{"./assets/sfx/", name})
|
||||
cstr := strings.clone_to_cstring(p)
|
||||
snd := rl.LoadSound(cstr)
|
||||
p := get_path(name, rl.Sound)
|
||||
snd := rl.LoadSound(p)
|
||||
rl.SetSoundVolume(snd, volume)
|
||||
return snd
|
||||
}
|
||||
|
||||
load_music :: proc(name: string, volume: f32 = 1) -> rl.Music {
|
||||
p := filepath.join([]string{"./assets/music/", name})
|
||||
cstr := strings.clone_to_cstring(p)
|
||||
snd := rl.LoadMusicStream(cstr)
|
||||
p := get_path(name, rl.Music)
|
||||
snd := rl.LoadMusicStream(p)
|
||||
rl.SetMusicVolume(snd, volume)
|
||||
return snd
|
||||
}
|
||||
|
@ -89,23 +104,28 @@ load_resources :: proc() {
|
|||
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.Models.PlayerModel = rl.LoadModel("./assets/models/chariot.glb")
|
||||
Res.Models.SnakeHeadTop = rl.LoadModel("./assets/models/snake_head_top.obj")
|
||||
Res.Models.SnakeHeadJaw = rl.LoadModel("./assets/models/snake_jaw.obj")
|
||||
Res.Models.SnakeBody = rl.LoadModel("./assets/models/snake_body.obj")
|
||||
Res.Models = {
|
||||
PlayerModel = load_model("chariot.glb"),
|
||||
SnakeHeadTop = load_model("snake_head_top.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.Lightning = load_sfx("lightning.ogg", 0.5)
|
||||
Res.Sfx.LightningHit = load_sfx("lightning-hit.ogg", 0.3)
|
||||
Res.Sfx.Rocket = load_sfx("rocket.ogg", 0.5)
|
||||
Res.Sfx.PlayerHit = load_sfx("player-hit.ogg", 0.5)
|
||||
Res.Sfx.PlayerSwoosh = load_sfx("player-swoosh.ogg")
|
||||
Res.Sfx.PlayerDead = load_sfx("player-dead.ogg")
|
||||
Res.Sfx.SnakeGrowl = load_sfx("snake-growl.ogg", 0.7)
|
||||
Res.Sfx.SnakeRoarBlast = load_sfx("snake-roar-blast.ogg", 0.8)
|
||||
Res.Sfx.SnakeBeam = load_sfx("snake-beam.ogg")
|
||||
Res.Sfx.SnakeSegmentExplode = load_sfx("snake-segment-explode.ogg", 0.8)
|
||||
Res.Sfx.SnakeEarthHit = load_sfx("snake-earth-hit.ogg", 0.6)
|
||||
Res.Sfx = {
|
||||
Drums = load_sfx("drums.ogg"),
|
||||
Lightning = load_sfx("lightning.ogg", 0.5),
|
||||
LightningHit = load_sfx("lightning-hit.ogg", 0.3),
|
||||
Rocket = load_sfx("rocket.ogg", 0.5),
|
||||
PlayerHit = load_sfx("player-hit.ogg", 0.5),
|
||||
PlayerSwoosh = load_sfx("player-swoosh.ogg"),
|
||||
PlayerDead = load_sfx("player-dead.ogg"),
|
||||
SnakeGrowl = load_sfx("snake-growl.ogg", 0.7),
|
||||
SnakeRoarBlast = load_sfx("snake-roar-blast.ogg", 0.8),
|
||||
SnakeBeam = load_sfx("snake-beam.ogg"),
|
||||
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.Second = load_music("alexander-nakarada-the-northern-path.mp3", 0.7)
|
||||
|
@ -115,10 +135,10 @@ Fullscreen := true
|
|||
|
||||
main :: proc() {
|
||||
rl.SetConfigFlags(rl.ConfigFlags{.MSAA_4X_HINT, .FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE})
|
||||
rl.SetWindowMinSize(800, 480)
|
||||
|
||||
rl.InitWindow(0, 0, "Ragnarøkkr")
|
||||
rl.InitAudioDevice()
|
||||
rl.SetWindowMinSize(800, 480)
|
||||
|
||||
rl.HideCursor()
|
||||
Cursor = rl.LoadTexture("./assets/gfx/crosshair.png")
|
||||
|
|
|
@ -68,6 +68,7 @@ menu_button_pressed :: proc(state: ^GameState, el: Menu_Buttons) {
|
|||
game := transmute(^Game)state.previous
|
||||
change_track(Res.Music.First)
|
||||
stack_pop()
|
||||
return
|
||||
case .TUTORIAL:
|
||||
NeedTutorial = !NeedTutorial
|
||||
case .KEYBOARD_ONLY:
|
||||
|
@ -99,5 +100,5 @@ menu_draw :: proc(state: ^GameState) {
|
|||
}
|
||||
|
||||
menu_free :: proc(state: ^GameState) {
|
||||
free(state)
|
||||
//free(state)
|
||||
}
|
||||
|
|
|
@ -66,12 +66,14 @@ pause_button_pressed :: proc(state: ^GameState, el: Pause_Buttons) {
|
|||
case .EXIT:
|
||||
pause.active = false
|
||||
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()
|
||||
game := transmute(^Game)stack_top()
|
||||
game_setup(game)
|
||||
menu := menu_init(game)
|
||||
stack_push(menu)
|
||||
//free(state)
|
||||
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) {
|
||||
free(state)
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ stack_pop :: proc() -> (bool) {
|
|||
}
|
||||
state := pop(&state_stack)
|
||||
state->free()
|
||||
//free(state)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue