TGC Codebase Backup



Cube vs. Sphere with some ambient lighting by Quincy person

7th Jul 2007 0:10
Summary

You're a cube and must run into the sphere to win all the while observing the nice ambient lighting.



Description

It makes a cube that runs around on a matrix. If you collide with the sphere you win. There is also some red ambient lighting to look at. Use the arrowkeys to move the cube around and the spacebar to jump (Hold the space bar to make the cube float). This is really my first program on my own featuring anything other than text. I hope nobody learns any bad habits from this. Enjoy!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `set some cool lighting
make light 1
show light 1
position light 1, 50, 0, 50
set ambient light 50
color ambient light rgb (200, 50, 50)

`create a box, sphere, and matrix
make object sphere 1, 5, 5, 5
position object 1, 50, 0, 50
make object box 2, 5, 5, 5
make matrix 1, 100, 100, 20, 20
ghost matrix on 1
ghost matrix on 1, 5
set object collision on 1
set object collision on 2


`main loop with movements
do
   print " press escapekey to exit"
   if upkey()=1
    move object 2, 1
   endif
   if downkey()=1
    move object 2, -1
   endif
   if rightkey()=1
    move object right 2, 1
   endif
   if leftkey()=1
    move object left 2, 1
   endif
   if spacekey()=1
    move object up 2, 5
    wait 5
    move object down 2, 5
   endif
   if object collision (1,2)=1
    position object 1, 100, 100, 100
    wait 1
    Victory(1, 50, "YOU WIN")
   endif
loop

function Victory(x, y, t$)
 do
   set cursor x, y
   print t$
 loop
endfunction