yet another array question

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi all. I need help about arrays. I couldn't still learn to use arrays :'(.

    When it becomes just little 2 dimensional array, my brain shuts down. And if I choose to go with private variables, then I can't pick proper ones and can't use proper functions. Sorry for long introduction.

    Here is my project;

    I have an sprite to use as an excel like cell. I want to spread it to window(maybe later to a proper area). So I used

    for x from 0 to round(displaywidth/sprite.width)

    for y from 0 to round(displayheight/sprite.height)

    add 1 to sprite.count

    So all of the sprites has different private value than each other.(but I think this is not enough to handle) After that things get complicated.

    Here is my problem;

    If I drag a text onto one of sprites, I equal sprite's width to text's witdh. But if text's witdh greater then sprite's witdh so it overlaps with other sprite, just the opposite, if it's lower then there becomes a space.

    Here is my question;

    For example on (3,4) cell, if I put a wider text. How can I push cells which overlaps to right(4,4)(5,4)(6,4) And if last cell on that row goes out of screen, than it should go down row's head. And of course other cells should do same basics.

    And also what if I delete one of the cells. So I guess (3,4) should be (2,4) and the rest same. What if I want to add between one of them. :(

    I think this is very hard to do with private variables. I should learn to use 2d arrays. Then with some maybe mathematical functions this can be done. But as I mentioned before I can't think that wide.

    I had seen an example before which was a complete space shooter game with enemy ai done with only arrays and functions. Omg it was amazing. But I couldn't learn to use arrays even with those examples.

    Sorry for long post. I can send my cap :) but there is nothing more then tons of private variables and a sprite and text. :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)