Code: Select all
Enumeration
;windows
#mainWindow
;images
#boardImg
#tileGradientImg
;sizes
#boardWidth = 500
#boardHeight = #boardWidth
#tileWidth = 50
#tileHeight = #tileWidth
EndEnumeration
Procedure placeMinorTiles(x,y,width,height,Color)
Protected x2,y2
x * #tileWidth
y * #tileHeight
DrawingMode(#PB_2DDrawing_AlphaBlend)
For x2 = x To x + width * #tileWidth - 1 Step #tileWidth / 5
For y2 = y To y + height * #tileHeight - 1 Step #tileHeight / 5
Box(x2,y2,#tileWidth / 5,#tileHeight / 5,RGBA(Red(Color) + Random(128),Green(Color) + Random(128),Blue(Color) + Random(128),$FF))
DrawImage(ImageID(#tileGradientImg),x2,y2,#tileWidth / 5,#tileHeight/ 5)
Next
Next
EndProcedure
Procedure createBoard()
Protected x,y, color = $000080
CreateImage(#boardImg,#boardWidth,#boardHeight,32)
StartDrawing(ImageOutput(#boardImg))
DrawingMode(#PB_2DDrawing_AlphaBlend)
For x = 0 To #boardWidth - 1 Step #tileWidth
For y = 0 To #boardHeight - 1 Step #tileHeight
Box(x,y,#tileWidth,#tileHeight,RGBA(Random(225) + 25,Random(225) + 25,Random(225) + 25,$FF))
DrawImage(ImageID(#tileGradientImg),x,y,#tileWidth,#tileHeight)
Next
Next
placeMinorTiles(1,1,1,5,color)
placeMinorTiles(2,1,2,1,color)
placeMinorTiles(3,2,1,1,color)
placeMinorTiles(2,3,2,1,color)
placeMinorTiles(5,4,1,5,color)
placeMinorTiles(6,4,2,1,color)
placeMinorTiles(8,5,1,1,color)
placeMinorTiles(6,6,2,1,color)
placeMinorTiles(8,7,1,1,color)
placeMinorTiles(6,8,2,1,color)
StopDrawing()
EndProcedure
If Not OpenWindow(#mainWindow,0,0,#boardWidth,#boardHeight,"Test",#PB_Window_SystemMenu)
MessageRequester("Error","Unable to open main window")
End
EndIf
;create tileGradient
CreateImage(#tileGradientImg,#tileWidth,#tileWidth,32)
StartDrawing(ImageOutput(#tileGradientImg))
DrawingMode(#PB_2DDrawing_AlphaChannel | #PB_2DDrawing_Gradient)
LinearGradient(0,0,OutputWidth(),OutputHeight())
GradientColor(0,$00000000)
GradientColor(0.49,$30000000)
GradientColor(0.50,$50000000)
GradientColor(1,$80000000)
Box(0,0,OutputWidth(),OutputHeight(),$00000000)
DrawingMode(#PB_2DDrawing_AlphaChannel)
Line(0,0,#tileWidth / 2,#tileHeight / 2,$00000000)
Line(#tileWidth / 2,#tileHeight / 2,#tileWidth / 2,#tileHeight / 2,$80000000)
Box(#tileWidth / 10,#tileHeight / 10,#tileWidth - #tileWidth / 5,#tileHeight - #tileHeight / 5,$40000000)
StopDrawing()
createBoard()
ImageGadget(0,0,0,0,0,ImageID(#boardImg))
Define event
Repeat
event = WaitWindowEvent(10)
Until event = #PB_Event_CloseWindow
@Edit: updated code for PB v4.40b2 by adding the image depth (32) to createImage()