I need help with puzzle concept please

Non-platform specific questions.

I need help with puzzle concept please

Postby krenisis » Fri May 07, 2010 2:49 am

1)Ok i want to make a puzzle game where when 4 same colors collide then they dissapear. what command do i use so that when 4 same colors collide then they disappear.
2)I also would like to know how to make objects when they collide stick together.
3)I wOuld like to know how I can make it so when an object is comming down on the screen I can control it while its on the way down but when it collides with another charactor you cannot control it anymore similar to tetris.
4) Lastly I would like to know how to make random color pieces come down like 1st one blue 2nd yellow but in random order.
Thanks alot guys!!
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: I need help with puzzle concept please

Postby Thanx » Fri May 07, 2010 5:50 pm

To make them stick together: on collision: changeparent of one to the other... to "collision actor"...
Random color pieces are: oncreation changeanimation on event actor, to GetAnimname => round(rand(animnum))
If that doesn't behave well, because it gets double values rather than integers, then in front of round: write this (int), that is cast the variable to an integer, which is safe in this case because we know the double is definitely an integer, and it is not negative.
Also if you want it to be controllable no more after colliding with that specific actor? Oncollision with that actor: EventDisable KEYDOWN or I don't know what the exact code is for pressing keydown... But that way it doesn't register on it, unless you do the EventEnable on it.

For the very first task, I suggest you have a variable for each clone (so create an array of integers)
and oncollision check whether the other actor's animname is the same, and if so, increment the actor's value (actually for both). On collision should decrement those array values, and also in the collision event should go a code, that if the value equals 4, then delete the actor, and change its variable to 0. That should delete all 4 in their collision.

Hope that works, and helps! :wink: :)
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score

Re: I need help with puzzle concept please

Postby DST » Fri May 07, 2010 10:03 pm

I think what you're wanting to do requires you to have a good understanding of variables and arrays.

When you stick four jewels together, what is the x and y you refer to to call the entire group? Technically, the only xy that can be applied in some way to all of them equally is dead center of the group. But what does that xy belong to? And how is it monitored and changed if the group changes size/shape?

If you choose one to become a parent, and the rest to become children, which one becomes the parent? How to you turn parenting on/off if that jewel becomes ungrouped and then grouped again?

If two like gems are to collide and destroy each other, its a simple destroy event actor and then destroy collide actor. But if there are three of them in a row, and the first one destroys itself and the second one, who is left to collide with and destroy the third one?

Tell me how you would answer these questions. The how is the easy part. There are several ways to do each of these things.

The question you have to answer is WHAT is it exactly that you want to do? What will your game do, and what won't it do?

How big can a group of jewels get? Can you move a group by clicking on one of them? Can the group change shape or lose members from gems beneath them being scored and destroyed? Do they group in midair where you control them, or only on the ground? Do they score by touching, or is there a separate event that triggers their destruction? (in tetris, completing a line was a separate event). Do they align in a square matrix like Tetris, a circular matrix like Dragonstone, or in a hexagonal matrix like Fractal?

Hope this helps.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: I need help with puzzle concept please

Postby krenisis » Sat May 08, 2010 4:50 pm

Ok basically i want 4 color balls when 4 are lined up they all get destroyed . when they are dropping i want them to follow the mouse downward but when they collide the follow mouse command ends.
Tutorial Database for all beginners click this link
viewtopic.php?f=4&t=8680
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: I need help with puzzle concept please

Postby DST » Sat May 08, 2010 6:56 pm

Okay, so lets say for this example, that you have a playfield of 10 x 25 squares. That's 10 squares across, and 25 from top to bottom.

So a piece starts at the top, with the "follow mouse" command enabled (on createactor).
Then, on collision with another piece, change follow mouse to NONE_AXIS, and enable gravity and physical response on the piece. If you want it to stay in the column it was dropped in, make its x snap to the column x. Otherwise, let the piece physical response off the other ones until it stops moving, and snap it into the closest slot.

Then the piece reports itself to the array, an array of 5 dimensions. [250][5]. the 250 is the position in the array, and the five slots are 1. piece there or not, 2. x 3.y, 4. color of piece, 5. cloneindex of piece. Note that the xy slots are filled in at game start.

Then, when its finished moving, and its snapped into place, you run an array check. You wipe slots 1, 4, and 5 from every position in the array, and ask the pieces to fill in their data.

Then you simply run checks horizontally, vertically, (and diagonally if you wish), looking for 4 or more of the same color.
When found, you record all the slot[5]'s, run an Actor* loop to destroy each of those pieces. Or if you like, you can send a timer to the pieces, and have each of them check their cloneindex against your scored list, and destroy themselves. Then the pieces with holes under them fall, snap into their slots, and when they finish, you run another check. You keep doing this until every time a piece has locked into place.

None of this affects the piece being dropped....when a piece is let go, the timer starts for the next piece drop, whether more score checks are needed or not.

so lets say you drop a piece into slot 100 (in a 32 x 32 piece size). The x and y for this are 16, 346. (we snap the center of 32), and this is in the array from the start of the game. So we say, as the piece is falling,

int aa=round(x/32);
int bb=round(y/32);
int cc=aa+(bb*10); //cc is the slot that the jewel is closest to.

if(jewels[cc+10][0]==1{ //if there is a piece under this one (meaning it's landed finally)
if(abs(x-jewels[cc][1]<10 && abs(y-jewels[cc][2]<10){ //if the piece is within 10 pixels of slot center
x=jewels[cc][1];
y=jewels[cc][2]; //snap the jewel to the center of the slot.
}
}

Does this make sense?
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: I need help with puzzle concept please

Postby krenisis » Sun May 09, 2010 8:28 am

Ok Iam working on it , its a little tough because the games i have made are simpiler than this one. But i must learn how to make puzzle games,because mobile gamers seem to like them most.Thanks alot DST!
Tutorial Database for all beginners click this link
viewtopic.php?f=4&t=8680
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest