0 Favourites

compare only 4objects among 5objects

  • 1) I'm trying to make a tetris-like game with maths number, same numbers a row and you'll get score. So now I have 5 blocks (Sprites) which have values, and I want to know how to compare any 4 blocks with same numbers and score will be given?

    example:|2| |2| |2| |2| |5| and I can get score.

    2) How to make an universal number (let say a number 0) that will make the system recognizes that 0 is same value as the other 3blocks? So that |2| |2| |0| |2| |5| I can get score.

  • sorry construct 2 isn't with me right now so i cannot try to make exact conditions or actions but i may help with an algorthm

    set compareValue = -1

    set counter = 0

    *********loop for each row of sprites ************

    pick sprite

    **compare if sprites value equal to compare value OR spires value is "0"**

    counter = counter +1

    **else**

    set compare value = picked sprites value

    set counter= 1

    ** end if **

    ********* end loop ************

    if counter >=4 add xxx to players score

    set counter = 0

    compare value is set to -1 so we gaurantee that first pick will always false

    if you going to destroy the objects after achieving a score make their isntance variable like toBeDestroyed=true if conditions are met. if not, pick all reset the variables and continue like:

    *********loop for each row of sprites ************

    pick sprite

    set sprites toBeDestroyed = true

    **compare if sprites value equal to compare value OR spires value is "0"**

    counter = counter +1

    **else**

    set compare value = picked sprites value

    set counter= 0

    pick all sprites, and make toBeDestroyed= false

    ** end if **

    ********* end loop ************

    if counter >=4 add xxx to players score

    set counter = 0

    pick all sprites if toBeDestroyed =true then destroy.

    i hope u understood what i ment. sorry for such stupid coding

  • I understand what you're trying to teach me, but I just don't know the way that I should put in the Events condition and action, but I'll try to figure it out. Thanks anyway

  • sorry construct 2 isn't with me right now so i cannot try to make exact conditions or actions but i may help with an algorthm

    set compareValue = -1

    set counter = 0

    *********loop for each row of sprites ************

    pick sprite

    **compare if sprites value equal to compare value OR spires value is "0"**

    counter = counter +1

    **else**

    set compare value = picked sprites value

    set counter= 1

    ** end if **

    ********* end loop ************

    if counter >=4 add xxx to players score

    set counter = 0

    How do I compare sprites value equal to OR sprites value is 0? I'm not sure how does the & and | works in the condition.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • How do I compare sprites value equal to OR sprites value is 0? I'm not sure how does the & and | works in the condition.

    as i remember

    when creating a condition select your sprite-> compare instance variable

    Also to understand how to do loops within same kind of sprites look at "pin chain style" example on construct 2

    its in the examples folder where construct 2 is located (propably at program files -> construct 2)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Comparing Frames
27 1,314
jance0405's avatar
jance0405
Topic
22 404
mattshallow's avatar
mattshallow
Topic
22 1,502
oosyrag's avatar
oosyrag