>°,ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜ ΐΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜ ΐΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜ ΐΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜ ΐΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜΜΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜΜΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜΜΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜ ΐΜΜΜΜΜΜΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜΜΜΜΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜ ΐΜΜΜ ΐΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜΜΜΜΜ ΐΜΜΜ ΐΜΜΜΜΜ 0000333330000300300333030ΐΐ ΜΜ ΐΜΐ ΐ Μ ΐ ΐΜ ΐ Μ Κ-- title: PONG using Lua -- author: Jose Elyabe (S_Undead) -- desc: A classic 70s game using Lua laguage. -- script: lua -- input:keyboard game={ width = 240, heigth = 136, l = 3, s = false, mt= false, } p1={ x = game.width/2-120, y = game.heigth/2-7, w = 5, h = 25, c = 12, v = 4, points = 10, } p2={ x = game.width/2+116, y = game.heigth/2-7, w = 5, h = 25, c = 12, v = 4, points = 10, } ball={ x = game.width/2, y = game.heigth/2, r = 3, c = 12, vx = 2, vy = 2, p_cl= false, } menu = { txt_1_c = 12, txt_2_c = 19, txt_3_c = 12, txt_4_c = 12, s = true, txt_4_t = "players 1", } --[[ thid function draws the munu on the screen and applies their functonalities--]] function menu_draw() if game.s == false and menu.s == true then print("pong",73,50,menu.txt_1_c,true,4,false); print("Start Game",74,80,menu.txt_2_c,false,1,true); print("Options",74,90,menu.txt_3_c,false,1,true); else if game.s == false and menu.s == false and menu.txt_3_c == 19 then print("pong",73,50,menu.txt_1_c,true,4,false); print (menu.txt_4_t,80,80,menu.txt_4_c,false,1,true); end end if btn(0) and game.s == false and menu.s == true and menu.txt_2_c == 12 or key (58) and game.s == false and menu.s == true and menu.txt_2_c == 12then menu.txt_2_c = 19 menu.txt_3_c = 12 end if btn (1) and game.s == false and menu.s == true and menu.txt_3_c == 12 or key (59) and game.s == false and menu.s == true and menu.txt_3_c == 12 then menu.txt_3_c = 19 menu.txt_2_c = 12 end if btn (4) and game.s == false and menu.s == true and menu.txt_3_c == 19 and menu.txt_2_c == 12 or key (50) and game.s == false and menu.s == true and menu.txt_3_c == 19 then menu.s = false menu.txt_4_c = 19 end if btn (5) and game.s == false and menu.s == false and menu.txt_4_c == 19 or key (51) and game.s == false and menu.s == false and menu.txt_4_c == 19 then menu.s = true end if btn (4) and game.s == false and menu.s == true and menu.txt_2_c == 19 or key (50) and game.s == false and menu.s == true and menu.txt_2_c == 19 then game.s = true p1.points = 0 p2.points = 0 p1.x = game.width/2-120 p1.y = game.heigth/2-7 p1.w = 5 p1.h = 25 p1.c = 12 p1.v = 4 p2.x = game.width/2+116 p2.y = game.heigth/2-7 p2.w = 5 p2.h = 25 p2.c = 12 p2.v = 4 ball.x = game.width/2 ball.y = game.heigth/2 ball.r = 3 ball.c = 12 ball.vx = 2 ball.vy = 2 end if btn (2) and game.s == false and menu.s == false or key (60) and game.s == false and menu.s == false then menu.txt_4_t = "players 2" game.mt = true else if btn (3) and game.s == false and menu.s == false or key (61) and game.s == false and menu.s == false then menu.txt_4_t = "players 1" game.mt = false end end -- end of the menu's function --[[ this function put on the screen all of the main objects of the game ]]-- end function draw() if game.s == true then rect(p1.x,p1.y,p1.w,p1.h,p1.c); -- player 1 rect(p2.x,p2.y,p2.w,p2.h,p2.c); -- player 2 circ(ball.x,ball.y,ball.r,ball.c); -- the ball print(p1.points,25,2,12,true,4,true); -- p1 poihts frame print(p2.points,210,2,12,true,4,true); -- p2 ponts frame for i = 1,game.heigth + 8, 5 do -- draws the line that splits thgtr screen in twice rect(game.width/2 - 1,i,2,2,12); end else circ(ball.x,ball.y,ball.r,ball.c) end end -- end of the draw function --[[ this function move's the players]]-- function p_move() if btn (0) and p1.y > 0 or key (58) and p1.y > 0 then -- p1 up move p1.y = p1.y - p1.v end if btn (1) and p1.y + p1.h <= game.heigth or key (59) and p1.y + p1.h <= game.heigth then -- p1 down move p1.y = p1.y + p1.v end if game.mt == false and p2.y > 0 then -- p2 "AI (artificial intelinge") up move p2.y = ball.y / 2 + 45 else if key (23) and game.mt == true and p2.y > 0 then -- p2 not AI up move p2.y = p2.y - p2.v end end if game.mt == false and p2.y + p1.h <= game.heigth then -- p2 AI down move p2.y = ball.y / 2 + 45 else if key (19) and game.mt == true and p2.y + p1.h <= game.heigth then -- p2 not AI move p2.y = p2.y + p2.v end end end --fim da funcao p_move --[[all the ball functions are declred here]]-- function ballset() -- ball movement ball.x = ball.x + ball.vx ball.y = ball.y + ball.vy -- x and y axes colision check -- here also checks the players colision with the ball if ball.y + ball.r > game.heigth then ball.vy = - ball.vy end if ball.x >= game.width and game.s == true then ball.x = game.width/2 ball.y = game.heigth/2 ball.r = 3 ball.c = 12 ball.vx = 2 ball.vy = 2 p1.points = p1.points + 1 else if ball.x >= game.width and game.s == false then ball.vx = -ball.vx end end if ball.y + ball.r < 0 then ball.vy = - ball.vy end if ball.x < 0 and game.s == true then ball.x = game.width/2 ball.y = game.heigth/2 ball.r = 3 ball.c = 12 ball.vx = 2 ball.vy = 2 p2.points = p2.points + 1 else if ball.x < 0 and game.s == false then ball.vx = -ball.vx end end if ball.x <= p1.x + p1.w and ball.y <= p1.y + p1.h and ball.y >= p1.y - ball.r then ball.vx = -ball.vx end if ball.x >= p2.x - p2.w and ball.y <= p2.y + p2.h and ball.y >= p2.y - ball.r then ball.vx = - ball.vx end end --[[ here, if the players points have a x value the the game resets ]]-- function game_over() if p1.points == 10 or p2. points == 10 then game.s = false game.mt = false menu.s = true p1.points = 0 p2.points = 0 end end function TIC() cls() draw() ballset() p_move() menu_draw() game_over() end