Currently Selected Tile (Types)

Blitz3D Forums/Blitz3D Beginners Area/Currently Selected Tile (Types)

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.

Hi,

Hmm, I didn't have the array set up, so I'll introduce that and see if I can get it to work. In the mean time, here's my code (relevant parts)

; Variable & Type Dimensions-----------------------------------------------------------------------------------------------------

Global state=0 ; Game state variable.
Global mx,my ; Mouse X and Y co-ordinates.
Type tile
Field x,y,l
End Type

; Media--------------------------------------------------------------------------------------------------------------------------

Global gfxpoint=LoadImage("gfx\hand.png") : MaskImage gfxpoint,255,0,255
Global gfxboard=LoadImage("gfx\board.png")
Global gfxletters=LoadAnimImage("gfx\letters.png",129,128,0,78) : MaskImage gfxletters,255,0,255

; Main Game Loop-----------------------------------------------------------------------------------------------------------------

Repeat

	Cls
	If state=0 Then
		Generate()
	End If
	Display()
	Flip

Until KeyHit(1)

; Functions----------------------------------------------------------------------------------------------------------------------

Function Display()
	DrawImage gfxboard,0,0
	mx=MouseX()
	my=MouseY()
	mxa=Floor((mx-53)/129)
	mya=Floor((my-62)/128)
	For letter.tile=Each tile
		DrawImage gfxletters,letter\x,letter\y,letter\l
		If mx>=53 And mx<698 And my>=62 And my<702
			DrawImage gfxletters,(mxa*129)+53,(mya*128)+62,letter\l+26
		End If
	Next 
	DrawImage gfxpoint,mx,my
End Function


Thanks!