Fixed winning screen, collisions

This commit is contained in:
Vlad Rud 2024-10-05 21:11:57 +03:00
parent a288d9f1a1
commit e714ead17f
10 changed files with 1028 additions and 112 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
# Made in Blockbench 4.11.1
newmtl m_3faa339c-1a1f-acb0-d167-578e9ad5cc6b
newmtl m_a4450cf3-b34d-625a-0f2a-2e3eff98962f
map_Kd background.png
newmtl none

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -44,7 +44,6 @@ explosions_process :: proc(delta: f32) {
explosions_draw :: proc() {
rl.BeginBlendMode(rl.BlendMode.ADDITIVE)
#reverse for &e, i in explosions {
fmt.println(e.time)
color := rl.ColorAlpha(e.color, 1 - ease.exponential_in(e.time / e.duration))
rl.DrawSphere(e.position, e.radius, color)
}

View File

@ -62,18 +62,14 @@ gameover_draw :: proc(state: ^GameState) {
SubtitleText := [?]cstring{"Нажмите Escape чтобы выйти"}
SubtitleFontSize :: 48
SubtitleSpacing :: 2
SubtitleSizes := [?]vec2{{}}
for c, i in SubtitleText {
SubtitleSizes = rl.MeasureTextEx(Res.Fonts.UI, c, SubtitleFontSize, SubtitleSpacing)
}
rl.DrawRectangleV(gameover.position - gameover.size / 2, gameover.size, rl.Color{90, 30, 150, 10})
rl.DrawTextPro(Res.Fonts.Title, TitleText, gameover.position - {0, 100}, TitleSize / 2, 0, TitleFontSize, TitleSpacing, rl.WHITE)
draw_text_centered(Res.Fonts.Title, TitleText, gameover.position - {0, 100}, TitleFontSize, 1, rl.WHITE)
for c, i in SubtitleText {
rl.DrawTextPro(Res.Fonts.UI, c, gameover.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, 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)
}

View File

@ -75,6 +75,10 @@ player_update :: proc(player: ^Player, game: ^Game, delta: f32) {
if !is_dead {
pos += vel * delta
if pos.y < radius {
pos.y = radius
vel.y = - vel.y
}
if !is_dodging {
dir_vector : vec3
if intro_timer <= 0 {

View File

@ -244,6 +244,10 @@ snake_hunt :: proc(game: ^Game, delta: f32) {
Head.vel = rl.Vector3MoveTowards(Head.vel, rl.Vector3Normalize(target_diff) * 50, 40 * delta)
Head.dir = math.atan2(-Head.vel.y, Head.vel.x)
Head.pos += Head.vel * delta
if Head.pos.y < Head.radius {
Head.pos.y = Head.radius
Head.vel.y = -Head.vel.y / 2
}
}
snake_shot :: proc(game: ^Game, delta: f32) {

View File

@ -26,7 +26,7 @@ get_vec_from_angle :: proc(angle: f32) -> vec3 {
return rl.Vector3RotateByAxisAngle(vec3right, vec3backward, angle)
}
draw_text_centered :: proc(font: rl.Font, text: cstring, pos: vec2, size: f32) {
draw_text_centered :: proc(font: rl.Font, text: cstring, pos: vec2, size: f32, spacing : f32 = 1, color : rl.Color = rl.BLACK) {
text_size := rl.MeasureTextEx(font, text, size, 1)
rl.DrawTextPro(font, text, pos, text_size / 2, 0, size, 1, rl.BLACK)
rl.DrawTextPro(font, text, pos, text_size / 2, 0, size, 1, color)
}

View File

@ -58,22 +58,17 @@ winning_draw :: proc(state: ^GameState) {
TitleFontSize :: 96
TitleSpacing :: 3
TitleText :: "GAME OVER"
TitleSize := rl.MeasureTextEx(Res.Fonts.Title, TitleText, TitleFontSize, TitleSpacing)
SubtitleText := [?]cstring{"Тор смог спасти Асгард от Рагнарёка", "Нажмите Escape чтобы выйти"}
SubtitleText := [?]cstring{"Тор смог спасти Асгард", "от Рагнарёка!", "Нажмите Escape чтобы выйти"}
SubtitleFontSize :: 48
SubtitleSpacing :: 2
SubtitleSizes := [?]vec2{{}, {}}
for c, i in SubtitleText {
SubtitleSizes = rl.MeasureTextEx(Res.Fonts.UI, c, SubtitleFontSize, SubtitleSpacing)
}
rl.DrawRectangleV(winning.position - winning.size / 2, winning.size, rl.Color{90, 30, 150, 10})
rl.DrawTextPro(Res.Fonts.Title, TitleText, winning.position - {0, 100}, TitleSize / 2, 0, TitleFontSize, TitleSpacing, rl.WHITE)
draw_text_centered(Res.Fonts.Title, TitleText, winning.position - {0, 100}, TitleFontSize, 1, rl.WHITE)
for c, i in SubtitleText {
rl.DrawTextPro(Res.Fonts.UI, c, winning.position - {0, f32(10 - i * 50)}, SubtitleSizes[i] / 2, 0, SubtitleFontSize, SubtitleSpacing, 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)
}