Creating Maximum Movement Indicators on a Board

0 favourites
From the Asset Store
Set of 21 Food plus 6 boards, for different kind of games
  • Your array population starts off by picking the square nearest to 0,0

    Does the array population still work if there is no square in the top left corner?

    It assumes few things:

    The game board is rectangle

    Each row has equal amount of squares

    Each column has equal amount of squares

    So you'll need to have a 'top left' square. :)

  • Also, another possible problem is that the squares on the board are not placed exactly in a multiple of 32, at least not when using Yann's random grid generator.

    I've contacted him asking about why the offsets are necessary.

    vee41 this is another problem. The original version of my game used squares and walls. The latest iteration destroys the walls so the background below can be shown. This means at some points, there will be no square.

  • vee41 this is another problem. The original version of my game used squares and walls. The latest iteration destroys the walls so the background below can be shown. This means at some points, there will be no square.

    You could still have the square object, just make it invisible.

  • Hmm, I'm under the impression that destroying it is better for memory usage, especially since I'm testing this on my iPad. Am I wrong?

  • Hmm, I'm under the impression that destroying it is better for memory usage, especially since I'm testing this on my iPad. Am I wrong?

    Few invisible objects (you could turn off collisions as well) won't do anything for performance. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm honestly still not convinced.

    Your method works, and I'm not going to question that. It's also simple and easy to understand.

    However, I do think it's possible to do this without making the squares be there (even if invisible). I have a screenshot on page 1 showing how I'm trying to do it, although for some odd reason it fails after a certain point and begins saying all remaining squares on the board do not exist, and I'm not quite sure why.

    Another reason is because I don't want to have to populate the entire board when creating a pregenerated board state. I want to be able to place the squares (aligned to grid, of course) and not have to place invisible ones in order for the array to work.

  • I'm honestly still not convinced.

    Your method works, and I'm not going to question that. It's also simple and easy to understand.

    However, I do think it's possible to do this without making the squares be there (even if invisible). I have a screenshot on page 1 showing how I'm trying to do it, although for some odd reason it fails after a certain point and begins saying all remaining squares on the board do not exist, and I'm not quite sure why.

    Another reason is because I don't want to have to populate the entire board when creating a pregenerated board state. I want to be able to place the squares (aligned to grid, of course) and not have to place invisible ones in order for the array to work.

    Sure, it is possible, but it will take a whole different approach. Just making some squares invisible is the simplest way to do what you want. Don't really see why placing invisible squares is a bad thing, takes about 5 seconds. :)

    Creating a level could be like this :

    Create row of 20 squares

    Select all, and copy paste them as 15 columns

    Add walls

    Make some squares invisible if necessary

    But you know better yourself what you want your process to be, this is just how I would create something like your screenshots at first post suggest.

  • vee41

    The game board is 18x7, and filling every possible space with a square (even if invisible) is 126 sprites. Add in UI sprites, the gameplay sprites, background image + sprites to create background animations, and we're looking at 180-200 sprites on screen. Thankfully, this game is turn-based so these sprites aren't all moving in real-time.

    I intend to make the game as flashy as possible while minimizing the amount of sprites that are 'doing nothing'.

    Now, I'm not sure what the performance gains are on not having sprites vs. making sprites invisible, but maybe Ashley (or anyone who is knowledgeable on this matter) can explain whether the performance gains caused by removing sprites altogether (as opposed to making them invisible) is going to make a difference.

  • Performance impact is non-existent like I said, would not worry about that.

  • vee41, I've read up some more and invisible sprites actually seem to do nothing to performance, so you are right.

    I'm having issues replicating your array method, as it seems like every spot in my array is getting the same value for some odd reason:

    <img src="http://i.imgur.com/JWx7YpX.png" border="0" />

    I tried to convert your array code to work for my program. The catch is that yours checks the animation state, mine has to check if a sprite is invisible (as opposed to animation state), and whether there is a program sitting on it (I don't destroy the board spaces when a unit is placed on top of them, as the units exist on a layer above them and have the appearance of 'sitting' on the board spaces).

    <img src="http://i.imgur.com/n1mMaYJ.png" border="0" />

    Any idea why I'm getting the same array value every time?

  • It seems you first pick an empty space (the top left one), then try to pick some more after that. That won't work, as you have already narrowed the selected objects to that single tile, so you can't pick outside it.

    Move the loops up one level, so you won't have the top left emptyspace picked when starting the loops.

    It also seems odd that you have this in a group. Function would be much more fitting and easier to use in my opinion. :)

  • vee41, I've moved it into a function, which is now called at the start of the player's turn. I'll fiddle around with the updating as I flesh the game out further.

    I'll start working on the grid display next :)

  • vee41

    I noticed in your highlight move function, you check whether the space is invisible or not in the array. However, my program has an additional complcation: units on the board can take up more than one space (their 'parts' can occupy more than once space). In my array, if a square is occupied by a program, the UID of the program is stored in the array.

    To check that the square is also not being occupied by a program, would I have to run a loop to see if some Program.UID (they're all in a family) does not equal the value stored at that location in the array? Or does one line of family.UID = Array.Value automatically check for the UIDs in the family for a match?

    <img src="http://i.imgur.com/pTlQ4CO.png" border="0" />

    Complicated question, I know :(

  • I've checked the array in the debugger. The function to create move point should be firing since the extra clause mentioned above is not an issue when all the programs are sitting on their spawn points and only occupy one space.

    However, I'm not sure why they're not showing up:

    <img src="http://i.imgur.com/YLlOrJI.png" border="0" />

    The highlight code is exactly the same as vee41's (his example works 100% perfectly):

    <img src="http://i.imgur.com/UE2pzss.png" border="0" />

    I think the problem lies in the actual function call:

    <img src="http://i.imgur.com/nepJquq.png" border="0" />

    I have the spawn highlighting section hidden because the highlighting is clearly working. I'm not quite sure what is wrong.

  • So you essentially want your play tokens (programs) to block movement, or did I misunderstand? Anyways, I added that functionality to my example. :)

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)