--Soundboard 0.1 (alpha) (1-12-2009) (Build 105)
--By:corytheidiot (aka corytheidiot1) (corytheidiot@gmail.com)
speed = 4
dofile("config.lua")--config file

white = Color.new(255,255,255)


soun12 = Sound.load("sounds/" ..sound1x2, false)
soun13 = Sound.load("sounds/" ..sound1x3, false)
soun14 = Sound.load("sounds/" ..sound1x4, false)
soun15 = Sound.load("sounds/" ..sound1x5, false)
soun16 = Sound.load("sounds/" ..sound1x6, false)
soun17 = Sound.load("sounds/" ..sound1x7, false)
soun18 = Sound.load("sounds/" ..sound1x8, false)
soun19 = Sound.load("sounds/" ..sound1x9, false)

soun22 = Sound.load("sounds/" ..sound2x2, false)
soun23 = Sound.load("sounds/" ..sound2x3, false)
soun24 = Sound.load("sounds/" ..sound2x4, false)
soun25 = Sound.load("sounds/" ..sound2x5, false)
soun26 = Sound.load("sounds/" ..sound2x6, false)
soun27 = Sound.load("sounds/" ..sound2x7, false)
soun28 = Sound.load("sounds/" ..sound2x8, false)
soun29 = Sound.load("sounds/" ..sound2x9, false)

soun32 = Sound.load("sounds/" ..sound3x2, false)
soun33 = Sound.load("sounds/" ..sound3x3, false)
soun34 = Sound.load("sounds/" ..sound3x4, false)
soun35 = Sound.load("sounds/" ..sound3x5, false)
soun36 = Sound.load("sounds/" ..sound3x6, false)
soun37 = Sound.load("sounds/" ..sound3x7, false)
soun38 = Sound.load("sounds/" ..sound3x8, false)
soun39 = Sound.load("sounds/" ..sound3x9, false)

soun42 = Sound.load("sounds/" ..sound1x2, false)
soun43 = Sound.load("sounds/" ..sound1x3, false)
soun44 = Sound.load("sounds/" ..sound1x4, false)
soun45 = Sound.load("sounds/" ..sound1x5, false)
soun46 = Sound.load("sounds/" ..sound1x6, false)
soun47 = Sound.load("sounds/" ..sound1x7, false)
soun48 = Sound.load("sounds/" ..sound1x8, false)
soun49 = Sound.load("sounds/" ..sound1x9, false)


but12 = Image.load("images/" ..button1x2)
but13 = Image.load("images/" ..button1x3)
but14 = Image.load("images/" ..button1x4)
but15 = Image.load("images/" ..button1x5)
but16 = Image.load("images/" ..button1x6)
but17 = Image.load("images/" ..button1x7)
but18 = Image.load("images/" ..button1x8)
but19 = Image.load("images/" ..button1x9)

but22 = Image.load("images/" ..button2x2)
but23 = Image.load("images/" ..button2x3)
but24 = Image.load("images/" ..button2x4)
but25 = Image.load("images/" ..button2x5)
but26 = Image.load("images/" ..button2x6)
but27 = Image.load("images/" ..button2x7)
but28 = Image.load("images/" ..button2x8)
but29 = Image.load("images/" ..button2x9)

but32 = Image.load("images/" ..button3x2)
but33 = Image.load("images/" ..button3x3)
but34 = Image.load("images/" ..button3x4)
but35 = Image.load("images/" ..button3x5)
but36 = Image.load("images/" ..button3x6)
but37 = Image.load("images/" ..button3x7)
but38 = Image.load("images/" ..button3x8)
but39 = Image.load("images/" ..button3x9)

but42 = Image.load("images/" ..button4x2)
but43 = Image.load("images/" ..button4x3)
but44 = Image.load("images/" ..button4x4)
but45 = Image.load("images/" ..button4x5)
but46 = Image.load("images/" ..button4x6)
but47 = Image.load("images/" ..button4x7)
but48 = Image.load("images/" ..button4x8)
but49 = Image.load("images/" ..button4x9)

background = Image.load("images/background.png")

pointer = {}
	pointer.x = 1
	pointer.y = 1
	pointer.img = Image.load("images/pointer.png")

function pointer_controls()
	if pad:right() then pointer.x = pointer.x + speed end
	if pad:left() then pointer.x = pointer.x - speed end
	if pad:down() then pointer.y = pointer.y + speed end
	if pad:up() then pointer.y = pointer.y - speed end

	if pointer.y <= 0 then pointer.y = oldy end
	if pointer.y >= 272 then pointer.y = oldy end
	if pointer.x >= 480 then pointer.x = oldx end
	if pointer.x <= 0 then pointer.x = oldx end
end

while true do
oldx = pointer.x
oldy = pointer.y
oldpad = pad
pad = Controls.read()
screen:clear()

pointer_controls()

screen:blit(0,0, background)


screen:blit(0,30, but12)
screen:blit(0,60, but13)
screen:blit(0,90, but14)
screen:blit(0,120, but15)
screen:blit(0,150, but16)
screen:blit(0,180, but17)
screen:blit(0,210, but18)
screen:blit(0,240, but19)


screen:blit(130,30, but22)
screen:blit(130,60, but23)
screen:blit(130,90, but24)
screen:blit(130,120, but25)
screen:blit(130,150, but26)
screen:blit(130,180, but27)
screen:blit(130,210, but28)
screen:blit(130,240, but29)


screen:blit(260,30, but32)
screen:blit(260,60, but33)
screen:blit(260,90, but34)
screen:blit(260,120, but35)
screen:blit(260,150, but36)
screen:blit(260,180, but37)
screen:blit(260,210, but38)
screen:blit(260,240, but39)


screen:blit(390,30, but42)
screen:blit(390,60, but43)
screen:blit(390,90, but44)
screen:blit(390,120, but45)
screen:blit(390,150, but46)
screen:blit(390,180, but47)
screen:blit(390,210, but48)
screen:blit(390,240, but49)






locationy = math.floor(pointer.x / 120)
locationx = math.floor(pointer.y / 30)


screen:blit(pointer.x, pointer.y, pointer.img) 


if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 1 then soun12:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 2 then soun13:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 3 then soun14:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 4 then soun15:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 5 then soun16:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 6 then soun17:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 7 then soun18:play() end
if pad:cross() and pad ~= oldpad and locationy == 0 and locationx == 8 then soun19:play() end

if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 1 then soun22:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 2 then soun23:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 3 then soun24:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 4 then soun25:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 5 then soun26:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 6 then soun27:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 7 then soun28:play() end
if pad:cross() and pad ~= oldpad and locationy == 1 and locationx == 8 then soun29:play() end

if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 1 then soun32:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 2 then soun33:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 3 then soun34:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 4 then soun35:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 5 then soun36:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 6 then soun37:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 7 then soun38:play() end
if pad:cross() and pad ~= oldpad and locationy == 2 and locationx == 8 then soun39:play() end

if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 1 then soun32:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 2 then soun33:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 3 then soun34:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 4 then soun35:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 5 then soun36:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 6 then soun37:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 7 then soun38:play() end
if pad:cross() and pad ~= oldpad and locationy == 3 and locationx == 8 then soun39:play() end


screen.waitVblankStart()
screen.flip()
end