Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

SFX issues

A topic by crap eyes created Jul 29, 2017 Views: 939 Replies: 2
Viewing posts 1 to 2
(1 edit)

for some reason the sound effects aren't working.

I had one sound effect that was supposed to play when you fired your gun in my game and it worked fine. Then I added another effect for your knife (it was above it in the code, if that's important) and it worked, but the gun sound now won't play. So then I add a door closing sound effect, and they all stop working. I don't know if it is a bug in Tic80 or if its my fault but I'd like to know.

I am on Android and coding in lua if that's important.

My code

start=2
t=0
x=0
y=-120
anim=257
ammo=50
bulletx=100
bullety=64
bulletexist1=0
weapon=276
knswing=0
ctxt=""

local tiles={}
function TIC()
 
cls(12)
map(x,y)
if start==2 then --Keep at top. to run after start
bulletx=bulletx+1

if btn(0) then y=y-0.2 end
if btn(1) then y=y+0.2 end
if btn(2) then x=x-0.2 end
if btn(3) then x=x+0.2 end
if btn(1) then anim=anim+1 end
if anim==260 then anim=257 end
if btn(7) then weapon=277 end

--Shooting/Attacking
if weapon==276 then
if btnp(6) then
spr(296,107,64,0,1)
sfx(02,12,20)
knswing=2
else knswing=0
end
end

if not weapon==276 then
if ammo>0 then
if btn(6) then 
bulletx=100
sfx(4,18,20) 
end
if btnp(6) then bulletexists1=1 end
if bulletexists==1 then
local bx=100
local by=64
bx=bx+1
spr(290,bx,by,0)
ammo=ammo-1
end
end
end


if btn(5) then mset(x,y,050) end
print(ammo,10,10)
spr(anim,104,64,0,1)
spr(weapon,107,64,0,1,knswing)
if t<150 then 
print("Objective: Find a cure",80,20)
else
sfx(06,54,20)
mset(15,21,039)
mset(15,20,040)
end

If you try to play two sounds on one channel, only last one will play. You need to give unique channels if you want to hear all of 3 sounds at once, check: https://github.com/nesbox/tic.computer/wiki/sfx

hmm thats weird but I'll try it