Challenge:
Winner?:
No
Code Snippet:
`[An Official Pong Ripoff] `[By: Foe7 {FoeVII}] autocam off : hide mouse `basic setup sync on : sync rate 60 type paddle obj as integer x as float y as float z as float speed as float score as integer endtype type ball obj as integer speed as float x as float z as float yang as float collision as boolean lastHit transition as integer endtype type powerup obj as integer current as integer appear as integer dissappear as integer isthere as integer x as float y as float z as float endtype dim paddle(1) as paddle dim ball(0) as ball dim powerup(0) as powerup global currVersion as integer `the current kind of pong being played currVersion = 1 `basic pong (2)=brick,(3)=wheel setup(1) do manageUser() manageComp() managePowerUps() manageBall() manageDisplay() if currVersion = 2 then manageBricks() if currVersion = 3 then manageWheels() if ball(0).transition > 0 transition(ball(0).transition) endif sync : loop function clamp(a#,b#,c#) if c# < a# then c# = a# if c# > b# then c# = b# endfunction c# function transition(t) v = currVersion true as boolean true = 0 sx = screen width()/2 sy = screen height()/2 box sx-100,sy-50,sx+100,sy+50,0,0,0,0 center text sx,sy,"TRANSITION!!!" if v = 1 `if t = 2 delete object 2 delete object 3 delete object 4 sync wait 500 repeat xa = object angle x(1) ya = object angle y(1) za = object angle z(1) rotate object 1,xa+1,ya+1,za+1 sync if object angle x(1) = 360 and object angle y(1) = 360 and object angle z(1) = 360 then true = 1 until true dumpObjects() setup(t) delayBall(750) currVersion = t exitfunction `endif endif if v = 2 `if t = 1 delete object 2 delete object 3 delete object 4 for b = 200 to 219 if object exist (b) then delete object b next b sync wait 500 repeat xa = object angle x(1) ya = object angle y(1) za = object angle z(1) rotate object 1,xa+1,ya+1,za+1 sync if object angle x(1) = 360 and object angle y(1) = 360 and object angle z(1) = 360 then true = 1 until true dumpObjects() setup(t) delayBall(750) currVersion = t exitfunction `endif endif if v = 3 `if t = 1 delete object 2 delete object 3 delete object 4 for b = 300 to 310 if object exist (b) then delete object b next b sync wait 500 repeat xa = object angle x(1) ya = object angle y(1) za = object angle z(1) rotate object 1,xa+1,ya+1,za+1 sync if object angle x(1) = 360 and object angle y(1) = 360 and object angle z(1) = 360 then true = 1 until true dumpObjects() setup(t) delayBall(750) currVersion = t exitfunction `endif endif endfunction function createBoard() `makes the playing board make object box 1,50,0.5,100 `board position object 1,0,0-object size y(1)/2,0 `place it so the top is at y-coordinate 0 make object box 10,4,10,100 make mesh from object 1,10 `so we can turn it into a limb add limb 1,1,1 offset limb 1,1,27,0,0 add limb 1,2,1 offset limb 1,2,-27,0,0 delete object 10 delete mesh 1 color object 1,0 color limb 1,1,rgb(155,155,55) color limb 1,2,rgb(155,155,55) make object sphere 15,-5000 endfunction function setupCamera() position camera 0,100,-100 point camera 0,0,0 position mouse screen width()/2,screen height()/2 `for convience, set it at middle of screen endfunction function createUser() `make the user paddle and such make object box 2,10,4,2 `player paddle color object 2,rgb(255,55,55) paddle(0).obj = 2 endfunction function createComp() clone object 3,2 `computer paddle color object 3,rgb(55,255,55) paddle(1).obj = 3 endfunction function createBall() `creates the ball to be hit make object sphere 4,5.5 color object 4,rgb(55,55,255) ball(0).obj = 4 ball(0).transition = 0 resetBall() endfunction function createSpecials() make object cube 100,5 `this will be the collision-object color object 100,rgb(155,155,155) ghost object on 100 hide object 100 powerup(0).obj = 100 powerup(0).current = 0 powerup(0).appear = timer() + 20000 powerup(0).dissappear = timer() + 25000 powerup(0).isthere = 0 powerup(0).y = 2.5 make object box 101,3.5,3.5,1 `this is to go to curveball `texture it color object 101,rgb(55,155,55) hide object 101 make object box 102,3.5,3.5,1 `this will be the powerup to go to brick-ball (lol) `texture it color object 102,rgb(155,55,55) hide object 102 make object box 103,3.5,3.5,1 `this will be the powerup to go to brick-ball (lol) `texture it color object 103,rgb(55,55,155) hide object 103 endfunction function createBricks() for b = 200 to 219 make object box b,5,2,2 placeBrick(b) next b endfunction function createWheels(n) make object box 300,2,5,2 make object box 301,4,2,2 make mesh from object 1,301 delete object 301 add limb 300,1,1 : offset limb 300,1,2,-1.5,0 add limb 300,2,1 : offset limb 300,2,-2,-1.5,0 delete mesh 1 make object box 301,2,2,4 make mesh from object 1,301 delete object 301 add limb 300,3,1 : offset limb 300,3,0,-1.5,2 add limb 300,4,1 : offset limb 300,4,0,-1.5,-2 delete mesh 1 placeWheel(300) for w = 1 to n clone object 300+w,300 s# = (rnd(500)/5)+40 s# = clamp(60,135,s#) scale object 300+w,s#,s#,s# placeWheel(300+w) next w endfunction function manageUser() `take care of user input and actions o = paddle(0).obj x# = object position x(2) y# = object position y(2) z# = object position z(2) ox# = x# inc x#,mousemovex()/2 `mouse sensitivity x# = clamp(-20,20,x#) `clamp the value between -20 and 20 paddle(0).speed = x#-ox# `set it's speed/direction for future reference position object o,x#,y#,z# paddle(0).x = x# endfunction function manageComp() `HORRIBLE AI CODE...needs serious help o = paddle(1).obj m# = abs(paddle(0).speed) `this is just so there is some relation between the speed of the player and that of the computer if m# = 0 then m# = 1 `if the player doesn't move, then i'll let the computer move 1 m# = m#/2`Computer Difficulty (m#/1 = definite loss) x# = object position x(o) y# = object position y(o) z# = object position z(o) ox# = x# if ball(0).x > ox# x# = ox# + m# else if ball(0).x < ox# x# = ox# - m# endif endif x# = clamp(-20,20,x#) position object o,x#,y#,z# paddle(1).x = x# paddle(1).speed = x#-ox# endfunction function manageBall() o = ball(0).obj `just a reference to the object number m# = ball(0).speed ox# = object position x(o) `the previous x oz# = object position z(o) `the previous z y# = object position y(o) `just a reference to the y position yan# = ball(0).yang `the object angle nx# = ox#+(m#*cos(yan#)) `uses trig to find new position nz# = oz#+(m#*sin(yan#)) nnx# = clamp(-23.5,23.5,nx#) `this is to check for collision with walls if nnx# <> nx# `collision occured (needed to clamp) yan# = 180-yan#`yan# - 180 inc m#,0.1 nx# = nnx# endif position object o,nx#,y#,nz# ball(0).x = nx# ball(0).z = nz# nnz# = clamp(-48.5,48.5,nz#) `this is to check if a score if nnz# <> nz# `a score if nz# < 0 `computer scored inc paddle(1).score else inc paddle(0).score endif resetBall() delayBall(500) exitfunction else `this checks for collision between ball and paddle if nz# < 0 `this will set the obejct to check collision with col = 0 else col = 1 endif if object collision (o,paddle(col).obj) = 1 and ball(0).collision = 0 ball(0).collision = 1 yan# = yan# - 180 inc m#,0.2 ball(0).lastHit = col `0 = player, 1 = computer if nx# < object position x(paddle(col).obj) `this is to give it an extra bounce yan# = yan#-10 else if nx# > object position x(paddle(col).obj) yan# = yan#+10 endif endif if paddle(col).speed > 0 inc yan#,4 else if paddle(col).speed < 0 inc yan#,-4 endif endif else if object collision (o,paddle(col).obj) = 0 then ball(0).collision = 0 endif endif ball(0).yang = wrapvalue(yan#) m# = clamp(0.9,2.5,m#) ball(0).speed = m# endfunction function manageBricks() for b = 200 to 219 if object collision (ball(0).obj,b) = 1 sx = object screen x(b) sy = object screen y(b) red = rgbr(point(sx,sy)) green = rgbg(point(sx,sy)) blue = rgbb(point(sx,sy)) s = red+green+blue s = s/150 if s = 0 then s = 1 `inc paddle(ball(0).lastHit).score,s placeBrick(b) `ball(0).yang = 180-ball(0).yang ball(0).yang = ball(0).yang-180-(rnd(2)-1) ball(0).speed = ball(0).speed + 0.1 exitfunction endif next b endfunction function manageWheels() for w = 300 to 310 if object exist(w) if object collision (ball(0).obj,w) = 1 ball(0).yang = ball(0).yang-180-(rnd(2)-1) ball(0).speed = ball(0).speed + 0.4 endif yrotate object w,object angle y(w)+1 endif next w endfunction function manageDisplay() text 80,100,str$(paddle(1).score) text 80,140,str$(paddle(0).score) if len(str$(paddle(0).score)) > len(str$(paddle(1).score)) temp$ = str$(paddle(0).score) else temp$ = str$(paddle(1).score) endif s$ = "" for i = 1 to len(temp$) s$ = s$ + "-" next i text 80,120,s$ endfunction function managePowerUps() if powerup(0).current = -1 a = rnd(25) + 15 d = a + rnd(20) + 10 d = d * 1000 a = a * 1000 powerup(0).current = 0 powerup(0).appear = a+timer() powerup(0).dissappear = d + timer() exitfunction endif if powerup(0).current = 0 `print "waiting..." if timer() >= powerup(0).appear repeat c = rnd(2)+1 until c <> currVersion powerup(0).current = c powerup(0).isthere = 1 `repeat x = rnd(40)-20 z = rnd(80)-40 powerup(0).x = x powerup(0).z = z o = powerup(0).obj position object o,x,powerup(0).y+0.1,z show object o `until object collision(o,0) = 0 position object 100+c,x,powerup(0).y+0.1,z show object 100+c endif exitfunction endif if powerup(0).isthere = 1 ` print "it's there" c = powerup(0).current + 100 xa# = object angle x(c) ya# = object angle y(c) za# = object angle z(c) rotate object c,xa#+1,ya#-1,za#+1 if timer() >= powerup(0).dissappear powerup(0).current = -1 powerup(0).isthere = 0 hide object powerup(0).obj hide object c exitfunction endif if object collision (powerup(0).obj,ball(0).obj) = 1 powerup(0).current = -1 powerup(0).isthere = 0 hide object powerup(0).obj hide object c ball(0).transition = c-100 exitfunction endif endif endfunction function placeBrick(o) x = rnd(10)+10 x = x * ((rnd(1)*2)-1) position object o,x,1,rnd(60)-30 for b = 200 to 219 if b <> o if object exist(b) if object collision(o,b) placeBrick(o) endif endif endif next b color object o,rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1) endfunction function placeWheel(o) x = rnd(10)+10 x = x * ((rnd(1)*2)-1) z = rnd(20)+10 z = z * ((rnd(1)*2)-1) position object o,x,object size y(o)/2+0.5,rnd(60)-30 `for b = 300 to 310 `if b <> o `if object exist(o) if object collision(o,0) > 0 placeBrick(o) endif `endif `endif `next b color object o,rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1) endfunction function resetBall() `positions ball position object ball(0).obj,0,object size y(4)/2,0 `puts it at ground level ball(0).speed = 1 ball(0).x = 0 ball(0).z = 0 ball(0).yang = -90 endfunction function delayBall(t) t = timer() + t repeat manageUser() manageComp() sync until timer() > t sync endfunction function resetPaddles() position object 2,0,object size y(2)/2,-49 paddle(0).x = 0 paddle(0).z = -49 paddle(0).y = object size y(2)/2 position object 3,object position x(2),object position y(2),object position z(2)*-1 `so you only need to change one set of values if you change size paddle(1).x = 0 paddle(1).z = 49 paddle(1).y = object size y(3)/2 endfunction function dumpObjects() `just to clean everything up if object exist(1) then delete object 1 if object exist(2) then delete object 2 if object exist(3) then delete object 3 if object exist(4) then delete object 4 `if object exist(10) then delete object 10 if object exist(15) then delete object 15 if object exist(100) then delete object 100 if object exist(101) then delete object 101 if object exist(102) then delete object 102 if object exist(103) then delete object 103 for b = 200 to 219 if object exist(b) then delete object b next b for b = 300 to 310 if object exist(b) then delete object b next b endfunction function resetGame() `as in, when you start over dumpObjects() setup(1) endfunction function setup(t) `the start createBoard() setupCamera() createUser() createComp() resetPaddles() createBall() createSpecials() if t = 2 then createBricks() if t = 3 then createWheels(rnd(9)) endfunction remstart List of Information: Object 1 - the board on bottom Object 2 - Player's paddle Object 3 - Computer's paddle Object 4 - The Ball *** Object 15 - Background *** Object 100 - Collision cube for powerups Object 101 - A powerup Object 102 - Another powerup Object 103 - Another one *** 200-219 - bricks remend