#Formula Help
1 messages · Page 1 of 1 (latest)
with any number of tiles
so that they're evenly spaced apart
with the first and last aways being the same distance from the edge
var _x_loc = x - ((sprite_width * 0.9 )/ 2) + (sprite_get_width(spHolder) / 2);
for(i = 0; i < size; i++)
{
var _holder = instance_create_depth(_x_loc, y, -8, oTileHolder);
var _array = tile_holder_array;
array_push(_array, _holder);
_holder.owner = self;
_x_loc += _space_between_tiles;
}```
this is my code so far
but it's not quite there
(I set origins to middle center)
are you trying to render the tiles
or are you trying to give them coordinate data to store to be rendered?
there is a difference between trying to render a set of data in a pattern, and storing the data for direct access to be rendered
did I answer your question?
so the naieve solution to draw these, if they weren't even individual objects would be this
var _size = array_length(tile_array);
var _margin = 4; // arbitrary, space from one square to the render position of the tile, assumed to be square
var _width = sprite_get_width(sTile) + (_margin * 2); // Space of an entire tile sprite + its left and right margins
var _cur_tile;
var _start_x = 200; // Coordinate where to start draw the strip of squares
var _start_y = 300; // ...
for (var _i = 0; _i < _size; _i++){
_cur_tile = tile_array[_i]; // If you need the tile in the array at all, now you've got it
draw_sprite(sTile, 0, _start_x + (_width * _i) + _margin, _start_y + _margin);
}
and that works at any size?
that's just drawing a strip of sprites of an arbitrary size
with a margin
and a start position
if you wanted to actually store these tiles as structs/instances in an array, that's also pretty easy, I'll write that up
they are stored in an array in my code
I'm sorry, I got hella distracted and wrote an entire scrabble player creation/ hand dealing routine
I forgot to ask something
Are you trying to render your letter tiles a fixed distance apart, or are you trying to render them evenly distributed between two points?
like ever?
it's true I never feel well
no I mean you've never programmed before