delay problem

Blitz3D Forums/Blitz3D Programming/delay problem

OK it is probably something stupid... but I am having a problem with the delay. I think that I am not seeing what I want because of the update rates on the video card.

I am making a swapping game. Probably more posts later...

You pick the first ball and it moves UP

You pick the second ball and it is supposed to drop DOWN (at least for a 1/2 a second) then the balls switch places.

Right now I don't have the checklegalmove() added and the checkforthree() is there but not actived...

But can someone hepl me see what I want???

; ############################# 
; INsanity 1.A
;
; Rook Zimbabwe aka SSG R. W. Dunn TXSG
; 9 MARCH 2005
; ############################# 
Graphics3D 800,600,32,1
SetBuffer BackBuffer()

SeedRnd MilliSecs()

camera=CreateCamera()
PositionEntity camera,0,0,-85
lights=CreateLight()
PositionEntity lights,0,90,0
;AmbientLight 200,200,200

Dim boardarea(11)
Dim topline(11)
Dim bottomline(11)
Dim boardx(11)
Dim boardy(11)
Dim turnpiecex(11)


Global square
Global xx
Global yy
Global what
Global firstpick
Global secondpick
Global slipper
Global pcolor$
Global colr
Global where
Global picker
Global entity
; ################################### MAKE INITIAL COLOR ARRAY FOR BOARD
For fillx = 0 To 11
	;For filly = 0 To 9
		colr=0
			boardarea(fillx)=colr
				topline(fillx)=colr
			bottomline(fillx)=colr
	;Next
Next

boardx(0)=-55
boardx(1)=-45
boardx(2)=-35
boardx(3)=-25
boardx(4)=-15
boardx(5)=-5
boardx(6)=5
boardx(7)=15
boardx(8)=25
boardx(9)=35
boardx(10)=45
boardx(11)=55


red=CreateBrush(255,0,0)
blue=CreateBrush(0,0,255)
yellow=CreateBrush(255,255,0)
green=CreateBrush(0,255,0)
orange=CreateBrush(255,80,0)
violet=CreateBrush(122,23,255) 

Global point=LoadImage("pointer4.png") ; ############  Load a pointer pic

Global gamePivot = CreatePivot() 

;chain=LoadMesh("chain1.b3d")
;ScaleEntity chain,4,1,1

;Global mesh=CreateCube()
Global mesh = CreateSphere(16)
EntityPickMode mesh,2
NameEntity mesh,"RED"
ScaleEntity mesh,4,4,4  ; was 5,5,5 for sphere
PaintEntity mesh,red
HideEntity mesh
Global mesh2=CopyEntity(mesh)
NameEntity mesh2,"BLUE"
PaintEntity mesh2,blue
HideEntity mesh2

Global mesh3=CopyEntity(mesh)
NameEntity  mesh3,"YELLOW"
PaintEntity mesh3,yellow
HideEntity mesh3

Global mesh4=CopyEntity(mesh)
NameEntity mesh4,"GREEN"
PaintEntity mesh4,green
HideEntity mesh4

Global mesh5=CopyEntity(mesh)
NameEntity mesh5,"ORANGE"
PaintEntity mesh5,orange
HideEntity mesh5

Global mesh6=CopyEntity(mesh)
NameEntity mesh6,"VIOLET"
PaintEntity mesh6,violet
HideEntity mesh6

PointEntity lights,mesh



makecolor()

setupboard()

picker = 1

; ############################# START OF PROGRAM LOOP
While Not KeyHit(1)

mx=MouseX()
my=MouseY()

e=CameraPick(camera,mx,my)
	If e<>entity
		If entity Then EntityAlpha entity,1
		entity=e
	EndIf
	
If entity Then   ; was entity
	EntityAlpha entity,.55
EndIf

	
If MouseHit(1) = True Then 
that=CameraPick(camera,mx,my)
	If that=0 Then Goto outme

		Select mesh ; was mesh 
			Case mesh
			xx=EntityX(entity,True)
			where=(xx + 55)/10 ; math on xx to devolve array place (ain't fancy but it works)
			pickpiece$=EntityName$(entity)
			Default 
			pp=0			
		End Select
If picker=1 Then
			topline(where)=boardarea(where) ; assign value from middle row to top
			firstpick = where ; assign same value to holder for use later
				boardarea(where)=0 ; plunk a 0 (NO COLOR) in middle row
				setupboard() ; reposition the board
			picker = 2 ; set picker to 2 for second pick
ElseIf picker=2 Then
			bottomline(where)=boardarea(where) ; get the idea from picker=1
				boardarea(where)=0
				secondpick = where
				setupboard()
				
; #-#-#-#-#-#-#-#-#-#-#-#-#-#-#
;	THIS is where I see a problem... If you REM out the switcheroo() command below
;	THEN you will see the ball drop down... If you DON'T rem it out you never
; 	see the ball drop... machine just waits and then plops the new ball in place.
; 
;	I have tried putting delay in the FRONT of the switcheroo() function.
;	I have tried putting delay just INSIDE the switcheroo...
;	Try it as it sits... then REM out switcheroo() and at least see what I want
; 	to see on the screen for 1/2 a second before it makes the switch.
;	HOW can I see this???
; #-#-#-#-#-#-#-#-#-#-#-#-$-$-$				
								
				Delay 650
				switcheroo() ; this is what I call to switch the values from what has been selected.
			picker = 1
EndIf

.outme


; ########## END this whole proposition
EndIf
; ################################### USELESS BUT ADDED FOR FUN for now!
If KeyDown(57) Then 
	FreeEntity gamePivot		
    	gamePivot = CreatePivot()	
			Cls
newcolor()
setupboard()
EndIf
; ################################### end of useless?

  UpdateWorld()
  RenderWorld()

; ############################# PRINT the array so I can check it... 
Text 0,100,"ROW 10: "+boardarea(0)+boardarea(1)+boardarea(2)+boardarea(3)+boardarea(4)+boardarea(5)+boardarea(6)+boardarea(7)+boardarea(8)+boardarea(9)+boardarea(10)

Text 0,160,"MOUSE: "+mx+" , "+my

Text 0,85,"PIECE: "+pickpiece$
Text 0,65,"Plocation: "+xx
Text 0,30,"ARRAYplace: "+where
Text 0,180,"TRIS: "+TrisRendered()
Text 0,10,"Picker: "+picker

DrawImage point,MouseX(),MouseY()

Flip

Wend

End
; ################################# FUNCTIONS
Function setupboard()
			FreeEntity gamePivot		
    		gamePivot = CreatePivot()	
			Cls
; BOTTOM LINE
col=-10
For row=0 To 11
	;For col=0 To 9
		what=bottomline(row)
		Select what
			Case 1 
			 red=CopyEntity (mesh,gamePivot)
			pcolor$="RED"	
			NameEntity mesh,pcolor$				
				PositionEntity red,boardx(row),col,0
			
			Case 2 
			 blue=CopyEntity (mesh2,gamePivot)	
			pcolor$="BLUE"	
			NameEntity mesh2,pcolor$		
				PositionEntity blue,boardx(row),col,0
			
			Case 3
			 grey=CopyEntity (mesh3,gamePivot)		
			pcolor$="YELLOW"	
			NameEntity mesh3,pcolor$	
				PositionEntity grey,boardx(row),col,0
			
			Case 4 
			 purp=CopyEntity (mesh4,gamePivot)
			pcolor$="GREEN"
			NameEntity mesh4,pcolor$					
				PositionEntity purp,boardx(row),col,0
			
			Case 5 
			 orng=CopyEntity (mesh5,gamePivot)	
			pcolor$="ORANGE"
			NameEntity mesh5,pcolor$				
				PositionEntity orng,boardx(row),col,0
			
			Case 6
			 yell=CopyEntity (mesh6,gamePivot)
			pcolor$="VIOLET"	
			NameEntity mesh6,pcolor$
			PositionEntity yell,boardx(row),col,0
			End Select
	;Next
Next

; ###########  topline
col=10
For row=0 To 11
	;For col=0 To 9
		what=topline(row)
		Select what
			Case 1 
			 red=CopyEntity (mesh,gamePivot)
			pcolor$="RED"	
			NameEntity mesh,pcolor$				
				PositionEntity red,boardx(row),col,0
			
			Case 2 
			 blue=CopyEntity (mesh2,gamePivot)	
			pcolor$="BLUE"	
			NameEntity mesh2,pcolor$		
				PositionEntity blue,boardx(row),col,0
			
			Case 3
			 grey=CopyEntity (mesh3,gamePivot)		
			pcolor$="YELLOW"	
			NameEntity mesh3,pcolor$	
				PositionEntity grey,boardx(row),col,0
			
			Case 4 
			 purp=CopyEntity (mesh4,gamePivot)
			pcolor$="GREEN"
			NameEntity mesh4,pcolor$					
				PositionEntity purp,boardx(row),col,0
			
			Case 5 
			 orng=CopyEntity (mesh5,gamePivot)	
			pcolor$="ORANGE"
			NameEntity mesh5,pcolor$				
				PositionEntity orng,boardx(row),col,0
			
			Case 6
			 yell=CopyEntity (mesh6,gamePivot)
			pcolor$="VIOLET"	
			NameEntity mesh6,pcolor$
			PositionEntity yell,boardx(row),col,0
			End Select
	;Next
Next
; MAIN ROW
col=0
For row=0 To 11
	;For col=0 To 9
		what=boardarea(row)
		Select what
			Case 1 
			 red=CopyEntity (mesh,gamePivot)
			pcolor$="RED"	
			NameEntity mesh,pcolor$				
				PositionEntity red,boardx(row),col,0
			
			Case 2 
			 blue=CopyEntity (mesh2,gamePivot)	
			pcolor$="BLUE"	
			NameEntity mesh2,pcolor$		
				PositionEntity blue,boardx(row),col,0
			
			Case 3
			 grey=CopyEntity (mesh3,gamePivot)		
			pcolor$="YELLOW"	
			NameEntity mesh3,pcolor$	
				PositionEntity grey,boardx(row),col,0
			
			Case 4 
			 purp=CopyEntity (mesh4,gamePivot)
			pcolor$="GREEN"
			NameEntity mesh4,pcolor$					
				PositionEntity purp,boardx(row),col,0
			
			Case 5 
			 orng=CopyEntity (mesh5,gamePivot)	
			pcolor$="ORANGE"
			NameEntity mesh5,pcolor$				
				PositionEntity orng,boardx(row),col,0
			
			Case 6
			 yell=CopyEntity (mesh6,gamePivot)
			pcolor$="VIOLET"	
			NameEntity mesh6,pcolor$
			PositionEntity yell,boardx(row),col,0
			End Select
	;Next
Next

End Function
; #################################
Function checkforthree()
; LEFT and RIGHT
For row=0 To 9
		a=boardarea(row)
		b=boardarea(row+1)
		c=boardarea(row+2)
			If a = b Then
				If b = c Then
					boardarea(row)=0
					boardarea(row+1)=0
					boardarea(row+2)=0
					;score = score+(55*sval)
				EndIf	
			EndIf
Next

End Function
; #################################
Function makecolor()

For row = 0 To 11
		a=boardarea(row)
			If a = 0 Then
				colr=Rnd(1,6)
				boardarea(row)=colr
			EndIf
Next

End Function
; #################################
Function newcolor()

For row = 0 To 11
		a=boardarea(row)
				colr=Rnd(1,6)
				boardarea(row)=colr
Next

End Function
; #################################
Function switcheroo()
; boardarea(#),topline(#),bottomline(#)
; This function clears up the topline and bottomline and resets boardarea with the opposite values
boardarea(secondpick)=topline(firstpick)
topline(firstpick)=0
boardarea(firstpick)=bottomline(secondpick)
bottomline(secondpick)=0
setupboard()

End Function
; end of all things

If you use ANY of this code I expect a name in your game credits! : )
-RZ

Thanks for all your help. It should be noted that, for some reason, this code refuses topick an entity 10% of the time and refuses to recognize an entity 20% of the time... I just re reun it and it seems to work on the second try. I am probably passing entity too much.

It would help if your code didn't have to be debugged to get it working in the first place :)

>>> Global point=LoadImage("pointer4.png") <<< No-one will have access to the media

I looked briefly but I couldn't understand what you wanted from this...
You pick the second ball and it is supposed to drop DOWN (at least for a 1/2 a second) then the balls switch places.
...because that's what it appeared to be doing to me?

Did you mean you wanted the ball to take 1/2 a second to drop down, or pause for 1/2 a second then drop down?

drop down THEN pause for 1/2 a second. My machine the first pops up and then you click the second and it changes instantly... you don't see the drop down.

-RZ