Help

Blitz3D Forums/Blitz3D Beginners Area/Help

Hmmmm, how about:

;==========================Var Setup
Type Rock
	Field X,Y,Z, RockType, Name$
	Field Model, ModelTex,State,Maxhits
	Field Currenthits
	Field ToolTip
	Field RequiredLevel
	Field Regen
End Type

Global AppVersion#		=.5
Global Copper			=1
Global Tin				=2
Global Iron				=3


;==========================Game Loop
	Graphics3D(800,600,0,2)
	AppTitle("ZScape Version "+AppVersion#)
	
		

	;Create Rock
	MyRock.rock = Rock_Create()
	Rock_SetType(MyRock, Copper)
	MyRock\Currenthits = 5
	
	Print "Rock Created with "+MyRock\Currenthits+" Current Hits.  Press any key!"
	WaitKey()
	
	
	While Not KeyDown(1)
		
		MineRock = True
		If MineRock Then
			Rock_MineRock(MyRock)
			MineRock = False
		EndIf
		
		Print "Rock Mined!  Current Hits:"+MyRock\Currenthits
		Print "Press any key to remine, esc to exit"
		WaitKey()
	Wend
	End



;==========================End Game Loop



;==========================Functions
Function Rock_Create.Rock()
	TempRock.Rock = New Rock
	Return TempRock
End Function

Function Rock_SetType(TempRock.Rock, RockType=0)
	TempRock\RockType = RockType
	Rock_UpdateRock(TempRock)
End Function

Function Rock_UpdateRock(TempRock.Rock)
	If TempRock <> Null Then
		Select TempRock\RockType
			Case 1
				TempRock\Name$ = "Copper"
				TempRock\ToolTip$ = "This is a minable rock"
				TempRock\Maxhits = 5
				TempRock\Regen=7
			Case 2
				TempRock\Name$ = "Tin"
				TempRock\ToolTip$ = "This is a minable rock"
				TempRock\Maxhits = 5
				TempRock\Regen=7			
			Case 3
				TempRock\Name$ = "Iron"
				TempRock\ToolTip$ = "This is a minable rock"
				TempRock\Maxhits = 4
				TempRock\Regen=10
		End Select
		If TempRock\Currenthits	>= TempRock\Maxhits Then TempRock\State=1
		If (TempRock\Currenthits/2)	= TempRock\Maxhits Then TempRock\State=2
		If TempRock\Currenthits	=0 Then TempRock\State=3
	EndIf
End Function

Function Rock_MineRock(TempRock.Rock)
	Repeat
		TempRock\CurrentHits = TempRock\CurrentHits - 1
	Until TempRock\CurrentHits <= 0
	Delay(TempRock\Regen*1000)
	TempRock\CurrentHits=TempRock\MaxHits
End Function


Not exactly sure what it is supposed to do, but guessing..... Word of advice Zach, writing cleaner code makes it easier for others to understand and help :-)