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 / Sprite + Particle Collision . Is it possible?

Author
Message
Adrian8891
8
Years of Service
User Offline
Joined: 9th Jul 2016
Location: Szczecin, Poland
Posted: 25th Jul 2016 18:43
Hey Guys!

Just as newbie, I have created part of code.

My idea is to get now collision between emited particles and sprite and add points to SCORE.

Current problem is with check such state of collision.
Is it even possible?


Or is there any other simple idea to get it?
What I'm creating is a rain (particles) dropping from cloud (sprite) that has to hit other sprite to get points.



I'm attaching of current screen of game (not so pretty ) and without last sprite so far...

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 25th Jul 2016 20:17 Edited at: 25th Jul 2016 20:20
ups
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 25th Jul 2016 20:19
not saw a list of particles, but here is my code from own particle emitter

some useful commands
GetSpriteInBox ( iSprite, x1, y1, x2, y2 )
GetSpriteInCircle ( iSprite, x1, y1, radius )

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Adrian8891
8
Years of Service
User Offline
Joined: 9th Jul 2016
Location: Szczecin, Poland
Posted: 25th Jul 2016 20:25
Here is my code for particles:

function particles()

LoadImage ( 1, "drop1.png" )


CreateParticles (1,200,200)
SetParticlesImage ( 1, 1 )


SetParticlesStartZone(1, -50, -50, 50, 50)


SetParticlesDirection ( 1, 0, 50.0 )


SetParticlesLife(1,2)
SetParticlesSize ( 1, 24)
SetParticlesAngle ( 1, 15 )
SetParticlesFrequency ( 1, 60 )
SetParticlesVelocityRange ( 1, 1, 4 )


AddParticlesColorKeyFrame ( 1, 0, 0, 100, 255, 0 )
AddParticlesColorKeyFrame ( 1, 0.5, 0, 100, 255, 255 )
AddParticlesColorKeyFrame ( 1, 8.0, 150, 50, 100, 255 )
AddParticlesColorKeyFrame ( 1, 9.0, 0, 0, 0, 0 )

endfunction
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 26th Jul 2016 03:12
Hey,

in order for your collision checks to work, the rain particles have to be sprites.
You can then either check them for collision by using collision commands, or by using distance calculations like Pythagoras.

L8er,
PSY

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Jul 2016 07:28
Or make a Feature Request that we get a Particle List from Emitter
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Adrian8891
8
Years of Service
User Offline
Joined: 9th Jul 2016
Location: Szczecin, Poland
Posted: 26th Jul 2016 10:25
so far my knowledge is too small to create few sprites and we are talking about hundrets of sprites

Where to add this idea to feature requests?
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 26th Jul 2016 13:01
Quote: "Or make a Feature Request that we get a Particle List from Emitter"


Correct me if I'm wrong but:

The AppGameKit integrated Particle System is pure Eye Candy.
It's not meant to be able to handle collisions or provide particle coordinates.

Ultra-fast systems like this use Single Surface techniques.
Only by using a single mesh you can have tons of particles move at insane fps


L8er,
PSY
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Jul 2016 17:50
@Adrian8891
i gave you an example for particle sprites. see above.
you just need a function with a sprite id and count if a particle is inside.
there exist a thread about feature.

@PSY
its painted so i guess paul can provide a position list.

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 26th Jul 2016 19:41
@Markus

Yeah, everything is 'painted', so you can provide 2D/3D positions for everything.
That's not the point.

The point is such a feature would slow down the particle system significantly, rendering it useless (too slow when handling huge amounts of particles) in the process...


Of course, Adrian could use a code like yours for his project. All he would need to do is add collisions (and some minor adjustments maybe)...

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Jul 2016 23:28
@PSY
it belongs the technique you are using for a "collision" test.
a public list of this particles do not affect anything until someone (the developer) make a big endless loop and the app did not continue.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Jul 2016 04:19
@Markus

I believe we are talking at cross purposes
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 27th Jul 2016 07:20
In my opinion, I would just create my own particle system so you can control every aspect of it, including adding collision detection. AGK's built in particle system is nice, but if you plan to create more complex apps and games I would take some time a develop your own system. It's super easy too, so get crackin!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Jul 2016 07:31
@PSY
me spoke about
Quote: "It's not meant to be able to handle collisions or provide particle coordinates.
The point is such a feature would slow down the particle system significantly,"
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Jul 2016 15:39 Edited at: 27th Jul 2016 15:41
@Markus

Yeah, but you still don't get what I mean. Let me explain it in another way:

1. The AppGameKit particle system is ultra-fast, most probably using a single-surface technique where all particles are integrated in a single mesh and the mesh is being drawn
2. Each particle most probably is a type which looks similar to this:


3. Each time UpdateParticles() is called, all particles are being updated. That means AppGameKit runs through EACH particle and calculates its new values like position, speed, colour etc...
4. So basically, YES, you could access each particle's coordinates (if Rick gave you access to the data)

BUT
You would then loop through EACH PARTICLE -->AGAIN<-- and evaluate its coordinates in order to check it for any collisions.

That would be pretty inefficient, wouldn't it?


So Adrian would be better off with writing his own particle system for his game (which would be checking for collisions WITHIN HIS OWN UpdateParticles() loop), making it much more effective (IN THIS SPECIAL CASE), because the Particle System that comes with AppGameKit is meant to be used for EYE CANDY.

AGK's PS is awesome, it's extremely fast, it has tons of parameters to configure and it makes your game look fantastic, but it's not a jack of all trades device. If you want custom stuff like collisions, use an own system.


Just my 2ct

You can burn me now, I'm hitting the swimming pool


(EDIT) Just saw you're from Germany. Just drop me a PM, it's much easier that way, my German is fluent
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jul 2016 08:48
@PSY
slow down at physics collision is often because collision test agains each other, thats not the case here.
its not necessary to loop through all each frame, also you can use regions or one rain drop can represent other around.
yes, i will write you a pm in my native language


AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Jul 2016 11:13
Why not use both the built in system, and your own?

If speed is important, and physically simulating every particle isn't ,required you could use use the built in system for the effect, and create your own system which creates a smaller number of 2d physics objects which have their own physics?
So for example, for every 3 AppGameKit particles, create 1 box2d particle.
Adrian8891
8
Years of Service
User Offline
Joined: 9th Jul 2016
Location: Szczecin, Poland
Posted: 3rd Aug 2016 00:00
Hello guys,

Sorry for late reply, but I just got married and I needed time to make it most beatiful day


Anyway, I'm newbie in AppGameKit, so code what You gave me its something like "black magic"... Screenshot that present my game required a lot of time from me to cover this game to this state!
Seems that I need to learn a looooooooot more than just LoadImage (CreateSprite) command
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Aug 2016 07:38
congratulation.

Quote: "so code what You gave me"

you just need to look the function names first, thats for building something, if you need details you can look inside a function.
about your rain cloud, maybe you can make it abstract, if under the cloud then player get wet , outside not, thats simular but i don't know if it fit your game idea.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Adrian8891
8
Years of Service
User Offline
Joined: 9th Jul 2016
Location: Szczecin, Poland
Posted: 3rd Aug 2016 10:21
Actually, iy fit my game idea. Maybe not about "wet player", but my idea is to get game where player control cloud(sprite) + rain(particles) and earn points for getting grass and flowers wet. They will grow when player reach X collision points (or make it by timer) etc etc. Nothing complicated, but for me a point without a reach

I will look closer at Your code, maybe someday I will understand
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Aug 2016 17:18
my particle code is very easy. u include this file #include "particles.agc"
the call once ParticleInit() to load two images as particle.
create a particle with ParticleNewStar or ParticleNewDot. that is the position,speed,count until is dissapear,
you call ParticleUpdate() (this moves all) where you call sync.
if your game end and will goto other menu call ParticleFreeAll() once, this will remove current particels at screen.

spr=CloudSprite
for p = 1 to 20
ParticleNewDot(getspritexbyoffset(spr)+RandomFloat(5.0),getspriteybyoffset(spr)+RandomFloat(5.0),RandomFloat(1)/10.0,RandomFloat(1)/10.0,random(1,30),random(60*2,60*4),index)
next
the index was used for a color table you can replace this
=Map[index].r
=Map[index].g
=Map[index].b
with white color or use also a array for rain drop colors.
this ParticleNewDot using colors , the ParticleNewStar using the original sprite color.

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-11-25 04:57:24
Your offset time is: 2024-11-25 04:57:24