3D Snake - The Lord Of The Ring
DBPro P4 only.
Set Display Mode 1024, 768, 32 : Autocam Off : Hide Mouse : Randomize Timer() : Set Text Font "Comic Sans MS" :
Set Text Size 30 : Set Text To Bold : Ink RGB(0, 255, 0), Make Vector3(1) : Color Backdrop 0 : Dim Prop(3000, 4) :
Position Camera 0.0, 300.0, -250.0 : Size=90 : For I=1 To 1440 : Make Object Box I, 10.0, 2.0, 10.0 : Make Object Box 10000+I, 10.0, 10.0, 10.0 :
Color Object I, RGB(6,118,121) : Ghost Object On I : Color Object 10000+I, RGB(0,0,255) : PlaceCube(I, I-(((I-1)/Size)*Size), (I-1)/Size, 4.0, 200.0) : Next I :
Sync Rate 30 : Sync On : Do : If Not NewGame : Gosub NewGame : NewGame=1 : EndIf :
If LeftKey() And Move <> 1 : Move=-1 : EndIf : If RightKey() And Move <> -1 : Move=1 : EndIf :
If DownKey() And Move <> Size : Move=-1*Size : EndIf : If UpKey() And Move <> -1*Size : Move=Size : EndIf :
If (Timer()-OldTimer) > 50 : If ((Move=-1*Size And Prop(1, 1) > Size) Or (Move=Size And Prop(1, 1) <= 1350) Or Move=1 Or Move=-1) : Prop(1, 2)=Prop(1, 1) : If (Move=-1 And (Prop(1, 1)-(((Prop(1, 1)-1)/Size)*Size))=1) Or (Move=1 And (Prop(1, 1)-(((Prop(1, 1)-1)/Size)*Size))=Size) : Prop(1, 1)=Prop(1, 1)-(Size-1)*Move : Else :
Prop(1, 1)=Prop(1, 1)+Move : EndIf : If Prop(1, 1)=Target : Inc Length, 4 : Gosub NewTarget : EndIf : If Prop(Prop(1, 1), 3)=1 : Gosub NewGame :
EndIf : For I=1 To 4+Length : Prop(Prop(I+1, 1), 3)=0 : Prop(Prop(I, 1), 3)=1 : Prop(I+1, 2)=Prop(I+1, 1) : Prop(I+1, 1)=Prop(I, 2) : Show Object 10000+I :
PlaceCube(10000+I, Prop(I, 1)-(((Prop(I, 1)-1)/Size)*Size), (Prop(I, 1)-1)/Size, 4.0, 207.0+((I-1)/(I-1))*(2.0+Cos(Offset#+I*50.0)*2)) : Next I : OldTimer=Timer() : Set Camera To Follow Object Position X(10001), Object Position Y(10001), Object Position Z(10001), 0.0, 90.0, 300.0, 15.0, 0 : Else : Dec Length :
If Length=0 : NewGame=0 : EndIf : For I=1 To 1440 : If I > 4+Length : Hide Object 10000+I : Prop(Prop(I, 1), 3)=0 : Else : PlaceCube(10000+I, Prop(I, 1)-(((Prop(I, 1)-1)/Size)*Size), (Prop(I, 1)-1)/Size, 4.0, 207.0+((I-1)/(I-1))*(2.0+Cos(Offset#+I*50.0)*2)) : EndIf : Next I : EndIf : Offset#=WrapValue(Offset#+50.0) :
EndIf : Point Camera Object Position X(10001), Object Position Y(10001), Object Position Z(10001) : Position Light 0, Camera Position X(), Camera Position Y(), Camera Position Z() : Point Light 0, Object Position X(10001), Object Position Y(10001), Object Position Z(10001) : Text 10, 10, "3D Snake - The Lord Of The Ring by DMiTR0S: FPS = "+Str$(Screen Fps())+Chr$(10)+"Score: "+Str$(Length) : Sync : Loop : UnDim Prop() :
NewGame:
For I=2 To 1441 : Hide Object I+9999 : Prop(I-1, 1)=720 : Prop(I-1, 2)=0 : Prop(I-1, 3)=0 : Next I : Show Object 10001 : Move=1 : PlaceCube(10001, Prop(1, 1)-(((Prop(1, 1)-1)/Size)*Size), (Prop(1, 1)-1)/Size, 4.0, 209.0) : Gosub NewTarget : Repeat : Center Text Screen Width()/2, Screen Height()/2, "Score: "+Str$(Length)+": Press Any Key To Play." : Set Camera To Follow Object Position X(10001), Object Position Y(10001), Object Position Z(10001), 0.0, 90.0, 300.0, 15.0, 0 : Point Camera Object Position X(10001), Object Position Y(10001), Object Position Z(10001) : Sync : Until ScanCode() <> 0 : Length=4 : Return :
NewTarget:
If Not Object Exist(20000) : Make Object Box 20000, 10.0, 10.0, 10.0 : Color Object 20000, RGB(255,0,0) : EndIf : Target=90+RND(1260) : PlaceCube(20000, Target-(((Target-1)/Size)*Size), (Target-1)/Size, 4.0, 209.0) : Return
Function PlaceCube(ObjN, X, Z, An#, Dist#) :
Set Vector3 1, NewZValue(0.0, -110.0+X*An#, Dist#), NewYValue(0.0, -110.0+X*An#, Dist#), NewZValue(0.0, -122.0+Z*An#, Dist#) : Position Object ObjN, (X Vector3(1)/Length Vector3(1))*Dist#,( Y Vector3(1)/Length Vector3(1))*Dist#, (Z Vector3(1)/Length Vector3(1))*Dist# : XRotate Object ObjN, Atanfull(Z Vector3(1), Dist#) : ZRotate Object ObjN, -1.0*Atanfull(X Vector3(1), Y Vector3(1)) :
EndFunction