Creating Maximum Movement Indicators on a Board

Get help using Construct 2

Post » Thu Aug 08, 2013 8:00 am

@vee41, What do the Square.xi and Square.yi variables represent? And why is it necessary to set them to loopindexes?Excal2013-08-08 08:00:18
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 08, 2013 8:03 am

X-index and Y-index.

They represent the objects position at the array, so we can use them to index the array position of the square. They kind of link the 'realworld' object positions to the position in the array, this way array knows which squares are around it in each direction. So we can index the square left of square with array.at(xi+1, yi)

Not the prettiest way to do things, but quite efficient in this case. :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 08, 2013 8:26 am

I think the problem, in my case, is that I want the array creation to be more flexible.

For example, my program currently uses a script to randomly generate the game board. However, the array population function occurs in a different event sheet - the gameplay event sheet. This is because I want to be able to populate an array that represents the board state regardless of how the board was generated (whether through the random board generator or using a pre-created board state).

However, your approach for populating the array should still work I think. You set the xi and yi values when you populate the array, so I suppose for it's okay in my program to generate the board, populate array, and then set the squares to match certain array values.

I'll give it a shot using your array population method and let you know how it goes.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 08, 2013 8:33 am

[QUOTE=Excal] I think the problem, in my case, is that I want the array creation to be more flexible.

For example, my program currently uses a script to randomly generate the game board. However, the array population function occurs in a different event sheet - the gameplay event sheet. This is because I want to be able to populate an array that represents the board state regardless of how the board was generated (whether through the random board generator or using a pre-created board state).

However, your approach for populating the array should still work I think. You set the xi and yi values when you populate the array, so I suppose for it's okay in my program to generate the board, populate array, and then set the squares to match certain array values.

I'll give it a shot using your array population method and let you know how it goes.[/QUOTE]

It shouldn't matter whether the squares are generated or preplaced in my example, so it should work.
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 08, 2013 8:35 am

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?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 08, 2013 8:40 am

[QUOTE=Excal] 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?[/QUOTE]

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. :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 08, 2013 8:42 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 08, 2013 8:45 am

[QUOTE=Excal]
@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.[/QUOTE]

You could still have the square object, just make it invisible.
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 08, 2013 8:46 am

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?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 08, 2013 8:48 am

[QUOTE=Excal] 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?[/QUOTE]

Few invisible objects (you could turn off collisions as well) won't do anything for performance. :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: lesthevrlover, plinkie and 27 guests