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

0 favourites
  • 9 posts
From the Asset Store
A complete Carrom Board artwork for making an awesome board game.
  • 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

  • You are asking us what your game should look like?

  • 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

  • scirra.com/forum/viewtopic.php

    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

  • Worst Game Ever 2 <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    (no rows and columns ..and startx...y)

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

    and no json <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • 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

  • 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

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

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

    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

  • 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..

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