€ À À ÀÀÀÀÀÀÀÀ€ > ^ ÀÌÀÌÌÀ ÌÀ Ì Ì Ì Ì ÀÌÀÌÌÌÌÀ ÌÀ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ-- title: Pong -- author: eskyozar(Yohib Hussain) -- desc: pong classic -- script: lua game_state = "menu" pad1 = { position = { x = 10, y = 0 }, spritenum = 0, speed = 1 } pad2 = { position = { x = 220, y = 110 }, spritenum = 3, speed = 2 } ball = { position={ x = 112, y = 50 }, spritenum = 2, xspeed = 1, yspeed = 1, } score1 = 0 score2 = 0 function TIC() if (game_state == "menu")then cls() print("Pong (ver 0.5.0)" ,70,30,12) print("Press z to start",65,40,12) print("Press x for changelog",55,50,12) print("Made by Eskyozar(Yohib Hussain)",30,90,12) print("Original game made by Atari",40,100,12) if (btnp(5))then game_state = "changelog" end if (btnp(4)) then game_state = play end end if (game_state == "changelog")then cls() print("Version 0.1.0",0,0,12) print("Game was made",40,10,12) print("Basic pong was made",40,20,12) print("") print("Version 0.5.0",0,30,12) print("Added score system",40,40,12) print("Added Main menu",40,50,12) print("Press z to start",80,100,12) print("Version 0.8.0",0,60,12) print("Shorten the size of paddles",40,70,12) print("Added new ball behaviour",40,80,12) if (btnp(4))then game_state = play end end if (game_state == "over")then cls() print("Game over",85,30,12) print("Press z to start again",50,40,12) if (btnp(4))then game_state = play score2 = 0 end end if (game_state == "win")then cls() print("You win",50,30,12) print("You are the best pong player ever!",30,50,12) print("Press z to start again",35,70,12) if (btnp(4))then game_state = play score1 = 0 end end if (game_state == play)then cls() movepad1() movepad2() moveball() print(score1,40,0,12) print(score2,220,0,12) checkhit() checkhit2() checklose() checkwin() drawpad1() drawpad2() drawball() end end function drawpad1() spr(pad1.spritenum,pad1.position.x,pad1.position.y) end function drawpad2() spr(pad2.spritenum,pad2.position.x,pad2.position.y) end function drawball() spr(ball.spritenum,ball.position.x,ball.position.y) end function movepad1() if (btn(1)) then pad1.position.y = pad1.position.y + pad1.speed end if (btn(0))then pad1.position.y = pad1.position.y - pad1.speed end if (pad1.position.y < 0)then pad1.position.y = 0 end if (pad1.position.y > 120)then pad1.position.y = 120 end end function moveball() ball.position.x = ball.position.x - ball.xspeed ball.position.y = ball.position.y - ball.yspeed if (ball.position.y < 0)then ball.position.y = 0 ball.yspeed = -ball.yspeed end if (ball.position.y > 120)then ball.position.y = 120 ball.yspeed = -ball.yspeed end if (ball.position.x < 0)then ball.position.x = 112 ball.position.y = 50 score2 = score2 + 1 ball.yspeed = 1 ball.xspeed = 1 end if (ball.position.x > 232)then ball.position.x = 112 ball.position.y = 50 score1 = score1 + 1 ball.yspeed = 1 ball.xspeed = 1 end end function checkhit() if (ball.position.x < 11)then if (ball.position.y == pad1.position.y + 1)then ball.xspeed = 1.5 randomball = math.random(-1,1) radomdirection = math.random(1,2) if (randomball == -1)then ball.yspeed = 1 ball.yspeed = -ball.yspeed ball.xspeed = -ball.xspeed end if (randomball == 0)then ball.yspeed = 0.5 ball.xspeed = -ball.xspeed if (randomdirection == 1)then ball.yspeed = -ball.yspeed end if (randomdirection == 2)then ball.yspeed = ball.yspeed end end if (randomball == 1)then ball.yspeed = 0 ball.xspeed = -ball.xspeed if (randomdirection == 1)then ball.yspeed = -ball.yspeed end if (randomdirection == 2)then ball.yspeed = ball.yspeed end end end end end function checkhit2() if (ball.position.x > 220)then if (ball.position.y == pad2.position.y)then randomball = math.random(-1,1) radomdirection = math.random(1,2) if (randomball == -1)then ball.yspeed = -ball.yspeed ball.xspeed = -ball.xspeed end if (randomball == 0)then ball.yspeed = 0.5 ball.xspeed = -ball.xspeed if (randomdirection == 1)then ball.yspeed = -ball.yspeed end if (randomdirection == 2)then ball.yspeed = 0.5 ball.yspeed = ball.yspeed end end if (randomball == 1)then ball.yspeed = 0 ball.xspeed = -ball.xspeed if (randomdirection == 1)then ball.yspeed = -ball.yspeed end if (randomdirection == 2)then ball.yspeed = 0 ball.yspeed = ball.yspeed end end end end end function movepad2() if (ball.position.y > pad2.position.y)then pad2.position.y = pad2.position.y + pad2.speed elseif (ball.position.y < pad2.position.y)then pad2.position.y = pad2.position.y - pad2.speed else ball.position.y = pad2.position.y end end function checklose() if (score2 == 10)then game_state = "over" end end function checkwin() if (score1 == 10)then game_state = "win" end end