
You guessed it, I'm
attempting to code a pong game for use with DJSP/PSP Advance. :dance: But now I need a tad bit of help. I'm pretty good at Lua now, but this is obviously differnt :think:. Anyway, I coded this pong game using different pong code from two or three different games. Well, when I put this on DJSP/PSP Advance it shows the score... and that's it

, but it plays the game by itself. So, if you guy's could help solve that :Pray: I give you super mad props!!! One other thing... when I add the enable/disabledjspcontrols() thing (you know what I mean), I can't return to DJSP/PSP Advance - but when I take it away I can't play the game. Well here's the code, thanx in advance to everyone who helps:
Code:
disableDJSPControls()
--VAR
p1paddle = 0
p2paddle = 0
ballx = 232
bally = 128
dx = 2
dy = 2
top = 0
bottom = 272
right = 480
left = 0
p1score = 0
p2score = 0
--COLOR
white = rgb(255, 255, 255)
--LOAD IMAGES
background = loadImage("data/images/table.png")
paddle = loadImage("data/images/paddle.png")
ball = loadImage("data/images/ball.png")
--GAME
function startgame()
ballx = 232
bally = 128
starty = math.random(0,1)
startx = math.random(0,1)
if startx == 0
then
dx = -2
else
dx = 2
end
if starty == 0
then
dy = -2
else
dy = 2
end
end
while true do
pad = readControls(true)
ballcenterx = ballx + 8
ballcentery = bally + 8
balltop = bally
ballbottom = bally + 16
ballleft = ballx
ballright = ballx + 16
ballx = ballx + dx
bally = bally + dy
if balltop <= top
then
dy = dy * -1
bally = bally + 5
end
if ballbottom >= bottom
then
dy = dy * -1
bally = bally - 5
end
if ballleft <= 0
then
p2score = p2score + 1
startgame()
end
if ballright >= 480
then
p1score = p1score + 1
startgame()
end
if ltriggerPressed() then
startGame()
end
if trianglePressed()
then
p2paddle = p2paddle - 2
if p2paddle <= 0
then
p2paddle = 0
end
end
if crossPressed()
then
p2paddle = p2paddle + 2
if p2paddle >= 210
then
p2paddle = 210
end
end
if upPressed()
then
p1paddle = p1paddle - 2
if p1paddle <= 0
then
p1paddle = 0
end
end
if downPressed()
then
p1paddle = p1paddle + 2
if p1paddle >= 210
then
p1paddle = 210
end
end
if ballleft <= 44 and ballleft >= 42 and ballcentery >= p1paddle and ballcentery <= p1paddle + 62
then
dx = dx * -1
ballx = ballx + 5
end
if ballright >= 428 and ballright <=430 and ballcentery >= p2paddle and ballcentery <= p2paddle + 62
then
dx = dx * -1
ballx = ballx - 5
end
-- flip screen
drawImage(ball, ballx, bally)
drawImage(paddle, 30, p1paddle)
drawImage(paddle, 428, p2paddle)
drawImage(background, 0, 0)
drawText("Player 1: " .. p1score, 10, 10, white, 0)
drawText("Player 2: " .. p2score, 375, 10, white, 0)
-- waitForVSync()
-- flipScreen()
end
enableDJSPControls()