Check if I've been there

Get help using Construct 2

Post » Sun Feb 10, 2013 11:10 pm

Hello!

As a quick disclaimer: I'm very new to this so basic step-by-step answers would be greatly appreciated.
I'm working on a digitalized version of a board game that is 15x10 squared and for this I need to know if my player character has already visited a certain position. I just can not figure out how to do it, anybody has the answer?
B
1
Posts: 3
Reputation: 231

Post » Mon Feb 11, 2013 12:29 pm

-bump-
B
1
Posts: 3
Reputation: 231

Post » Mon Feb 11, 2013 12:37 pm

I'd make a local variable (boolean) for each square called something like 'visited'. Set it to false by default, and then when the player is overlapping the square, set the boolean to true.

Then you can simply check if the boolean is true or false to know if the square has been visited.
B
4
Posts: 8
Reputation: 391

Post » Mon Feb 11, 2013 2:05 pm

I thought about that but that would require 150 booleans, is there no easier way? :P
B
1
Posts: 3
Reputation: 231

Post » Mon Feb 11, 2013 2:14 pm

[QUOTE=grotgar] I thought about that but that would require 150 booleans, is there no easier way? :P[/QUOTE]

unless your squares are separate objects you can do with just one. Instances of square object will have their own variable. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Feb 11, 2013 8:06 pm

To further elaborate on what vee41 was saying.

Basically you would create one sprite representing the game board.
You could vary up the look of the piece, by using a different frame of animation for a different "look" to the piece if it has a variety of types lets say.

Then you would give it one variable called "visited"

When you create multiple instances of the board square, each one will then have its own "visited" variable that will keep track of itself

then you would simply code something like this.

player is overlapping object "board piece"
-> set "visited" to 1

or however your game works.

then late you could check if its visited by doing.

(board piece) visited = 1
-> do this



B
50
S
21
G
8
Posts: 844
Reputation: 10,299


Return to How do I....?

Who is online

Users browsing this forum: Khamsou, Yahoo [Bot] and 19 guests