3 in a row

For questions about using Classic.

Post » Sun Feb 22, 2009 8:23 pm

hi,

I have no idea how to solve the following after searching the wiki and a search on "3 in a row" on this forum:

I would like to detect 3 (or more) in a row, with a falling-blocks game.

How the game looks likes/works:
- 1 type of square blocks fall down (like tetris), creating different instances from 1 sprite object.
- they detect the ground and eachother by using "collision".
- after collision blocks stack up.
- if they are next to eachother, I would like them to detect if it is 3 in a row, only horizontal.
- I didn't use the grid-option.
- blocks fall down from a chosen x-point at the top of the screen.

I have tried "compare x-value", but perhaps I didn't do it correctly.
In what direction do you think I must look?

I think if only 1 sprite object can detect if another sprite object is next to it, I can continue.
Or perhaps if I know how to compare x-value of an instance of a sprite-object (instead of standard sprite object).

I've tried 1.5 hours only not to post this question in the forum and find it out myself, but I ended up with choosing between breaking my keyboard or posting this question.
I chose the first option.
Then posted the question.
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Sun Feb 22, 2009 8:30 pm

Don't be afraid to cheat a bit! Create a sprite, 1 pixel high and slightly less than three blocks wide, with hotspot in middle, then for each block place the sprite over the block at desired angle, then check if it overlaps three blocks.

+Sprite is overlapping Block
+CountMatching("Block")=3
>Gotcha
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Feb 22, 2009 8:36 pm

Thanks, I will try to see if I get that working.
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Tue Feb 24, 2009 5:42 pm

I can't get it working.

I am spawning the 1-pixel-horizontal-slightly-smaller-than-3-blocks-wide over (centered) the block, everytime the block gets created and falls down. (the 1-pixel-sprite follows the block, is attached to it, by an event)

I don't know what I should do with a hotspot.
I created 3 imageboxes, so that I could perhaps let it detect if the 3 Imageboxes were overlapped, but I could find no such option for imageboxes.
So I am currently not using Imageboxes.

It only detects: block overlaps the 1-pixel-sprite.
This happens every spawning, so that's useless.

A sollution would be: if the 1-pixel-sprite is completely overlapped from left x to right x: start action.
I wouldn't know how to do this.

(or if I could somehow ("pick closest-condition" perhaps?) let blocks detect if another object is near them, on the x-axis)

What do you think I am doing wrong, or in what direction should I look for?
B
16
S
5
G
7
Posts: 599
Reputation: 5,000


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests