This other piece of code doesn't work as intended :
Code: Select all
EnableExplicit
; constants
Enumeration
#WinMain
EndEnumeration
Enumeration
#SpriteHex
EndEnumeration
#Black = 0
#White = 16777215
#Red = 255
#Green = 65280
#Blue = 16711680
; structures
; globals
; imports
; XIncludeFile "LibAALines.pb"
; procedures
Procedure.i HexCornerX(hexX.f, hexSize.i, i.i)
Define angle.f
angle = 60 * i + 30
angle = Radian(angle)
ProcedureReturn hexX + hexSize * Cos(angle)
EndProcedure
Procedure.i HexCornerY(hexY.f, hexSize.i, i.i)
Define angle.f
angle = 60 * i + 30
angle = Radian(angle)
ProcedureReturn hexY + hexSize * Sin(angle)
EndProcedure
Procedure DrawHex(x.i, y.i, hexSize.i)
Define loop.i
; DEBUG
Box(x, y, 5, 5, #Blue)
; For loop = 0 To 5
; If loop < 5
; AALines::NormalL(HexCornerX(x, hexSize, loop), HexCornerY(y, hexSize, loop), HexCornerX(x, hexSize, loop + 1), HexCornerY(y, hexSize, loop + 1), #Red, 2)
; Else
; AALines::NormalL(HexCornerX(x, hexSize, loop), HexCornerY(y, hexSize, loop), HexCornerX(x, hexSize, 0), HexCornerY(y, hexSize, 0), #Red, 2)
; EndIf
; Next loop
EndProcedure
Procedure ShowHexes()
DisplayTransparentSprite(#SpriteHex, ScreenWidth() / 2, ScreenHeight() / 2)
EndProcedure
Procedure Init()
; init environment
If InitSprite() And InitKeyboard()
OpenWindow(#WinMain, 100, 100, 640, 480, "Hexperimentations", #PB_Window_BorderLess)
OpenWindowedScreen(WindowID(#WinMain), 0, 0, 640, 480)
Else
MessageRequester("Error", "Cannot initialize environment")
End
EndIf
; draw hexes individually
CreateSprite(#SpriteHex, 60, 60, #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#SpriteHex))
DrawHex(30, 30, 25)
StopDrawing()
EndProcedure
; init
Init()
; main loop
Repeat
While WindowEvent() : Wend
FlipBuffers()
ClearScreen(0)
ShowHexes()
Delay(1)
ForEver
That should draw a little blue square (Box(x, y, 5, 5, #Blue)).
Works fine on Windows.
Note : I can't access native constants and structures such as #Red or point ; don't know if it's normal. (hence the manual declaration of color constants)