#$$$3333$$$43333PUUPeVUffUUffUPeVUUP >Òÿðÿÿðÿÿðÿðÿÿÿðÿÿÿðÿðÿÿÿðÿÿðÿðÿÿÿÿÿÿÿððÿðÿÿÿðÿÿððÿÿÿÿÿððÿðððÿÿÿÿðÿðÿðÿÿÿÿðÿÿÿÿðÿÿÿÿÿÿÿÿÿðÿðÿðÿÿððÿÿÿÿðÿÿððÿðÿððÿððÿÿðððÿÿÿðÿÿÿÿÿÿÿðÿÿððÿððÿÿÿÿðÿÿÿðÿÿÿÿÿÿÿÿðÿÿÿÿðÿÿÿÿÿðÿððÿðÿðÿ~ -- title: Wall Pong -- author: CocoPuff -- desc: a pong like game -- site: none -- license: MIT License -- version: 0.1 -- script: lua game_State_Init = 5 game_State_Start = 10 game_State_Play = 20 game_State_Dead = 30 game_State_End = 40 game_State = game_State_Start screen_Max_X = 232 screen_Max_Y = 127 ball = { x = 120, y = 0, x_Speed = 2, y_Speed = 1 } bat = { x = 114, y = 120, speed = 4 } score = 0 function TIC() if game_State == game_State_Start then start_Game() elseif game_State == game_State_Init then init_Game() elseif game_State == game_State_Play then play_Game() elseif game_State == game_State_End then end_Game() end -- if end -- TIC function start_Game() cls() print("Wall Pong",85,40,12) print("Made by CocoPuff",70,50,12) print("Press Z to Start the game",50,60,12) print("Use the arrow key to move",50,70,12) if btnp(4) then game_State = game_State_Init end end function init_Game() cls() ball = { x = 120, y = 0, x_Speed = 2, y_Speed = 1 } bat = { x = 114, y = 120, speed = 4 } score = 0 draw_Wall() draw_Bat() draw_Ball() score = 0 game_State = game_State_Play end function play_Game() cls() print("score = "..score,3,3) draw_Wall() draw_Bat() draw_Ball() move_Bat() move_Ball() check_Hit() end function end_Game() cls() print("GAME OVER",75,46,2) print("Your score is "..score,60,60,12) print("Press Z to quit the game",60,70,12) print("Press X to restart the game",60,80,12) if btnp(4) then exit() elseif btnp(5) then game_State = game_State_Start end end function move_Bat() if (btn(2)) then bat.x = bat.x - bat.speed end if (btn(3)) then bat.x = bat.x + bat.speed end if (bat.x > (screen_Max_X - 8)) then bat.x = screen_Max_X - 8 elseif (bat.x < 0) then bat.x = 0 end end function draw_Bat() spr(0, bat.x, bat.y, 0,1,0,0,2,1) end function draw_Wall() line(0,127,0,0,15) line(0,0,239,0,15) line(239,0,239,127,15) line(0,127,239,127,2) end --draw_wall function move_Ball() ball.x = ball.x + ball.x_Speed ball.y = ball.y + ball.y_Speed if (ball.x > screen_Max_X) then ball.x = screen_Max_X ball.x_Speed = -ball.x_Speed sfx(0,40,5) elseif (ball.x < 0) then ball.x = 0 ball.x_Speed = -ball.x_Speed sfx(0,40,5) end if (ball.y < 0) then ball.y = 0 ball.y_Speed = -ball.y_Speed sfx(0,50,5) elseif (ball.y >= screen_Max_Y) then sfx(0,20,5) game_State = game_State_End end end function draw_Ball() spr(16, ball.x, ball.y) end function check_Hit() if (ball.y_Speed > 0) then if (ball.y > (bat.y - 8)) and (ball.y < (bat.y)) then if (ball.x > (bat.x -6)) and (ball.x < (bat.x + 22)) then ball.y_Speed = -ball.y_Speed ball.x_Speed = ball.x_Speed + math.random(-1,1) score = score + 1 sfx(0,55,5) end end end end