• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Anno Game Help

H

HugoStiglitz

Guest
Hello guy´s,
This is my first Thread on this forum and I hope that there isn´t another thread about this Topic ^^.
So now to my question:

I am currently working on a game like Anno. But I have a problem with the placing of the building. I have made a simmilar game in Lazarus(PowerPascal) but I don´t know how to generate a grid on wich I can place the buildings.

thanks for the help :)

HugoStiglitz
 
H

HugoStiglitz

Guest
Yeah I tried to work with ds_grids, but I don´t know how to use them as a grid in the room where I can place a building in every panel:)
 
P

Paolo Mazzon

Guest
Okay, I'm going to assume that you have multiple different sizes of buildings (Which would mean some buildings would take up multiple slots in the grid), so I will take a different approach. Use a ds_list, and don't store things as places in a grid. The basic idea is adding the buildings to the list, then when you need to draw them or check or whatever, you can just loop through that list.

When you place a buildings, what you would do is
  1. Get the x/y/orientation of the new building
  2. Loop through every building already in the list and check if the new one is overlapping with another
  3. If not, then place the building there and append that building to the list with its coordinates and orientation for later collision checking
This makes drawing really fast as well, since you're not looping through any grids that have nothing on them, and makes it easier to provide in depth statistics when you can just loop through everything available and collect statistics. Since the buildings will store their coordinates, drawing will also be easy.
 
H

HugoStiglitz

Guest
Thanks man!!! I din´t thought that I would get an answer so fast ^^ :)
 
Top