TGC Codebase Backup



WaterSnake by neilio

10th Feb 2005 5:49
Summary

full 3D snake controll, make knots!



Description

If you ever played anaconda on timesplitters, and imagine full 3D control, that is what it is like... (without the cool music). There is now food to eat or anything, it's just fun to tie yourself up in knots.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` WaterSnake by Neil Houlden
` I haven't finished this yet, but take a look:

`Show the title screen:
center text screen width()/2,6, "                    __ ____ ___  __            "
center text screen width()/2,18, "==========   /   / /_/  /  /_   /_/  =========="
center text screen width()/2,30, "==========  /_/_/ / /  /  /__  / |   =========="
center text screen width()/2,40, "                                               "
center text screen width()/2,50, " ######   ##    ##     ###     ##   ##  #######"
center text screen width()/2,60, "##    ##  ###   ##    ## ##    ##  ##   ##     "
center text screen width()/2,70, "##        ####  ##   ##   ##   ## ##    ##     "
center text screen width()/2,80, " ######   ## ## ##   ##   ##   ####     #######"
center text screen width()/2,90, "      ##  ##  ####  #########  ## ##    ##     "
center text screen width()/2,100, "##    ##  ##   ###  ##     ##  ##  ##   ##     "
center text screen width()/2,110, " ######   ##    ##  ##     ##  ##   ##  #######"
center text screen width()/2,120, "                                               "
center text screen width()/2,130, " ============================================= "
center text screen width()/2,150, " By Neil Houlden        www.neilsdemo.tk "
center text screen width()/2,170, " ============================================= "
center text screen width()/2,280, "Use you're mouse to control the Water Snake."
center text screen width()/2,290, "Press any key to Continue"
center text screen width()/2,400, " - neilio_omnipotent@yahoo.co.uk -"
wait key
cls
input "enter the length of the snake (I usually use 300): " ,bodylength


`set Frame Rate
sync rate 20

`hide the mouse
hide mouse

`make ground (So I can see how fast I'm going)
make object plain 1,100,100
xrotate object 1,90
set object wireframe 1,1

`make the head
make object sphere 2,4
color object 2,rgb(0,255,50)

`Prepare to make body parts
t=3
partcolor=1

`The body part making loop
for t=3 to bodylength
   `Make a body part
   make object sphere t,3
   ` color it
   if partcolor=1
      partcolor=2
      color object t,rgb(0,100,0)
   else
      partcolor=1
      color object t,rgb(0,255,50)
   endif
next t


` game loop
do
   `Control the way the head faces by moving the mouse
   yrotate object 2,object angle y(2)+ (mousemovex()/2)
   xrotate object 2,object angle x(2)+ (mousemovey()/2)
   if object angle x(2)<-90
      xrotate object 2,object angle x(2)-object angle x(2)
      xrotate object 2,-90
   endif
   if object angle x(2)>90
      xrotate object 2,object angle x(2)-object angle x(2)
      xrotate object 2,90
   endif

   ` position the bits
   t=bodylength
   for a=4 to bodylength
      position object t,object position x(t-1),object position y(t-1),object position z(t-1)
      t=t-1
   next a


   `this want's to be outside the loop because the last body part has to be attatched to the head.
   position object 3, object position x(2),object position y(2),object position z(2)

   `move the head in the direction it's facing
   move object 2,1
   `put the camera in the right place.
   set camera to follow object position x(2),object position y(2),object position z(2),object angle y(2),50,object position y(2)+10,5,1
   point camera object position x(2),object position y(2),object position z(2)
loop