Match3 logic [Need help]

Get help using Construct 2

Post » Thu Dec 26, 2013 10:26 am

the capx

I need help with the logic in match3-like game.

What I do: on touched the object I call 4 functions wich go in 4 dirrections (up, down , left , right) though array. every func check the value in array and if this value equal to choosen object - I spawn destroyer at this position, else - stop loop.

But it show terrible result. Hope on you, guys!
B
57
S
19
G
10
Posts: 191
Reputation: 9,636

Post » Thu Dec 26, 2013 1:20 pm

Hello!
I've tried to fix your capx, and here's what I came up to link.
I works a bit better.. a tiny bit:( Still needs fixing.
May be you'll find a way to make it run as intended:)
I'll keep trying too, and I'll let you know if I find a solution ^_^

UPD: Allright, I've tried another way and kinda got it running:) Example 1
So.. the answer is.. Tilemaps! :D God I love them.
In this particular case, using a single tilemap replaces both Array and Sprites
and saves us from some pain-in-the-butt with our code.
Well my example works pretty fine, I guess.
But! It now deletes only those tiles that are in the same row/col with the tile we click.
And I think we need to check if every tile we delete has 3matching tiles..
Sorry, hard to explain, I hope you get the idea:)
To do this, we need a simple recursion.. but seems it's not working :((( Or I'm just doing something wrong :P
Please let me know if you find how to fix it!JJList2013-12-27 02:54:47
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Thu Dec 26, 2013 2:55 pm

Oh, thanks ! I'm still trying.

Here I'm not start build the events from checking if we have 3 in a row or not.
But I don't understand why my logic doesn't work. It simple go from top to bottom and from side to side and check the same value. What's a thing I loose ?
B
57
S
19
G
10
Posts: 191
Reputation: 9,636

Post » Thu Dec 26, 2013 3:01 pm

[QUOTE=Kurz]
It simple go from top to bottom and from side to side and check the same value. What's a thing I loose ? [/QUOTE]
I guess..
In your "up" function, you had "for i from 0 to param()"
Where I made it "for i from param() to 0", so it starts counting from param() and decrements to 0. Same for "left" I guess that might be the problem)

P.S. Updated my first post with a fine working example:)JJList2013-12-26 15:01:50
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Thu Dec 26, 2013 3:11 pm

from 0 to param(1) in for loop just change the loopindex. In action I make (param(1) - loopindex) which the same what you mean
B
57
S
19
G
10
Posts: 191
Reputation: 9,636

Post » Thu Dec 26, 2013 8:16 pm

Here's a new version, getting closer.. Example 2
But it is still glitchy and overcomplicated:(
There must be an easier and more stable way! I feel it:P and I'll find it >:D

UPD: I guess I've fixed it :) Example 3
It still needs optimization, but at least it's working now)JJList2013-12-27 00:04:14
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Fri Dec 27, 2013 7:49 am

Oh, amazing) But I going to turn back to arrays. I loose smth and can't see some hiden little thing in my logic.
B
57
S
19
G
10
Posts: 191
Reputation: 9,636

Post » Fri Dec 27, 2013 8:06 am

Same here, after a couple of hours of brainfu[storm]ing I've figuired out that it shoud be easier to do with arrays
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Fri Dec 27, 2013 10:02 am

You really should either go with arrays or use rexrainbows set of plugins (which come with capx examples btw).
B
23
S
6
G
11
Posts: 1,047
Reputation: 8,065

Post » Fri Dec 27, 2013 10:25 am

@PixelRebirth I totally agree:)
It's just me, as a novice in C2 and general programming, always trying to "roll my own" solution instead of using examples:P
Sometimes useful, mostly- complete waste of time^^JJList2013-12-27 10:25:30
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Next

Return to How do I....?

Who is online

Users browsing this forum: max2612 and 25 guests