Sounds are working

This commit is contained in:
2023-07-23 20:10:40 +10:00
parent ab4c8de8c0
commit dee5bea96d
5 changed files with 11 additions and 2 deletions

2
Box

Submodule Box updated: aded9f54be...a2382c19b4

View File

@@ -1,5 +1,6 @@
import standard;
import node;
import sound;
//constants
@@ -29,6 +30,9 @@ var attackPositionY: int = null;
var walkAnimationCounter: int = 0;
var attackAnimationCounter: int = 0;
//audio utils
var kickSound: opaque = null;
//accessors & mutators
fn setGridPosition(node: opaque, x: int, y: int) {
@@ -65,6 +69,8 @@ fn getAttackPositionY(node: opaque) {
fn onLoad(node: opaque) {
node.loadNodeTexture("sprites:/parvati.png"); //NOTE: all of this script is mapped to this sprite sheet
node.faceDirection(DIRECTION_DOWN);
kickSound = loadSound("sound:/attack.ogg");
}
//fn onUpdate(node: opaque, delta: int) {
@@ -159,6 +165,7 @@ fn onStep(node: opaque) {
fn onFree(node: opaque) {
node.freeNodeTexture();
kickSound.freeSound();
}
fn onDraw(node: opaque) {
@@ -203,6 +210,8 @@ fn onKeyDown(node: opaque, event: string) {
node.setAttackPosition(gridPositionX - 1, gridPositionY);
}
kickSound.playSound();
return;
}

View File

@@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
Toy_setDrivePath("sprites", "assets/sprites");
Toy_setDrivePath("audio", "assets/audio");
Toy_setDrivePath("music", "assets/audio/music");
Toy_setDrivePath("sounds", "assets/audio/sounds");
Toy_setDrivePath("sound", "assets/audio/sound");
Toy_setDrivePath("fonts", "assets/fonts");
Box_initEngine("scripts:/init.toy");