PDA

View Full Version : Match3 Engine



ironquark
24-01-2012, 07:43 PM
..............

User137
24-01-2012, 08:51 PM
I can't get it to crash at all, can you tell more detailed steps? Also, you are using generics which aren't supported in my old Delphi7 - so can't compile it :P

As for the pieces moving, you need a timer with small interval for it. There's hundred different ways, but this is 1:
- In the onMouseUp event set moving := true, and save vector := piece2.position - piece1.position, set delta: single to 0.
- In the onTimer, draw piece1 to piece1.position + vector*delta and piece2 to piece1.position + vector*(1-delta), then add delta by something like 0.05 per tick.
- When delta>=1, set pieces to final positions and stop animation.

ironquark
24-01-2012, 11:20 PM
I can't get it to crash at all, can you tell more detailed steps? Also, you are using generics which aren't supported in my old Delphi7 - so can't compile it :P

As for the pieces moving, you need a timer with small interval for it. There's hundred different ways, but this is 1:
- In the onMouseUp event set moving := true, and save vector := piece2.position - piece1.position, set delta: single to 0.
- In the onTimer, draw piece1 to piece1.position + vector*delta and piece2 to piece1.position + vector*(1-delta), then add delta by something like 0.05 per tick.
- When delta>=1, set pieces to final positions and stop animation.

press the right button of your mouse to put the blocks at the board:

http://img191.imageshack.us/img191/2305/crashbt.jpg (http://imageshack.us/photo/my-images/191/crashbt.jpg/)


Uploaded with ImageShack.us (http://imageshack.us)

and when you match pieces below the blocks it crashes...

I'm using Delphi 2010 instead Delphi 7

I've posted the code to see if somebody can help...

wagenheimer
25-01-2012, 04:28 AM
The "Crash" problem happens on the ApplyGravity function,

Swap(A, B);
Exit(True);

You have to do something to avoid it Swap pieces out of bounds, on some tests it tried to swap a piece on -1,4