compare only 4objects among 5objects

Get help using Construct 2

Post » Sun Apr 27, 2014 6:53 am

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.
B
5
Posts: 35
Reputation: 331

Post » Sun Apr 27, 2014 11:37 am

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 :P
Truth shall be your freedom...
B
14
S
2
G
1
Posts: 45
Reputation: 930

Post » Sun Apr 27, 2014 1:10 pm

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
B
5
Posts: 35
Reputation: 331

Post » Sun Apr 27, 2014 1:14 pm

Aleq wrote: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.
B
5
Posts: 35
Reputation: 331

Post » Sun Apr 27, 2014 1:20 pm

What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Sun Apr 27, 2014 6:54 pm

Serge Low wrote: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)
Truth shall be your freedom...
B
14
S
2
G
1
Posts: 45
Reputation: 930


Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, kiki4construct and 31 guests