Page 1 of 1

Building size

Posted: Mon Apr 18, 2016 11:30 pm
by dewast
HI
Where and how can I operate building size, it corelation with graffic size and opsticle (can I go betwen 2 of them, or ar they making wall).
Or where is forum page about that.
Thanks for time and help.

Re: Building size

Posted: Fri Apr 22, 2016 10:23 am
by bobingabout
I think the 2 tags collision_offset and selection_offset are what you need to look at, they list an array of a pair of 2D co-ordinates, EG {{-1,-1},{1,1}}, This example creates a 2x2 entity.

The co-ordinates are the top left position from center, and bottom right position from center. The number of tiles this will actually occupy is calculated and rounded up, so the center point moves from the center of a tile, to between the tiles to match an odd/even width/height.

The selection box is the one you see when you point to an entity, the collision box is often smaller than the selection box though, by about 0.2 to 0.3 either side, this allows the player to walk between entities placed next to each other, and also prevent very close objects from blocking placement by rounding error.

So a 1x1 would have selection {{-0.5, -0.5},{0.5, 0.5}}, and collision {{-0.3, -0.3},{0.3, 0.3}}, Then for each tile you want wider/taller, add 0.5 to the coordinates as needed
A 2x2 would be around selection {{-1,-1},{1,1}}, and collision {{-0.8, -0.8},{0.8, 0.8}},




Also note: The listed tag names are off the top of my head, they may not be accurate, but look for collision and selection followed by an array similar to what I listed on existing entities, those are the 2 lines you need to edit to control building size.

Yes, dispite making one of the most popular mods for the game, my memory for tag names is terrible, pretty much everything I've programmed has been while looking at code with an example of the tags I'm after, and in a lot of cases, just copy and paste from one entity to another to make sure the tag is correct. Don't get me wrong, I understand what pretty much every tag does and why it is needed, I just can't remember the exact names, and how to spell them.

Re: Building size

Posted: Fri Apr 22, 2016 5:31 pm
by dewast
Is the picture size mather or it is scaled to match grid placement 1*1 2*2 and 3*3

like how to understand this part
the width and height is the picture size in file and shift is for what?
it is for 2*2 placemant

base_picture =
{
filename = "__Beacon MK__/graphics/entity/basic-beacon/basic-beacon-base.png",
width = 77,
height = 62,
shift = { 0.23, 0.04}
},

Re: Building size

Posted: Fri Apr 22, 2016 9:16 pm
by bobingabout
Picture size does matter, you can add scale=0.5 to half the graphic size, or scale=2 to double it.

So if you want a 2x2 building, you want a 64x64 image. if your sprite image is 128x128 pixels in size, then it's 4x4, a scale = 0.5 would change it to a 2x2 structure.

Now, imagine the sprite sheet as a uniform grid. the middle of each of these grids will be the middle of your building in the world, centered either in the middle, or on the edge of the tile depending on building size. if the sprite in this tile is not centered, you can use shift to adjust it's position so it aligns to game grid. the values are {x,y} movement in whole (32 pixel) game tiles, I forget the direction, for example, I forget if 0.5 for x would move it half a tile left, or half a tile right, just try it and see what happens.
width and height at the values of the grid size on your sprite sheet. As I said, imagine a uniform grid. So in this example, 77,62 for the beacon, that would mean each square of the grid in the sprite sheet is 77 pixels wide, and 62 pixels tall. So the first frame of this sheet occupies pixels 0 to 76 on the X, and 0 to 61 on the Y. the second frame of the sprite would be pixels 77 to 153 on the X, and still 0 to 61 on the Y.