How do I fill a board with numbers stored in an array?

Get help using Construct 2

Post » Sun May 10, 2015 5:18 pm

Hello all,
I am trying to make a basic number puzzle game.

I have written down my algorihytm on a paper. I also have written my methods to make it ideally playable.

Now, I want to try visualising it on Construct2, for this, I need to pass the numbers stored in my array (4x4) to the game board and the user should be able to click them.

What should I use for that kind of design? I have been looking at an empty layout for 1 hour but couldn't think of something productive. Should I create a background with 4x4 squares, or should I create number blocks (only 16 numbers in the game) in photoshop as sprites?

To sum up, I am trying to visualise my 4x4 array, and will be very grateful to hear any ideas

Thanks
B
4
Posts: 9
Reputation: 232

Post » Sun May 10, 2015 5:29 pm

You are asking us what your game should look like?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun May 10, 2015 5:35 pm

More or less, it will look like this. I just want to learn some options on reflecting an array into a visual like the one below

Image
B
4
Posts: 9
Reputation: 232

Post » Sun May 10, 2015 5:39 pm

Image
B
63
S
23
G
7
Posts: 1,479
Reputation: 10,794

Post » Sun May 10, 2015 5:46 pm

korbaach wrote:https://www.scirra.com/forum/viewtopic.php?f=147&t=130154

ahha, worst game ever :)))
thank you for the input, I am checking your capx.

Edit: This is something that perfectly fits what I need and I think your design is very sophisticated. Although it is difficult to understand, it created an inspiration :)
B
4
Posts: 9
Reputation: 232

Post » Sun May 10, 2015 9:53 pm

Worst Game Ever 2 :D
(no rows and columns ..and startx...y)

capx> http://s000.tinyupload.com/index.php?fi ... 1672242838

and no json :)
capx> http://s000.tinyupload.com/index.php?fi ... 5167678494
Image
B
63
S
23
G
7
Posts: 1,479
Reputation: 10,794

Post » Mon May 11, 2015 8:59 am

Hello korbaach,
Thank you very much for your interest, this must have cost you some time.
I'm at work, and will be checking the files as soon as possible.

BTW, I would rep+ your post if there was a button for that :)
B
4
Posts: 9
Reputation: 232

Post » Mon May 11, 2015 2:00 pm

First of all, I must say you have created a more advanced game out of 2 newbie questions and you're about to produce a complete product :)))

I am checking your sample without JSON, because I am not familiar with JSON at all, yet.

At start of layout:
You set a 2 dimensional array with SpriteCount ,2 (SpriteCount array)
And you create another array (0,1,1) (ArrayPosition) so, initially this array has 0 size.

Then,
You go through all the instances of the Sprite, you set the values stored in the array's 1st column, to X values of the sprites, and you set the values stored in 2nd column of the array to the Y values of the sprites.

I can understand that you are triggering the "Set" method (or function) when the Sprite.Count is 0. This happens both when the user clicks and destroys all boxes, and also is triggered at start of the layout because there is "Sprite Destroy" item at start.

I am trying to figure out the "set" function,
A local variable named Rnd is created and set to 0, OK.

A for loop is created, it will use "frame" variable from 0 to ArrayPosition.Width-1 which is 1 less than the sprite count, OK. It will be looped for Sprite.Count times as it starts from 0.
"Push back loopindex on X axis" -> you insert loopindex value to the ArrayFrames array, and I guess since you are pushing to X axis, it should be like (0,1,1) where 0 is X. That would populate the ArrayFrames's X address with 0,1,2,3...15 for 16 sprites.

WHen we come to ForEach statement, we create a random integer between1-15 (width of ArrayFrames) and then Create a sprite at positions related to ArrayPosition.At(ArrayPosition.CurX,0), ArrayPosition.At(ArrayPosition.Curx,1) I just couldn't get where this part can get the actual position information instead of just 0,1,2,3...

After creating the sprites, the animation frame of each sprite is taken from the randomth element of ArrayFrames array. This is a very clear and clever approach, IMO.

I have 2 things that I couldn't understand completely:
1. How do you prevent repetitive numbers to take place? I couldn't get that part of the logic in the event sheet.
2. How is the actual coordinates set? (ArrayPosition.CurX stuff)

You've already done more than I would expect, so it is still OK if you wouldn't like to explain further :roll:
B
4
Posts: 9
Reputation: 232

Post » Mon May 11, 2015 4:47 pm

gamewanderer wrote: I have 2 things that I couldn't understand completely:

Sorry @gamewanderer I'm not very good at explaining things..but maybe this'll help
I separated these two actions

gamewanderer wrote: 1. How is the actual coordinates set? (ArrayPosition.CurX stuff)


capx> http://s000.tinyupload.com/index.php?fi ... 8955414827

gamewanderer wrote: 2. How do you prevent repetitive numbers to take place? I couldn't get that part of the logic in the event sheet.


capx> http://s000.tinyupload.com/index.php?fi ... 9251756886

(click on Debug layout and then the FrameArray to see what exactly is going on..)


..and one recommendation :
capx> http://s000.tinyupload.com/index.php?fi ... 7209151524
Image
B
63
S
23
G
7
Posts: 1,479
Reputation: 10,794

Post » Mon May 11, 2015 5:09 pm

@korbaach
thank you very much for all the efforts, I have a clearer understanding of using Construct2 with some aspects I never thought before. This means a lot to me..
B
4
Posts: 9
Reputation: 232


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests