wtf I don't know
parent
a9fcca4246
commit
ff7acaa28e
|
@ -1 +0,0 @@
|
||||||
hrtf = false
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,5 +5,4 @@ sounds=group("audio/enemies/1")
|
||||||
sounds.loop:setLooping(true)
|
sounds.loop:setLooping(true)
|
||||||
enemyBasic.super.new(self,x,y,sounds)
|
enemyBasic.super.new(self,x,y,sounds)
|
||||||
sounds.loop:play()
|
sounds.loop:play()
|
||||||
|
|
||||||
end
|
end
|
23
enemy.lua
23
enemy.lua
|
@ -1,12 +1,18 @@
|
||||||
enemy=object:extend()
|
enemy=object:extend()
|
||||||
|
|
||||||
function enemy:new(x,y,sounds)
|
function enemy:new(x,y,sounds,hp)
|
||||||
self.x=x
|
self.x=x
|
||||||
self.y=y
|
self.y=y
|
||||||
self.dx=0
|
self.dx=0
|
||||||
self.dy=-1
|
self.dy=-1
|
||||||
|
self.hp=hp or 10
|
||||||
self.sounds=sounds;
|
self.sounds=sounds;
|
||||||
sounds.loop:setPosition(x,y,0)
|
sounds.loop:setPosition(x,y,0)
|
||||||
|
for k,v in pairs(sounds) do
|
||||||
|
if v:typeOf("Source") then
|
||||||
|
v:setAttenuationDistances(110,game.field.height)
|
||||||
|
end
|
||||||
|
end
|
||||||
self.lastMoveTick=0
|
self.lastMoveTick=0
|
||||||
self.rate=game.currentTrack.info.beatDivisions
|
self.rate=game.currentTrack.info.beatDivisions
|
||||||
end -- new
|
end -- new
|
||||||
|
@ -21,5 +27,16 @@ function enemy:move()
|
||||||
self.lastMoveTick=game.ticker.ticks
|
self.lastMoveTick=game.ticker.ticks
|
||||||
self.x=self.x+self.dx
|
self.x=self.x+self.dx
|
||||||
self.y=self.y+self.dy
|
self.y=self.y+self.dy
|
||||||
self.sounds.loop:setPosition(self.x,self.y,0)
|
utils.setSourcePosition(self.sounds.loop, self.x,self.y)
|
||||||
end
|
if(self.y<=0) then self:land() end
|
||||||
|
end
|
||||||
|
|
||||||
|
function enemy:land()
|
||||||
|
tts.say("landed")
|
||||||
|
for k,v in pairs(self.sounds) do
|
||||||
|
if v:typeOf("Source") then
|
||||||
|
if v:isLooping() then v:stop() end
|
||||||
|
end
|
||||||
|
end -- stop all loops
|
||||||
|
self.destroy=true
|
||||||
|
end -- land
|
|
@ -9,5 +9,6 @@ end -- new
|
||||||
function field:update(dt)
|
function field:update(dt)
|
||||||
for k,v in pairs(self.contents) do
|
for k,v in pairs(self.contents) do
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
|
if v.destroy then game.field.contents[k]=nil end
|
||||||
end -- for field
|
end -- for field
|
||||||
end
|
end
|
16
game.lua
16
game.lua
|
@ -1,7 +1,7 @@
|
||||||
require "field"
|
require "field"
|
||||||
|
|
||||||
game={}
|
game={}
|
||||||
game.field=field(40,20)
|
game.field=field(40,30)
|
||||||
game.player=player
|
game.player=player
|
||||||
game.ticker=ticker(0.125)
|
game.ticker=ticker(0.125)
|
||||||
game.currentTrack={}
|
game.currentTrack={}
|
||||||
|
@ -31,7 +31,8 @@ game.trackRunning=false
|
||||||
end -- loadtrack
|
end -- loadtrack
|
||||||
|
|
||||||
function game.init()
|
function game.init()
|
||||||
table.insert(game.field.contents, enemyBasic(5,20))
|
game.meh=enemyBasic(6,game.field.height)
|
||||||
|
table.insert(game.field.contents, game.meh)
|
||||||
function game.ticker:tick()
|
function game.ticker:tick()
|
||||||
for k,event in pairs(game.events) do
|
for k,event in pairs(game.events) do
|
||||||
local adjustedTicks=game.ticker.ticks-1+(event.shift or 0)
|
local adjustedTicks=game.ticker.ticks-1+(event.shift or 0)
|
||||||
|
@ -48,12 +49,17 @@ end -- if fire one-shot event
|
||||||
end -- if recurring
|
end -- if recurring
|
||||||
end -- for events
|
end -- for events
|
||||||
end
|
end
|
||||||
local click={
|
local radar={
|
||||||
i=2,
|
i=1,
|
||||||
recurring=true,
|
recurring=true,
|
||||||
func=function()
|
func=function()
|
||||||
|
for k,v in pairs(game.field.contents) do
|
||||||
|
if v.x==player.x then
|
||||||
aud.meh:stop()
|
aud.meh:stop()
|
||||||
aud.meh:play()
|
aud.meh:play()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
local beep={
|
local beep={
|
||||||
|
@ -64,6 +70,6 @@ aud.beep:stop()
|
||||||
aud.beep:play()
|
aud.beep:play()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
-- game.events.click=click
|
game.events.radar=radar
|
||||||
-- game.events.beep=beep
|
-- game.events.beep=beep
|
||||||
end
|
end
|
5
main.lua
5
main.lua
|
@ -18,7 +18,9 @@ require "player"
|
||||||
require "game"
|
require "game"
|
||||||
require "enemy"
|
require "enemy"
|
||||||
require "enemies/basic"
|
require "enemies/basic"
|
||||||
|
love.audio.setDistanceModel("exponent")
|
||||||
aud=group("audio")
|
aud=group("audio")
|
||||||
|
aud.meh:setRelative(true)
|
||||||
c=require "tracks/gourmet"
|
c=require "tracks/gourmet"
|
||||||
love.timer.sleep(1)
|
love.timer.sleep(1)
|
||||||
game.loadTrack(c)
|
game.loadTrack(c)
|
||||||
|
@ -39,8 +41,7 @@ player.direction=-1
|
||||||
elseif key=="c" then
|
elseif key=="c" then
|
||||||
tts.say(player.x)
|
tts.say(player.x)
|
||||||
elseif key=="d" then
|
elseif key=="d" then
|
||||||
print(love.audio.getOrientation())
|
tts.say(game.meh.y)
|
||||||
love.audio.setPosition(100,0,30)
|
|
||||||
end
|
end
|
||||||
end -- keyPressed
|
end -- keyPressed
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,6 @@ if dx<0 or dx>game.field.width then
|
||||||
-- boundary shit goes here
|
-- boundary shit goes here
|
||||||
else
|
else
|
||||||
player.x=dx
|
player.x=dx
|
||||||
love.audio.setPosition(player.x, player.y, 0)
|
love.audio.setPosition(player.x, player.y, 3)
|
||||||
end -- if boundary
|
end -- if boundary
|
||||||
end
|
end
|
|
@ -9,9 +9,9 @@ function group:addDirectory(directory) files=fs.getDirectoryItems(directory)
|
||||||
sound=love.audio.newSource(fullpath, "static")
|
sound=love.audio.newSource(fullpath, "static")
|
||||||
if sound:typeOf("Source") then
|
if sound:typeOf("Source") then
|
||||||
--print("Loaded " .. nameOnly)
|
--print("Loaded " .. nameOnly)
|
||||||
if sound:getChannelCount()==1 then sound:setRelative(true) end
|
-- if sound:getChannelCount()==1 then sound:setRelative(true) end
|
||||||
self[nameOnly]=sound
|
self[nameOnly]=sound
|
||||||
self.sounds[nameOnly] =sound
|
-- self.sounds[nameOnly] =sound
|
||||||
end --if is a sound
|
end --if is a sound
|
||||||
end --if it's a file
|
end --if it's a file
|
||||||
end -- if it's not a dot
|
end -- if it's not a dot
|
||||||
|
@ -20,7 +20,7 @@ function group:addDirectory(directory) files=fs.getDirectoryItems(directory)
|
||||||
end --addDirectory
|
end --addDirectory
|
||||||
function group:new(directory)
|
function group:new(directory)
|
||||||
|
|
||||||
self.sounds={}
|
-- self.sounds={}
|
||||||
self:addDirectory(directory)
|
self:addDirectory(directory)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -42,7 +42,3 @@ end --setEffect function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
t={
|
|
||||||
a=2,
|
|
||||||
b=3
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
local t={
|
local t={
|
||||||
path="audio/tracks/gourmet.mp3",
|
path="audio/tracks/gourmet.mp3",
|
||||||
bpm=160,
|
bpm=160,
|
||||||
startTime=0.05,
|
startTime=0.02,
|
||||||
beatDivisions=4,
|
beatDivisions=4,
|
||||||
volumeBase=0
|
volumeBase=0.02
|
||||||
}
|
}
|
||||||
|
|
||||||
return track(t)
|
return track(t)
|
|
@ -9,4 +9,10 @@ local closest=math.min(math.abs(time-prevDivTime), math.abs(time-nextDivTime))
|
||||||
local halfDivision=beatDivisions/2*game.ticker.tickTime
|
local halfDivision=beatDivisions/2*game.ticker.tickTime
|
||||||
-- print(math.abs(time-nextDivTime),"to next beat, ",math.abs(time-prevDivTime)," to previous beat. Half division is ",halfDivision,". Closest is ",closest,". The current time is ",time,", and the next division is at ", nextDivTime,", last tick happened at ",game.ticker.lastTickTime," and is tick number ",game.ticker.ticks)
|
-- print(math.abs(time-nextDivTime),"to next beat, ",math.abs(time-prevDivTime)," to previous beat. Half division is ",halfDivision,". Closest is ",closest,". The current time is ",time,", and the next division is at ", nextDivTime,", last tick happened at ",game.ticker.lastTickTime," and is tick number ",game.ticker.ticks)
|
||||||
return (halfDivision-closest)/halfDivision -- Math is hard
|
return (halfDivision-closest)/halfDivision -- Math is hard
|
||||||
|
end
|
||||||
|
|
||||||
|
local volumeScale=0.0029
|
||||||
|
function utils.setSourcePosition(source, x, y)
|
||||||
|
source:setPosition(x,8,0)
|
||||||
|
source:setVolume(volumeScale*game.field.height-volumeScale*math.abs(player.y-y))
|
||||||
end
|
end
|
Loading…
Reference in New Issue