How do I Make A "Box"

0 favourites
  • 6 posts
  • Hey guys,

    I'm trying to make a word game for my Son to help him with his spelling.

    I have 4-5 letters to choose from and I have the length of the word as a (visually) empty box for the letters.

    Think of it like Scrabble a little bit; One letter per square.

    Logically (in pseudo code) I can:

    If box1 == empty {
      put letter in this box
    } else if box2 == empty {
     put letter in this box
    } else if box3 == empty {
     but letter in this box
    }
    
    if box1 box2 box3 == full && correct == false {
      reset the letters
    }[/code:23bkjbk7]
    
    But I don't know the best way to do this using Construct 2.
    
    Am I best off using containers, or arrays, or maybe variables?
    
    Thanks!
  • I have managed to do the following logic:

    Global Variables:

    Empty_Box_1

    Empty_Box_2

    Empty_Box_3

    Letters:

    Letter_E_Small

    Letter_D_Small

    Letter_R_Small

    Letter_A_Small

    Letter_M_Small

    [Letter_R_Small Group]

    To move the letter R to Empty_Box_1:

    If Empty_Box_1 = 0 > Set Position to XXX, YYY > Set Empty_Box_1 to 1

    To remove the letter R from Empty_Box_1:

    If Empty_Box_1 = 1 and Letter_R_Small.X = XXX and Letter_R_Small.Y = Empty_Box_1.X and Empty_Box_1.Y >

    Letter_R_Small set Position back to original XXX, YYY and set Empty_Box_1 to 0.

    This is just one letter, one box. Is there a better way I can do this for all 26 letters across variable sized Empty_Box_x's depending on the word length?

    It'll take forever to do it this way I think, surely there's a more dynamic and less 'code' way of doing it?

    Edit: Image

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Im going to assume drag and drop letters onto boxes.

    Letter on collision with box

    ->box compare instance variable "filled"=0

    -->letter set drag and drop to disabled

    -->letter set position to box

    -->box set variable "filled" to 1

    This assumes letters and boxes are instances from two separate objects.

    Letter frame 0 = A, 1 = B, etc

  • Im going to assume drag and drop letters onto boxes.

    Letter on collision with box

    ->box compare instance variable "filled"=0

    -->letter set drag and drop to disabled

    -->letter set position to box

    -->box set variable "filled" to 1

    This assumes letters and boxes are instances from two separate objects.

    Letter frame 0 = A, 1 = B, etc

    Hi Newt, thank you for replying to me.

    I'm not sure what the frame is that you're referring to but I'll assume that's right? I created a new sprite object for each letter and gave them the name Letter_R_Small etc.

    As for the selection, it's click based at the moment but I'll ultimately want it touch based since i'm gonna put it on my phone for my Son to use.

    On Object Click > Letter_R_Small, move to Pos xxx, yyy, and so on.

  • Im not saying you can't make 24 objects to make the alphabet, but I will say you should do a forum search on how instances work.

    That with instance variables and how a Sprites animation frames can be used with them.

  • Im not saying you can't make 24 objects to make the alphabet, but I will say you should do a forum search on how instances work.

    That with instance variables and how a Sprites animation frames can be used with them.

    Ahh Right, I see what you mean now (I think).

    1 Object - 26 frames to make up the alphabet.

    Could that be called dynamically, for instance:

    On Load: Letters.0 (R) Letters.1 (E) Letters.2 (D) Letters.Random (Z) Letters.Random (F) and so on?

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