All pastes #608182 Raw Edit

Someone

public text v1 · immutable
·published 2007-07-08 03:21 UTC
rendered paste body
Graphics 640,480,0

Global blockfield:Int[12,8]
Global usedfield:Int[12,8]
ResetUsedField()

Global earth:TImage=LoadImage("gfx/earth.bmp")
Global water:TImage=LoadImage("gfx/water.bmp")
Global fire:TImage=LoadImage("gfx/fire.bmp")
Global wind:TImage=LoadImage("gfx/wind.bmp")
'0 = Null
'1 = Earth
'2 = Water
'3 = Fire
'4 = Wind
'5 = Heaven

For i = 0 To 11
	For j = 0 To 7
		blockfield[i,j]=Rand(1,4)
	Next
Next

While Not KeyDown(KEY_ESCAPE)
	Cls
	
	For i = 0 To 11
		For j = 0 To 7
		Select blockfield[i,j]
			Case 1
				DrawImage(earth,i*48,j*48)
			Case 2
				DrawImage(water,i*48,j*48)
			Case 3
				DrawImage(fire,i*48,j*48)
			Case 4
				DrawImage(wind,i*48,j*48)
			Default
		End Select
		Next
	Next
	
	If MouseDown(1) Then
		Local BlockX:Int=Floor(MouseX()/48)
		Local BlockY:Int=Floor(MouseY()/48)
		DrawText("BlockX: "+BlockX,16,400)
		DrawText("BlockY: "+BlockY,16,400+16)
		ResetUsedField()
		KillBlock(BlockX,BlockY,blockfield[BlockX,BlockY])
	End If
	
	Flip
Wend

Function KillBlock(x:Int,y:Int,c:Int)
	blockfield[x,y]=0
	usedfield[x,y]=1
	If x<11 And blockfield[x+1,y]=c And Not usedfield[x+1,y]=1 Then
		killblock(x+1,y,c)
	End If
	If y<7 And blockfield[x,y+1]=c And Not usedfield[x,y+1]=1 Then
		killblock(x,y+1,c)
	End If
	If x>0 And blockfield[x-1,y]=c And Not usedfield[x-1,y]=1 Then
		killblock(x-1,y,c)
	End If
	If y>0 And blockfield[x,y-1]=c And Not usedfield[x,y-1]=1 Then
		killblock(x,y-1,c)
	End If
End Function

Function ResetUsedField()
	For i = 0 To 11
		For j = 0 To 7
		usedfield[i,j]=0
		Next
	Next
End Function