#Formula Help

1 messages · Page 1 of 1 (latest)

trail valeBOT
midnight rapids
#

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)

late warren
#

are you trying to render the tiles

#

or are you trying to give them coordinate data to store to be rendered?

midnight rapids
#

they each have draw_gui events

#

that draw_self();

late warren
#

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

midnight rapids
#

did I answer your question?

late warren
#

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);
}
midnight rapids
#

and that works at any size?

late warren
#

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

midnight rapids
#

they are stored in an array in my code

late warren
#

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?

midnight rapids
#

lmao

#

I figured it out while you did

late warren
#

I'm so sorry

#

I'm not feeling well I just... started... programming

midnight rapids
#

like ever?

late warren
#

it's true I never feel well

midnight rapids
#

no I mean you've never programmed before

late warren
#

No, I just started to program something for you and didn't stop to think about what I was doing

#

I've been programming for years

#

glad you solved your problem