Skip to main content
gamedev.net
🔒 Locked

Grids

Started by Drakon Dec 21, 2001 at 5:56 AM 1 replies 200+ views
Original Post
Drakon
Drakon
I''m making a level editor for a game I''m making in VC++. Does anyone know how to make grids in VB? I''m to the point where I can create lines and such, but I need them to snap to grid. Help would be appreciated.
"Go for the eyes, Boo, go for the eyes!"
intrest86
intrest86
Ok, you were a little vague, so I will help you as much as I can right now. First, chose the number of grid lines you want up and down the screen, then set the scalewidth and height of the container object you are using to that number. Whenever you create an object on the container use a grid the size of scale to place things...

got to go, come back later

If one person would write a book on DirectX in VB, I would make them a rich man!
Turring Machines are better than C++ any day ^_~
krez
krez
In your form:

Private Const X_SQUARES = 10
Private Const Y_SQUARES = 10
Private gX as Single, gY as Single

Private Sub Form_Load()
gX = ScaleWidth / (X_SQUARES + 1)
gY = ScaleWidth / (Y_SQUARES + 1)
End Sub
Private Sub Form_Resize()
For t% = 0 to (X_SQUARES + 1)
Line(t% * gX, 0) - (t% * gX, ScaleHeight)
Next t%
For t% = 0 to (Y_SQUARES + 1)
Line(0, t% * gY) - (ScaleWidth, t% * gY)
Next t%
End Sub

that should give you a 10x10 grid...

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.