TGC Codebase Backup



3D Pong Survival (20 Lines) by neilio

8th Feb 2005 8:04
Summary

Bat, ball, bouncing... simple



Description

My first actual 3D game, compacted for the 20 line challenge, move the bat with you're mouse, keep control of the ball as it speeds up. Also the camera tracks the bat. very basic, but just an afternoons work...



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    remstart
        #####################################################
        #                                                   #
        #  ##### #####     #####   #####   ###  ##  #####   #
        #     ## ##  ##    ##  ## ##   ##  #### ## ##   ##  #
        #   #### ##  ##    #####  ##   ##  ## #### ##       #
        #     ## ##  ##    ##     ##   ##  ##  ### ##  ###  #
        #  ##### #####     ##      #####   ##   ##  #### #  #
        #                                                   #
        #####################################################
        ### S------U-----R------V-----I-----V-----A-----L ###
        #####################################################
        #                                                   #
        #       By Neil Houlden      www.neilsdemo.tk       #
        #                                                   #
        #####################################################

remend



MAKE OBJECT BOX 2,5,50,5 : MAKE OBJECT BOX 3,5,50,5 : MAKE OBJECT BOX 

4,85,5,5 : MAKE OBJECT BOX 5,5,5,5 : MAKE OBJECT BOX 1,20,5,5
position object 1,0,-23,0 : position object 2,-40,0,0 : position object 

3,40,0,0 : position object 4,0,25,0 : position camera 0,50,-90 : 

balldir = 7 : highscore=0 : score=0 : ballspeed#=0.05
do : point camera object position x(1),0,0 : box 

0,0,640,20,rgb(0,0,100),rgb(0,0,255),rgb(0,0,100),rgb(0,0,255) : 

datext$="Score: "+str$(score) +"           HighScore: 

"+str$(highscore)+"              3D PONG SURVIVAL by Neil Houlden" : 

center text screen width()/2,2, datext$ : if score>highscore then 

highscore=score
   position object 1, mousex()/3-100,-23,0 : if mousex()<216 then 

position object 1,-30,-23,0
   if mousex()>385 then position object 1,30,-23,0
   if balldir=7
      move object left 5, ballspeed# : move object up 5, ballspeed# : 

if object position x(5)<-35 then balldir=9 else if object position 

y(5)>20  then balldir=1
   endif
   if balldir=9
      move object right 5, ballspeed# :move object up 5, ballspeed# : 

if object position y(5)>20 then balldir=3 else if object position 

x(5)>35 then balldir=7
   endif
   if balldir=3
      move object right 5, ballspeed# :move object down 5, ballspeed# : 

if object position x(5)>35 then balldir=1 else if object position 

y(5)<object position y(1)+5 and object position x(5)< object position 

x(1)+15 and object position x(5)> object position x(1)-15 then 

balldir=9 : score= score+1
   endif
   if balldir=1
      move object left 5, ballspeed# :move object down 5, ballspeed# : 

if object position x(5)<-35 then balldir=3 else if object position 

y(5)<object position y(1)+5 and object position x(5)< object position 

x(1)+15 and object position x(5)> object position x(1)-15 then 

balldir=7 : score= score+1
   endif
   if object position y(5)<object position y(1) then score=0 : position 

object 5,0,0,0 : balldir=7 : ballspeed#=0.05
   ballspeed#=ballspeed#*1.0001
loop