Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Three sprites collide then a action happens.

Author
Message
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 27th Jun 2020 04:27 Edited at: 27th Jun 2020 04:36
So after joining many different Sprites in groups, and figuring out how to switch them and it looks good. I can't figure out how to join them as a group in a collision. So if only that group of sprites touch, then a action can happen like deleting just those sprites. Please let me know. Thanks.

Think of match three games.

I've tried many things. There needs to be a

group sprite collision

And add as many groups to that function.

The author of this post has marked a post as an answer.

Go to answer

fubarpk
Retired Moderator
15
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 27th Jun 2020 05:27 Edited at: 27th Jun 2020 05:33
https://www.appgamekit.com/documentation/Reference/Sprite/GetSpriteHitGroup.htm
Returns the ID of the first sprite found under the point x,y in world coordinates

there is no function that returns if a specific group has collision only one that returns an individual sprite from a group
which is pretty much the same thing

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 27th Jun 2020 06:44
Well that means all this work for nothing lol.

All jokes aside I believe that I can say something like

Group1=getspritegrouphit

So on and so forth.

Would be nice to have Sprite group collision checks.
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 27th Jun 2020 06:50
For a match 3 game I think you might be going about this the wrong way.
I wouldn't bother with collisions at all!

Store the contents of each 'cell' of the game board in a 2D array and then simply check the contents for a group of three.
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 27th Jun 2020 07:03
That's a great idea,, I already have a array set up for each block position. But all the sprites have to match . I have all the same sprites in the same group.

But that puts me on the right track.

Thank you
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 28th Jun 2020 05:14 Edited at: 28th Jun 2020 05:15
Ok I tried everything with no real results.

I can delete all sprite groups, but not if there besides each other. There is no real way to check to see if three of the same sprites from only the same group are together.

I'm so lost in this. I'm not giving up .

I would post code but am on my phone till the third. Till I can pay my internet bill.
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Jun 2020 08:15
So, your still sticking with SpriteGroups and collisions eh?
I think you'd have a lot more luck if you tried my suggestion.
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 28th Jun 2020 08:36
Even when I did , and I did. still have to check to see if all same sprites that match are together. So It is the same problem. Here's the problem.

I have 66 different sprites all loaded and positioning different so they can be mixed up.

All different sprite numbers.

Even the same images are different numbers.

So to match them as pairs I have to figure out how to find out each pairs sprite numbers.

So image 3 has many different Sprite numbers.

Or perhaps there's a good way to get all the sprite numbers for each image?

I'm lost.
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Jun 2020 08:55 Edited at: 28th Jun 2020 09:16
Here's a very quick example of match3 that I've just knocked together.
The number represents the start of a matching column or row.


Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 28th Jun 2020 09:02
Very well done, let me play with your code here a bit and I'll do my best to incorporate what I need.im still using physics but will only use them when needed.

Thank you for all your help.
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Jun 2020 05:22 Edited at: 29th Jun 2020 05:27
Hi

Ok I took your code and ran it.

I added 10 animated sprites changing create sprite 0 to create sprite random2(1,10)

The program still runs but only counts each color as a match and not the images. So if each sprite is colored red then it gets 3 or more matches. The colors match but the images are not matching.

Also the images are not randomizing for each spacekey hit. Hit, just the colors. So I tried to change this to my images with no results.

It's a great start besides.
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Jun 2020 06:21 Edited at: 29th Jun 2020 06:43
This post has been marked by the post author as the answer.
I have a good idea of what you're doing wrong but if you show your code it would be a lot easier to point it out.

[Edit]I found some free match 3 media, so here is an example with images:

Attachments

Login to view attachments
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Jun 2020 07:10
Thank you so much for your help, I had everything perfect but with no matches let l. I wish I could do something to show my appreciation.
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Jun 2020 23:09 Edited at: 30th Jun 2020 03:41
Ok so I incorporated my code with the example and here is what happens.

When I move the sprites together I get wrong matches. But if I update the sprite images after a move it sort of works in a bad way.

For some reason the only way I can get correct matches is when all the sprites are randomly Updated to new images.

But even after that the update is wrong.

So It only updates the correct matches if no sprites was moved manually. So I think the same sprite numbers can't be moved out of order. So I can't move sprites around .

Sorry I'm still on my phone till the third.
Game_Code_here
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 30th Jun 2020 07:51
Ok after looking at other examples I see that I have to switch images from the position I'm moving to.

My game works now.

Login to post a reply

Server time is: 2020-07-04 15:30:20
Your offset time is: 2020-07-04 15:30:20