inflate and deflate sphere using TIMER

Blitz3D Forums/Blitz3D Tutorials/inflate and deflate sphere using TIMER

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I got tired of some of the silly questions that are asked about time and case... Combined BOTH into a simple tutorial that is fun to watch in WIREFRAME... Commented heavily...
;weird sphere code
;hit SPACEBAR To see WireFrame
;Rook Zimbabwe  
Graphics3D 800,600  ;							sets GRAPHICS 3D MODE

SetBuffer BackBuffer()

   
camera=CreateCamera()  
PositionEntity camera,0,0,-2 
  
light=CreateLight()  
RotateEntity light,80,0,0 

Global bop ;									BOP controls WHICH phase we are in set by function call
Global segments ;								variable to tell how many segments to make the SPHERE
Global oldtime = MilliSecs() ;					INITIAL timer amount to be used later to segments and suck
Global phase$ ;									A string that tells which phase we are in B / S

bop = 0 ;										sets INITIAL phase to segments
segments = 4 ;									sets INITIAL segments to 4

While Not KeyDown( 1 ) ; ESC

phase$ = " " ; clears previous phase$

sphere = CreateSphere(segments) ;					Create the sphere with the segments

xx=xx+1 ; rotation value in X
yy=yy+2 ; rotation value in Y
zz=zz+3 ; rotation value in Z

RotateEntity sphere,xx,yy,zz ; Make that sphere DANCE!!!

Select bop ;									CASE selector for BOP (we started with 0 so
	Case 1 ;									which function would we call?)
		segmentsdown()
	Case 0
		segmentsup()
End Select

If KeyHit( 57 )=True Then ; SPACEBAR enables wireframe
	enable=1-enable
EndIf

WireFrame enable ; allows WIREFRAME to be enabled

UpdateWorld  
RenderWorld 
    
Text 5,20,"Triangles Rendered: "+TrisRendered()
Text 5,40,"SEGMENTS: "+segments 
Text 5,60,"PHASE: "+phase$

Flip 

Cls

FreeEntity sphere ;							CLEAN UP THE LAST SPHERE!!!

Wend 
  
End	

Function segmentsup()

Color 255,12,12
phase$ = "INFLATE" ; remember this is a GLOBAL VARIABLE (has to be to be passed to a function)

If MilliSecs() > oldtime + 120 Then ; 	if it has been 1/4 second since the last time I made a variable with the timer...

segments = segments + 1 ;				then ADD 1 to the segments value
	If segments > 32 Then ;				If we have 32 segments...
		bop = 1 ;						Switch BOP to 1 (it will be picked up by main program loop)
	EndIf
	
oldtime = MilliSecs() ;					Get new OLDTIME value...

EndIf

End Function


Function segmentsdown()

Color 12,12,255
phase$ = "DEFLATE"

If MilliSecs() > oldtime + 120 Then
segments = segments - 1 ; 				SAME for this but in reverse!
	If segments < 4 Then
		bop = 0
	EndIf
 
oldtime = MilliSecs()

EndIf

End Function
I can't see any questions necessary after this but if you have I am on the board...

: )

RZ