A "Fifteen" game mechanics?

Get help using Construct 2

Post » Mon Jul 02, 2012 11:38 am

Hello everyone!

My name is Alex. First of all I'm very happy about being a part of this community and I'll contribute as much as I can.

I'm new to Construct 2, so of course, there are tons of questions in the head. I'll read all FAQ's and manuals eventually, but for now I'm a bit lost.

Currently working on a "15" game and I have no idea how to do a math part. I have some experience in programming (it was Visual Basic 5 long time ago), so some common terms and principles won't make me halt .

So here it is: How do I generate an array full of 16 random numbers (each time different order, as I remember if rnd is not properly done, it may repeat the same randomness after restart) and then assign them to 16 global variables and then place each one to a preset XY coordinates, providing I have some graphics - a field, 15 tiles and so on.

Any help would be very much appreciated
B
3
Posts: 2
Reputation: 329

Post » Mon Jul 02, 2012 2:27 pm

Hello, welcome to the community.

I'm not sure I understand what you want to do. I have two questions to make things a bit more clear, if you don't mind:

Why do you want to add the numbers to global variables if you've already stored them in an array? Why not just refer to the array when you need the number?

And what is it you're looking to place based on coordinates? Do you mean you want to place sprites based on values in the variables/array?

If you could make your problem a bit more clear, I'm sure I (or someone else) can help you out.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Jul 02, 2012 4:10 pm

B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Jul 02, 2012 4:13 pm

Ashley sneaked in a function for array that's quite useful for this.

https://dl.dropbox.com/u/666516/nonRepeatingRandomList.capx
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jul 04, 2012 8:40 pm

Thank you guys for a quick reply!

@R0J0hound: I tried to open fifteenGameRandomProblem.capx but it says "object type uses unknown plugin ID". As it doesn't say which one, I guess it's time to install them all
Will look into other links as well.

@Nimtrix: Sorry for a confusion. What I thought was 16 points with X and Y coordinates that are bound to 16 variables, so when I shuffle them in the beginning every tile would go to appropriate coordinates. Does it make sense? Can array store both X and Y for every tile?

@newt: The random in this example is absolutely the same each time I click. There are different variations upon restart though. But I need full random each time.
B
3
Posts: 2
Reputation: 329


Return to How do I....?

Who is online

Users browsing this forum: Matthew de, onzephyr and 0 guests