refactor out to SFX class

This commit is contained in:
ethan merchant 2024-11-04 04:28:05 -05:00
parent e9c8e96d7f
commit b5568e2a68
3 changed files with 15 additions and 11 deletions

View file

@ -30,14 +30,6 @@ static class Mono
public static DeltaBool food_fall = new(false); public static DeltaBool food_fall = new(false);
public static double eat_timestamp = 0.0; public static double eat_timestamp = 0.0;
// put in SFX static class
static void PlayBox(this Sound sound, XYZi pos)
{
sound.Play(box_pose.ToMatrix(box_scale) * pos.ToVec3);
}
public static Sound sfx_crisp_nom = Sound.FromFile("sfx/crisp_nom.mp3");
public static Sound sfx_punch_through = Sound.FromFile("sfx/punch_through.mp3");
public static void Init() public static void Init()
{ {
for (int i = 0; i < snake.Length; i++) for (int i = 0; i < snake.Length; i++)
@ -145,7 +137,7 @@ static class Mono
if (in_box.delta != 0) // 1 just in -1 just out if (in_box.delta != 0) // 1 just in -1 just out
{ {
holes.Add(snake[0], snake_dir); holes.Add(snake[0], snake_dir);
sfx_punch_through.PlayBox(snake[0]); SFX.punch_through.PlayBox(snake[0]);
} }
if (holes.ContainsKey(snake[snake_len - 1])) if (holes.ContainsKey(snake[snake_len - 1]))
{ {
@ -165,7 +157,7 @@ static class Mono
grow_buffer += 3; grow_buffer += 3;
Feed(); Feed();
sfx_crisp_nom.PlayBox(snake[0]); SFX.crisp_nom.PlayBox(snake[0]);
} }
} }

View file

@ -1,4 +1,3 @@
using System.Collections.Generic;
using StereoKit; using StereoKit;
namespace snake; namespace snake;

13
src/SFX.cs Normal file
View file

@ -0,0 +1,13 @@
using StereoKit;
namespace snake;
static class SFX
{
public static void PlayBox(this Sound sound, XYZi pos)
{
sound.Play(Mono.box_pose.ToMatrix(Mono.box_scale) * pos.ToVec3);
}
public static Sound crisp_nom = Sound.FromFile("sfx/crisp_nom.mp3");
public static Sound punch_through = Sound.FromFile("sfx/punch_through.mp3");
}