Hi. I need some help with my code. I'm trying to rotate block by changing their positions.
here is my code. Check out the rotate function.
Use this image.
here is my code. Check out the rotate function.
Strict Graphics 1024,768,16,60 SetMaskColor 255,0,255 Global tiles:TImage = LoadAnimImage("fulltiles.png",32,32,0,16,MASKEDIMAGE) Global tilesX:Int = 300 Global tilesY:Int = 100 Global bricklist:TList = CreateList() Type brick Field TopLeftX Field TopLeftY Field TopRightX Field TopRightY Field BottomLeftX Field BottomLeftY Field BottomRightX Field BottomRightY Function tile_create() Local b:brick = New brick b.TopLeftX = 0 b.TopLeftY = 0 b.TopRightX = 32 b.TopRightY = 0 b.BottomLeftX = 0 b.BottomLeftY = 32 b.BottomRightX = 32 b.BottomRightY = 32 ListAddLast bricklist,(b) End Function Function draw_tiles() For Local b:brick = EachIn bricklist DrawImage tiles,tilesX+b.TopLeftX,TilesY+b.TopLeftY,0 DrawImage tiles,tilesX+b.TopRightX,tilesY+b.TopRightY,1 DrawImage tiles,tilesX+b.BottomLeftX,tilesY+b.BottomLeftY,2 DrawImage tiles,tilesX+b.BottomRightX,tilesY+b.BottomRightY,3 Next End Function Function rotate() If KeyHit(KEY_LEFT) For Local b:brick = EachIn bricklist b.TopLeftX = b.BottomLeftX b.TopLeftY = b.BottomLeftY b.TopRightX = b.TopLeftX b.TopRightY = b.TopLeftY b.BottomRightX = b.TopRightX b.BottomRightY = b.TopRightY b.BottomLeftx = b.BottomRightX b.BottomLeftY = b.BottomRightY Next End If End Function End Type brick.tile_create() While Not KeyHit(KEY_ESCAPE) Cls brick.draw_tiles() brick.rotate() Flip FlushMem Wend
Use this image.