[edit: attached Customer Service tag, but can’t change that…]
I have this Cartesian Coordinates. At 0,0 I place a square, then I go south 1 and place a square, go west 1, place a square, go north 1, go east 1, place a square, go south etc.
In every step it must be considered if the neighbor (for direction east look south, for direction south look west, for direction west look north, for direction north look east) square is empty. If so, continu that path, place a pixel. Loop.
For the first steps the algorithm looks like:
dim x,y as integer
dim steps as integer = 5000
//placeCube draws the cube or pixel
//go south 1
The thing I try to put in the algorithm is that when encountered a neighbor, place a cube and then change course as directed. Help very much appreciated…
You might want to move this to the general channel. I suspect you won’t get too many answers in Customer Service.
Add a direction component to your algorithm say
1 = South
2 = West
3 = North
4 = East
Then in your loop you would test the next cell based on which direction you’re moving
Select Case Direction
Case 1 ’ Keep moving south until I can move West
If cell(x -1, y + 1) = True Then ’ cube there
y = y + 1 ’ keep moving south
x = x - 1
Direction = 2
OK, thanks Wayne. I’ll look into that.
I believe something like this should work:
Dim i as integer
Dim x as integer
**loop ___ times
for x = 0 to i
for x = 0 to i
i = i + 1
This assumes that the grid is blank already, as it doesn’t actually check for an occupied block, it just iterates over 2 sides of the same # of blocks, then increases the # by 1 for the next 2 sides.