Compare commits
5 Commits
Hackathon-
...
master
Author | SHA1 | Date |
---|---|---|
Nefrace | f72ac633ee | |
Nefrace | 4df0bcd5ff | |
Nefrace | b251553275 | |
Vlad Rud | 8a9e20f370 | |
Nefrace | 4f0b5dace4 |
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "ntween"]
|
||||||
|
path = ntween
|
||||||
|
url = https://git.nefrace.ru/nefrace/ntween.git
|
BIN
Ragnarokkr
BIN
Ragnarokkr
Binary file not shown.
BIN
Ragnarokkr.exe
BIN
Ragnarokkr.exe
Binary file not shown.
|
@ -1,8 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import rl "vendor:raylib"
|
|
||||||
import "core:math/ease"
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
|
import "core:math/ease"
|
||||||
|
import "ntween"
|
||||||
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
|
|
||||||
GameOver :: struct {
|
GameOver :: struct {
|
||||||
|
@ -22,7 +23,15 @@ gameover_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
||||||
state.free = gameover_free
|
state.free = gameover_free
|
||||||
|
|
||||||
state.previous = prev
|
state.previous = prev
|
||||||
tween_to(&state.position.y, WSize.y / 2, 1, ease.Ease.Back_Out, state, gameover_ready)
|
ntween.animate(
|
||||||
|
&vec2_tweens,
|
||||||
|
&state.position,
|
||||||
|
WSize / 2,
|
||||||
|
1,
|
||||||
|
ease.Ease.Back_Out,
|
||||||
|
state,
|
||||||
|
gameover_ready,
|
||||||
|
)
|
||||||
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
@ -33,7 +42,14 @@ gameover_update :: proc(state: ^GameState, delta: f32) {
|
||||||
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
||||||
gameover.ready_to_go = false
|
gameover.ready_to_go = false
|
||||||
rl.StopMusicStream(current_music)
|
rl.StopMusicStream(current_music)
|
||||||
tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, state, proc(data: rawptr) {
|
ntween.animate(
|
||||||
|
&f32_tweens,
|
||||||
|
&Overlay_Opacity,
|
||||||
|
1.0,
|
||||||
|
0.5,
|
||||||
|
ease.Ease.Cubic_Out,
|
||||||
|
state,
|
||||||
|
proc(data: rawptr) {
|
||||||
state := transmute(^GameState)data
|
state := transmute(^GameState)data
|
||||||
stack_pop()
|
stack_pop()
|
||||||
game := transmute(^Game)state.previous
|
game := transmute(^Game)state.previous
|
||||||
|
@ -41,8 +57,9 @@ gameover_update :: proc(state: ^GameState, delta: f32) {
|
||||||
menu := menu_init(game)
|
menu := menu_init(game)
|
||||||
stack_push(menu)
|
stack_push(menu)
|
||||||
free(state)
|
free(state)
|
||||||
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
ntween.animate(&f32_tweens, &Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,9 +83,23 @@ gameover_draw :: proc(state: ^GameState) {
|
||||||
|
|
||||||
// rl.DrawRectangleV(gameover.position - gameover.size / 2, gameover.size, rl.Color{90, 30, 150, 10})
|
// rl.DrawRectangleV(gameover.position - gameover.size / 2, gameover.size, rl.Color{90, 30, 150, 10})
|
||||||
|
|
||||||
draw_text_centered(Res.Fonts.Title, TitleText, gameover.position - {0, 100}, TitleFontSize, 1, rl.WHITE)
|
draw_text_centered(
|
||||||
|
Res.Fonts.Title,
|
||||||
|
TitleText,
|
||||||
|
gameover.position - {0, 100},
|
||||||
|
TitleFontSize,
|
||||||
|
1,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
for c, i in SubtitleText {
|
for c, i in SubtitleText {
|
||||||
draw_text_centered(Res.Fonts.UI, c, gameover.position - {0, f32(10 - i * 50)}, SubtitleFontSize, 1, rl.WHITE)
|
draw_text_centered(
|
||||||
|
Res.Fonts.UI,
|
||||||
|
c,
|
||||||
|
gameover.position - {0, f32(10 - i * 50)},
|
||||||
|
SubtitleFontSize,
|
||||||
|
1,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
// rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE)
|
// rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
main.odin
41
main.odin
|
@ -1,11 +1,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import rl "vendor:raylib"
|
import "core:fmt"
|
||||||
import "core:path/filepath"
|
import "core:path/filepath"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
import "ntween"
|
||||||
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
vec3 :: [3]f32
|
vec3 :: [3]f32
|
||||||
|
vec3i :: [3]i32
|
||||||
vec2 :: [2]f32
|
vec2 :: [2]f32
|
||||||
|
vec2i :: [2]i32
|
||||||
vec3right := vec3{1, 0, 0}
|
vec3right := vec3{1, 0, 0}
|
||||||
vec3left := vec3{-1, 0, 0}
|
vec3left := vec3{-1, 0, 0}
|
||||||
vec3up := vec3{0, 1, 0}
|
vec3up := vec3{0, 1, 0}
|
||||||
|
@ -17,6 +21,8 @@ vec3backward := vec3{0, 0, -1}
|
||||||
WSize := [2]f32{}
|
WSize := [2]f32{}
|
||||||
WSizei := [2]i32{}
|
WSizei := [2]i32{}
|
||||||
|
|
||||||
|
WSizeLast := vec2i{}
|
||||||
|
|
||||||
WindowShouldExit := false
|
WindowShouldExit := false
|
||||||
|
|
||||||
NeedTutorial := true
|
NeedTutorial := true
|
||||||
|
@ -54,7 +60,7 @@ Resources :: struct {
|
||||||
Music: struct {
|
Music: struct {
|
||||||
First: rl.Music,
|
First: rl.Music,
|
||||||
Second: rl.Music,
|
Second: rl.Music,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Res: Resources
|
Res: Resources
|
||||||
|
@ -131,14 +137,20 @@ load_resources :: proc() {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
Fullscreen := true
|
f32_tweens: ntween.Tween_Map(f32)
|
||||||
|
vec2_tweens: ntween.Tween_Map(vec2)
|
||||||
|
vec3_tweens: ntween.Tween_Map(vec3)
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
rl.SetConfigFlags(rl.ConfigFlags{.MSAA_4X_HINT, .FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE})
|
f32_tweens = ntween.init(f32)
|
||||||
|
vec2_tweens = ntween.init(vec2)
|
||||||
|
vec3_tweens = ntween.init(vec3)
|
||||||
|
// rl.SetConfigFlags(rl.ConfigFlags{.MSAA_4X_HINT, .FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE})
|
||||||
|
rl.SetConfigFlags(rl.ConfigFlags{.VSYNC_HINT, .WINDOW_RESIZABLE})
|
||||||
|
|
||||||
rl.InitWindow(0, 0, "Ragnarøkkr")
|
rl.InitWindow(800, 600, "Ragnarøkkr")
|
||||||
rl.InitAudioDevice()
|
rl.InitAudioDevice()
|
||||||
rl.SetWindowMinSize(800, 480)
|
rl.SetWindowMinSize(800, 600)
|
||||||
|
|
||||||
rl.HideCursor()
|
rl.HideCursor()
|
||||||
Cursor = rl.LoadTexture("./assets/gfx/crosshair.png")
|
Cursor = rl.LoadTexture("./assets/gfx/crosshair.png")
|
||||||
|
@ -163,7 +175,9 @@ main :: proc() {
|
||||||
state := stack_top()
|
state := stack_top()
|
||||||
delta := rl.GetFrameTime()
|
delta := rl.GetFrameTime()
|
||||||
timers_process(delta)
|
timers_process(delta)
|
||||||
tweens_process(delta)
|
ntween.process(&f32_tweens, delta)
|
||||||
|
ntween.process(&vec2_tweens, delta)
|
||||||
|
ntween.process(&vec3_tweens, delta)
|
||||||
state->update(delta)
|
state->update(delta)
|
||||||
|
|
||||||
rl.BeginDrawing()
|
rl.BeginDrawing()
|
||||||
|
@ -176,3 +190,16 @@ main :: proc() {
|
||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fullscreen := false
|
||||||
|
|
||||||
|
toggle_fullscreen :: proc() {
|
||||||
|
monitor := rl.GetCurrentMonitor()
|
||||||
|
rl.ToggleBorderlessWindowed()
|
||||||
|
WSizei = {rl.GetScreenWidth(), rl.GetScreenHeight()}
|
||||||
|
WSize = {f32(WSizei.x), f32(WSizei.y)}
|
||||||
|
Fullscreen = !Fullscreen
|
||||||
|
|
||||||
|
|
||||||
|
// rl.ToggleFullscreen()
|
||||||
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ menu_button_pressed :: proc(state: ^GameState, el: Menu_Buttons) {
|
||||||
KeyboardOnly = !KeyboardOnly
|
KeyboardOnly = !KeyboardOnly
|
||||||
NeedTutorial = true
|
NeedTutorial = true
|
||||||
case .FULLSCREEN:
|
case .FULLSCREEN:
|
||||||
rl.ToggleFullscreen()
|
toggle_fullscreen()
|
||||||
Fullscreen = rl.IsWindowFullscreen()
|
// Fullscreen = rl.IsWindowFullscreen()
|
||||||
|
|
||||||
case .EXIT:
|
case .EXIT:
|
||||||
WindowShouldExit = true
|
WindowShouldExit = true
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import rl "vendor:raylib"
|
|
||||||
import "core:math/ease"
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
|
import "core:math/ease"
|
||||||
|
import "ntween"
|
||||||
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
MenuItemType :: enum {
|
MenuItemType :: enum {
|
||||||
NONE,
|
NONE,
|
||||||
|
@ -12,7 +13,7 @@ MenuItemType :: enum {
|
||||||
|
|
||||||
BoolStrings := map[bool]cstring {
|
BoolStrings := map[bool]cstring {
|
||||||
true = "вкл",
|
true = "вкл",
|
||||||
false = "выкл"
|
false = "выкл",
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem :: struct {
|
MenuItem :: struct {
|
||||||
|
@ -28,7 +29,7 @@ MenuList :: struct($T: typeid) {
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
active_element: T,
|
active_element: T,
|
||||||
active_marker: vec2,
|
active_marker: vec2,
|
||||||
tween: ^Tween,
|
tween: ^ntween.Tween(f32),
|
||||||
elements: ^[T]MenuItem,
|
elements: ^[T]MenuItem,
|
||||||
menu_pressed: proc(state: ^GameState, element: T),
|
menu_pressed: proc(state: ^GameState, element: T),
|
||||||
background: rl.Color,
|
background: rl.Color,
|
||||||
|
@ -46,12 +47,10 @@ menu_list_update :: proc(list: ^MenuList($T)) {
|
||||||
list.mouse_pos = rl.GetMousePosition()
|
list.mouse_pos = rl.GetMousePosition()
|
||||||
|
|
||||||
size := menu_list_get_size(list)
|
size := menu_list_get_size(list)
|
||||||
if rl.CheckCollisionPointRec(list.mouse_pos, rl.Rectangle{
|
if rl.CheckCollisionPointRec(
|
||||||
x = list.position.x,
|
list.mouse_pos,
|
||||||
y = list.position.y,
|
rl.Rectangle{x = list.position.x, y = list.position.y, width = size.x, height = size.y},
|
||||||
width = size.x,
|
) {
|
||||||
height = size.y,
|
|
||||||
}) {
|
|
||||||
if last_mouse_pos != list.mouse_pos {
|
if last_mouse_pos != list.mouse_pos {
|
||||||
mouse_relative := list.mouse_pos - list.position
|
mouse_relative := list.mouse_pos - list.position
|
||||||
cur_element = i8(mouse_relative.y / list.line_size)
|
cur_element = i8(mouse_relative.y / list.line_size)
|
||||||
|
@ -63,7 +62,6 @@ menu_list_update :: proc(list: ^MenuList($T)) {
|
||||||
last_mouse_pos = list.mouse_pos
|
last_mouse_pos = list.mouse_pos
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if rl.IsKeyPressed(rl.KeyboardKey.DOWN) {
|
if rl.IsKeyPressed(rl.KeyboardKey.DOWN) {
|
||||||
cur_element += 1
|
cur_element += 1
|
||||||
}
|
}
|
||||||
|
@ -75,9 +73,10 @@ menu_list_update :: proc(list: ^MenuList($T)) {
|
||||||
if cur_element == len(T) {cur_element = 0}
|
if cur_element == len(T) {cur_element = 0}
|
||||||
list.active_element = cast(T)cur_element
|
list.active_element = cast(T)cur_element
|
||||||
if list.tween != nil {
|
if list.tween != nil {
|
||||||
tween_cancel(list.tween)
|
ntween.cancel(list.tween)
|
||||||
}
|
}
|
||||||
list.tween = tween_to(
|
list.tween = ntween.animate(
|
||||||
|
&f32_tweens,
|
||||||
&list.active_marker.y,
|
&list.active_marker.y,
|
||||||
f32(list.active_element) * list.line_size,
|
f32(list.active_element) * list.line_size,
|
||||||
0.25,
|
0.25,
|
||||||
|
@ -94,7 +93,14 @@ menu_list_draw :: proc(list: ^MenuList($T)) {
|
||||||
size := menu_list_get_size(list)
|
size := menu_list_get_size(list)
|
||||||
rl.DrawRectangleV(list.position - {40, 40}, size + {80, 80}, list.background)
|
rl.DrawRectangleV(list.position - {40, 40}, size + {80, 80}, list.background)
|
||||||
}
|
}
|
||||||
rl.DrawTextEx(Res.Fonts.UI, ">", list.position + list.active_marker + {-30, 0}, 48, 2, rl.WHITE)
|
rl.DrawTextEx(
|
||||||
|
Res.Fonts.UI,
|
||||||
|
">",
|
||||||
|
list.position + list.active_marker + {-30, 0},
|
||||||
|
48,
|
||||||
|
2,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
for el, i in list.elements {
|
for el, i in list.elements {
|
||||||
pos := list.position + {0, f32(i) * list.line_size}
|
pos := list.position + {0, f32(i) * list.line_size}
|
||||||
text := el.text
|
text := el.text
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 7136c68f3e63470b9b1c80109dd0904151e08070
|
40
pause.odin
40
pause.odin
|
@ -1,30 +1,29 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import rl "vendor:raylib"
|
|
||||||
import "core:math/ease"
|
import "core:math/ease"
|
||||||
|
import "ntween"
|
||||||
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
|
|
||||||
Pause_Buttons :: enum {
|
Pause_Buttons :: enum {
|
||||||
CONTINUE,
|
CONTINUE,
|
||||||
EXIT
|
EXIT,
|
||||||
}
|
}
|
||||||
|
|
||||||
pause_strings := [Pause_Buttons]cstring {
|
pause_strings := [Pause_Buttons]cstring {
|
||||||
.CONTINUE = "Продолжить",
|
.CONTINUE = "Продолжить",
|
||||||
.EXIT = "Прервать игру"
|
.EXIT = "Прервать игру",
|
||||||
}
|
}
|
||||||
|
|
||||||
pause_items := [Pause_Buttons]MenuItem {
|
pause_items := [Pause_Buttons]MenuItem {
|
||||||
.CONTINUE = {text = pause_strings[.CONTINUE]},
|
.CONTINUE = {text = pause_strings[.CONTINUE]},
|
||||||
.EXIT = {text = pause_strings[.EXIT]}
|
.EXIT = {text = pause_strings[.EXIT]},
|
||||||
}
|
}
|
||||||
|
|
||||||
Pause :: struct {
|
Pause :: struct {
|
||||||
using state: GameState,
|
using state: GameState,
|
||||||
|
|
||||||
active: bool,
|
active: bool,
|
||||||
list: MenuList(Pause_Buttons),
|
list: MenuList(Pause_Buttons),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pause_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
pause_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
||||||
|
@ -37,7 +36,7 @@ pause_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
||||||
font_size = 48,
|
font_size = 48,
|
||||||
elements = &pause_items,
|
elements = &pause_items,
|
||||||
menu_pressed = pause_button_pressed,
|
menu_pressed = pause_button_pressed,
|
||||||
background = rl.Color{50, 10, 110, 0}
|
background = rl.Color{50, 10, 110, 0},
|
||||||
}
|
}
|
||||||
state.update = pause_update
|
state.update = pause_update
|
||||||
state.draw = pause_draw
|
state.draw = pause_draw
|
||||||
|
@ -45,7 +44,7 @@ pause_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
||||||
state.previous = prev
|
state.previous = prev
|
||||||
state.active = true
|
state.active = true
|
||||||
|
|
||||||
tween_to(&state.list.position.x, 100, 0.5, ease.Ease.Back_Out)
|
ntween.animate(&f32_tweens, &state.list.position.x, 100, 0.5, ease.Ease.Back_Out)
|
||||||
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,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, state, proc(data: rawptr) {
|
ntween.animate(
|
||||||
|
&f32_tweens,
|
||||||
|
&Overlay_Opacity,
|
||||||
|
1.0,
|
||||||
|
0.5,
|
||||||
|
ease.Ease.Cubic_Out,
|
||||||
|
state,
|
||||||
|
proc(data: rawptr) {
|
||||||
state := transmute(^GameState)data
|
state := transmute(^GameState)data
|
||||||
stack_pop()
|
stack_pop()
|
||||||
game := transmute(^Game)stack_top()
|
game := transmute(^Game)stack_top()
|
||||||
|
@ -74,8 +80,9 @@ pause_button_pressed :: proc(state: ^GameState, el: Pause_Buttons) {
|
||||||
menu := menu_init(game)
|
menu := menu_init(game)
|
||||||
stack_push(menu)
|
stack_push(menu)
|
||||||
//free(state)
|
//free(state)
|
||||||
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
ntween.animate(&f32_tweens, &Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +95,16 @@ pause_draw :: proc(state: ^GameState) {
|
||||||
TitleSpacing :: 3
|
TitleSpacing :: 3
|
||||||
TitleText :: "Ragnarøkkr"
|
TitleText :: "Ragnarøkkr"
|
||||||
TitleSize := rl.MeasureTextEx(Res.Fonts.Title, TitleText, TitleFontSize, TitleSpacing)
|
TitleSize := rl.MeasureTextEx(Res.Fonts.Title, TitleText, TitleFontSize, TitleSpacing)
|
||||||
rl.DrawTextPro(Res.Fonts.Title, TitleText, {WSize.x - 50, 50}, {TitleSize.x, 0}, 0, 96, 3, rl.WHITE)
|
rl.DrawTextPro(
|
||||||
|
Res.Fonts.Title,
|
||||||
|
TitleText,
|
||||||
|
{WSize.x - 50, 50},
|
||||||
|
{TitleSize.x, 0},
|
||||||
|
0,
|
||||||
|
96,
|
||||||
|
3,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
|
|
||||||
menu_list_draw(&pause.list)
|
menu_list_draw(&pause.list)
|
||||||
|
|
||||||
|
|
34
player.odin
34
player.odin
|
@ -1,14 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:math"
|
||||||
|
import "core:math/ease"
|
||||||
|
import "core:math/rand"
|
||||||
|
import "core:slice"
|
||||||
|
import "core:strings"
|
||||||
|
import "ntween"
|
||||||
import rl "vendor:raylib"
|
import rl "vendor:raylib"
|
||||||
import "vendor:raylib/rlgl"
|
import "vendor:raylib/rlgl"
|
||||||
import "core:math"
|
|
||||||
import "core:strings"
|
|
||||||
import "core:math/rand"
|
|
||||||
import "core:math/ease"
|
|
||||||
import "core:fmt"
|
|
||||||
import "core:slice"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// PlayerAnims : [^]rl.ModelAnimation
|
// PlayerAnims : [^]rl.ModelAnimation
|
||||||
|
@ -64,11 +64,12 @@ player_update :: proc(player: ^Player, game: ^Game, delta: f32) {
|
||||||
|
|
||||||
mouse_ray := rl.GetMouseRay(rl.GetMousePosition(), game.camera)
|
mouse_ray := rl.GetMouseRay(rl.GetMousePosition(), game.camera)
|
||||||
mouse_pos: vec3
|
mouse_pos: vec3
|
||||||
hit := rl.GetRayCollisionQuad(mouse_ray,
|
hit := rl.GetRayCollisionQuad(
|
||||||
|
mouse_ray,
|
||||||
{-1000, -1000, 0},
|
{-1000, -1000, 0},
|
||||||
{-1000, 1000, 0},
|
{-1000, 1000, 0},
|
||||||
{1000, 1000, 0},
|
{1000, 1000, 0},
|
||||||
{1000, -1000, 0}
|
{1000, -1000, 0},
|
||||||
)
|
)
|
||||||
if hit.hit {
|
if hit.hit {
|
||||||
mouse_pos = hit.point
|
mouse_pos = hit.point
|
||||||
|
@ -144,7 +145,13 @@ player_update :: proc(player: ^Player, game: ^Game, delta: f32) {
|
||||||
can_dodge = false
|
can_dodge = false
|
||||||
rl.StopSound(Res.Sfx.Rocket)
|
rl.StopSound(Res.Sfx.Rocket)
|
||||||
rl.PlaySound(Res.Sfx.PlayerSwoosh)
|
rl.PlaySound(Res.Sfx.PlayerSwoosh)
|
||||||
tween_to(&player.rolling, math.PI*2, 0.42, ease.Ease.Quadratic_Out)
|
ntween.animate(
|
||||||
|
&f32_tweens,
|
||||||
|
&player.rolling,
|
||||||
|
math.PI * 2,
|
||||||
|
0.42,
|
||||||
|
ease.Ease.Quadratic_Out,
|
||||||
|
)
|
||||||
timer_start(0.45, player, proc(data: rawptr) {
|
timer_start(0.45, player, proc(data: rawptr) {
|
||||||
player := transmute(^Player)data
|
player := transmute(^Player)data
|
||||||
player.is_dodging = false
|
player.is_dodging = false
|
||||||
|
@ -167,7 +174,10 @@ player_update :: proc(player: ^Player, game: ^Game, delta: f32) {
|
||||||
}
|
}
|
||||||
if can_shoot {
|
if can_shoot {
|
||||||
roll := -math.PI / 2 + math.cos(dir) * math.PI / 2
|
roll := -math.PI / 2 + math.cos(dir) * math.PI / 2
|
||||||
b := bullet_spawn(pos + get_vec_from_angle(dir) * 3 + get_vec_from_angle(dir+math.PI/2)*.3, dir)
|
b := bullet_spawn(
|
||||||
|
pos + get_vec_from_angle(dir) * 3 + get_vec_from_angle(dir + math.PI / 2) * .3,
|
||||||
|
dir,
|
||||||
|
)
|
||||||
append(&game.bullets, b)
|
append(&game.bullets, b)
|
||||||
can_shoot = false
|
can_shoot = false
|
||||||
timer_start(0.07, player, proc(data: rawptr) {
|
timer_start(0.07, player, proc(data: rawptr) {
|
||||||
|
@ -205,7 +215,7 @@ player_update :: proc(player: ^Player, game: ^Game, delta: f32) {
|
||||||
}
|
}
|
||||||
ray := rl.Ray {
|
ray := rl.Ray {
|
||||||
position = Head.pos,
|
position = Head.pos,
|
||||||
direction = get_vec_from_angle(Head.dir)
|
direction = get_vec_from_angle(Head.dir),
|
||||||
}
|
}
|
||||||
if Head.is_shooting && rl.GetRayCollisionSphere(ray, pos, radius + 3).hit {
|
if Head.is_shooting && rl.GetRayCollisionSphere(ray, pos, radius + 3).hit {
|
||||||
got_hit = true
|
got_hit = true
|
||||||
|
|
80
tween.odin
80
tween.odin
|
@ -1,80 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import "core:math"
|
|
||||||
import "core:math/ease"
|
|
||||||
import "core:math/linalg"
|
|
||||||
import "core:slice"
|
|
||||||
|
|
||||||
|
|
||||||
Tween :: struct {
|
|
||||||
ptr: ^f32,
|
|
||||||
from: f32,
|
|
||||||
to: f32,
|
|
||||||
time: f32,
|
|
||||||
duration: f32,
|
|
||||||
ease_type: ease.Ease,
|
|
||||||
active: bool,
|
|
||||||
finished: proc(data: rawptr),
|
|
||||||
data: rawptr
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tweens : [dynamic]^Tween
|
|
||||||
|
|
||||||
|
|
||||||
tween_clean :: proc() {
|
|
||||||
for tween, i in tweens {
|
|
||||||
free(tween)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tween_to :: proc(
|
|
||||||
value: ^f32, to: f32, duration: f32,
|
|
||||||
ease: ease.Ease = ease.Ease.Quartic_In_Out,
|
|
||||||
data: rawptr = nil,
|
|
||||||
callback: proc(data: rawptr) = nil
|
|
||||||
) -> ^Tween {
|
|
||||||
|
|
||||||
tween := new(Tween)
|
|
||||||
tween.ptr = value
|
|
||||||
tween.from = value^
|
|
||||||
tween.to = to
|
|
||||||
tween.duration = duration
|
|
||||||
tween.ease_type = ease
|
|
||||||
tween.active = true
|
|
||||||
tween.data = data
|
|
||||||
tween.finished = callback
|
|
||||||
|
|
||||||
append(&tweens, tween)
|
|
||||||
return tween
|
|
||||||
}
|
|
||||||
|
|
||||||
tween_cancel :: proc(t: ^Tween) {
|
|
||||||
t.active = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tweens_process :: proc(delta: f32) {
|
|
||||||
#reverse for tween, i in tweens {
|
|
||||||
|
|
||||||
tween.time += delta
|
|
||||||
p := clamp(tween.time / tween.duration, 0, 1)
|
|
||||||
|
|
||||||
val := ease.ease(tween.ease_type, p)
|
|
||||||
if tween.ptr != nil {
|
|
||||||
tween.ptr^ = math.lerp(tween.from, tween.to, val)
|
|
||||||
} else {
|
|
||||||
tween.active = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if tween.time >= tween.duration {
|
|
||||||
tween.active = false
|
|
||||||
if tween.finished != nil {
|
|
||||||
tween.finished(tween.data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !tween.active {
|
|
||||||
free(tween)
|
|
||||||
unordered_remove(&tweens, i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
53
winning.odin
53
winning.odin
|
@ -1,8 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import rl "vendor:raylib"
|
|
||||||
import "core:math/ease"
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
|
import "core:math/ease"
|
||||||
|
import "ntween"
|
||||||
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
|
|
||||||
Winning :: struct {
|
Winning :: struct {
|
||||||
|
@ -22,7 +23,15 @@ winning_init :: proc(prev: ^GameState = nil) -> ^GameState {
|
||||||
state.free = winning_free
|
state.free = winning_free
|
||||||
|
|
||||||
state.previous = prev
|
state.previous = prev
|
||||||
tween_to(&state.position.y, WSize.y / 2, 1, ease.Ease.Back_Out, state, winning_ready)
|
ntween.animate(
|
||||||
|
&vec2_tweens,
|
||||||
|
&state.position,
|
||||||
|
WSize / 2,
|
||||||
|
1,
|
||||||
|
ease.Ease.Back_Out,
|
||||||
|
state,
|
||||||
|
winning_ready,
|
||||||
|
)
|
||||||
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
@ -33,7 +42,14 @@ winning_update :: proc(state: ^GameState, delta: f32) {
|
||||||
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
if rl.IsKeyPressed(rl.KeyboardKey.ESCAPE) {
|
||||||
winning.ready_to_go = false
|
winning.ready_to_go = false
|
||||||
rl.StopMusicStream(current_music)
|
rl.StopMusicStream(current_music)
|
||||||
tween_to(&Overlay_Opacity, 1.0, 0.5, ease.Ease.Cubic_Out, nil, proc(data: rawptr) {
|
ntween.animate(
|
||||||
|
&f32_tweens,
|
||||||
|
&Overlay_Opacity,
|
||||||
|
1.0,
|
||||||
|
0.5,
|
||||||
|
ease.Ease.Cubic_Out,
|
||||||
|
nil,
|
||||||
|
proc(data: rawptr) {
|
||||||
state := transmute(^GameState)data
|
state := transmute(^GameState)data
|
||||||
stack_pop()
|
stack_pop()
|
||||||
game := transmute(^Game)state.previous
|
game := transmute(^Game)state.previous
|
||||||
|
@ -41,8 +57,9 @@ winning_update :: proc(state: ^GameState, delta: f32) {
|
||||||
menu := menu_init(game)
|
menu := menu_init(game)
|
||||||
stack_push(menu)
|
stack_push(menu)
|
||||||
free(state)
|
free(state)
|
||||||
tween_to(&Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
ntween.animate(&f32_tweens, &Overlay_Opacity, 0, 0.5, ease.Ease.Cubic_Out)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,15 +76,33 @@ winning_draw :: proc(state: ^GameState) {
|
||||||
TitleSpacing :: 3
|
TitleSpacing :: 3
|
||||||
TitleText :: "GAME OVER"
|
TitleText :: "GAME OVER"
|
||||||
|
|
||||||
SubtitleText := [?]cstring{"Тор смог спасти Асгард", "от Рагнарёка!", "Нажмите Escape чтобы выйти"}
|
SubtitleText := [?]cstring {
|
||||||
|
"Тор смог спасти Асгард",
|
||||||
|
"от Рагнарёка!",
|
||||||
|
"Нажмите Escape чтобы выйти",
|
||||||
|
}
|
||||||
SubtitleFontSize :: 48
|
SubtitleFontSize :: 48
|
||||||
|
|
||||||
|
|
||||||
rl.DrawRectangleV(winning.position - winning.size / 2, winning.size, rl.Color{90, 30, 150, 10})
|
rl.DrawRectangleV(winning.position - winning.size / 2, winning.size, rl.Color{90, 30, 150, 10})
|
||||||
|
|
||||||
draw_text_centered(Res.Fonts.Title, TitleText, winning.position - {0, 100}, TitleFontSize, 1, rl.WHITE)
|
draw_text_centered(
|
||||||
|
Res.Fonts.Title,
|
||||||
|
TitleText,
|
||||||
|
winning.position - {0, 100},
|
||||||
|
TitleFontSize,
|
||||||
|
1,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
for c, i in SubtitleText {
|
for c, i in SubtitleText {
|
||||||
draw_text_centered(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleFontSize, 1, rl.WHITE)
|
draw_text_centered(
|
||||||
|
Res.Fonts.UI,
|
||||||
|
c,
|
||||||
|
winning.position - {0, f32(10 - i * 50)},
|
||||||
|
SubtitleFontSize,
|
||||||
|
1,
|
||||||
|
rl.WHITE,
|
||||||
|
)
|
||||||
// rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE)
|
// rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, rl.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue