#Global Hooks
$GameInit:
[
--HudPong (tm)
w = gr.getScreenWidth()
h = gr.getScreenHeight()
poneh = 0
ptwoh = 0
gameh = 200 --you can change this to what
gamew = 220 --ever resolution you want. changed to the shape of a ping pong table.
gamex = w / 2 --set what coords to draw (now set to above reticle)
gamey = h / 5 --the game at here (game center, Y axis).
ballx = gamex
bally = gamey
ballxvel = 2 --changed to make
ballyvel = 3 --it act more like a ping-pong ball
balla = 255
deathmsg = "GAME OVER"
drawpongarea = function(x, y, sx, sy) --pong box here
gr.setColor(0,200,1,255) --pong green
gr.drawLine(x-sx, y+sy, x+sx, y+sy)
gr.drawLine(x-sx, y-sy, x+sx, y-sy)
gr.setColor(0,100,1,20)
gr.drawRectangle(x-sx, y+sy, x+sx, y-sy) --now featuring a transparent back, which is even better now.
end
drawpongpaddle = function(x, y)
gr.setColor(0,10,200,255) --change these number values and change how the paddle looks
gr.drawRectangle(x+5, y+15, x-5, y-15, true)
end
drawpongball = function(x, y, a)
gr.setColor(200,10,10,a) --change these and change the ball
gr.drawCircle(10,x,y)
end
--im nuts
]
$HUD:
[
--HudPong
drawpongarea(gamex,gamey,gamew/2,gameh/2) --draw playing area every frame
if w >= 1024 then --compensate for resolution
maxis1 = ((ms.getY() / 769) * (gameh * 0.9)) --paddels, fixed by takashi to act slightly more realistic
maxis2 = ((ms.getX() / 1019) * (gameh * 0.9))
else
maxis1 = ((ms.getY() / 490) * (gameh * 0.9)) --paddels, see above comment, now in lowres!
maxis2 = ((ms.getX() / 640) * (gameh * 0.9))
end
poneh = (maxis1 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.9)) / 2)
ptwoh = (maxis2 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.9)) / 2)
drawpongpaddle(gamex + (gamew/2) - 5, poneh)
drawpongpaddle(gamex - (gamew/2) + 5, ptwoh)
ballx = ballx + ballxvel --move and draw the ball
bally = bally + ballyvel
drawpongball(ballx, bally, balla)
if bally < (gamey - (gameh / 2)) + 5 or bally > (gamey + (gameh / 2)) - 5 then
ballyvel = ballyvel * -1 --bounce off borders
end
if ballx < (gamex - (gamew / 2)) or ballx > (gamex + (gamew / 2)) then --tell the player when he gets castrated and reset the game
gr.setColor(200,200,100,155)
gr.drawString(deathmsg, gamex - (gr.getStringWidth(deathmsg) / 2) , gamey)
balla = balla - 8
if balla < 1 then
ballx = gamex
bally = gamey
balla = 255
end
end
if (ballx < (gamex - (gamew / 2)) + 15 and bally > ptwoh - 15 and bally < ptwoh + 15) or (ballx > (gamex + (gamew / 2)) - 15 and bally > poneh - 15 and bally < poneh + 15) then
ballxvel = ballxvel * -1 --bounce off paddles
end
--nuts indeed
]
#End
small math fixes. nothing more. and a few color tweaks....