Source Code: DrawGrid()
Syntax
DrawGrid( gridX#, gridY#, gridWidth#, gridHeight#, numbCellsX, numbCellsY )
- gridX# - x position of the grid
- gridY# - y position of the grid
- gridWidth# - width of grid
- gridHeight# - height of grid
- numbCellsX - number of horizontal cells
- numbCellsY - number of vertical cells
Explanation
DrawGrid() dynamically draws a grid. Make sure you place it between Cls and Sync.
Example
SetFPS 60
Do
Cls 0
DrawGrid( 100, 100, 200, 200, 25, 25 )
Sync
Loop
Source Code
PSub DrawGrid( gridX#, gridY#, gridWidth#, gridHeight#, numbCellsX, numbCellsY)
If numbCellsX < 1 Then numbCellsX = 1
If numbCellsY < 1 Then numbCellsY = 1
LockBuffer
For i# = 0 To gridWidth# Step gridWidth# / numbCellsX
Line gridX#+i#,gridY#, gridX#+i#, gridY# + gridHeight#
Next
If Mod(gridWidth#, numbCellsX)
Line gridX#+gridWidth#, gridY#, gridX#+gridWidth#, gridY#+gridHeight#
EndIf
For i# = 0 To gridHeight# Step gridHeight# / numbCellsY
Line gridX#, gridY# + i#, gridX# + gridWidth#, gridY# + i#
Next
If Mod(gridHeight#, numbCellsY)
Line gridX#, gridY#+gridHeight#, gridX#+gridWidth#,gridY# + gridHeight#
EndIf
UnlockBuffer
EndPSub
| Categories: Graphics : Graphics Source Code : Source Code |