Thousands of simple sprites with collision...possible?

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

Thousands of simple sprites with collision...possible?

Post by Sjatplat » Tue Apr 24, 2012 9:28 pm

Hi

Is it possible with the new graphics boost to make a LOT of sprites with collisions in livecode. I'm talking about small simple dots wich simulates a kind of sand wich you can move around...
thousands of them...

Is this possible or is it a rather unrealistic demand of livecode in its current state?
...you people with experience :)

Sjat

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Thousands of simple sprites with collision...possible?

Post by Mark » Wed Apr 25, 2012 3:40 pm

Hi,

Usually, I answer such questions with no, but maybe you should just give it a try and tell us about your experiences.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14184
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Thousands of simple sprites with collision...possible?

Post by Klaus » Wed Apr 25, 2012 4:02 pm

Hi Sjat,

please check the tutorials on this website:
http://www.tactilemedia.com/
Click "Software" and then "LiveCode tutorials..." in top right corner.

Maybe the stack "Swarm" (scroll down the page) might get you started.
The other stacks aren't that bad either 8)


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4168
Joined: Sun Jan 07, 2007 9:12 pm

Re: Thousands of simple sprites with collision...possible?

Post by bn » Wed Apr 25, 2012 6:03 pm

Hi Sjat,

could you give a little more background of what the simple sprites are supposed to represent and do?
Do you need collision testing? Or do you need random movement with a bias?

Is this for a desktop computer or a mobile device?

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4168
Joined: Sun Jan 07, 2007 9:12 pm

Re: Thousands of simple sprites with collision...possible?

Post by bn » Sun May 06, 2012 12:29 pm

Hi Sjat,

I made a stack that moves around simple dots. (triangles, 3x3 dots, etc). Up to about 2-3000 dots are possible with acceptable frame rate. Collision check, no interaction with mouse, see details in stack

or you might want to let a 16th note float around
Bildschirmfoto 2012-05-06 um 12.48.43.png
SandStackSjatplat_0.0.9.livecode.zip
(29.14 KiB) Downloaded 511 times
If you have questions feel free to ask.

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4168
Joined: Sun Jan 07, 2007 9:12 pm

Re: Thousands of simple sprites with collision...possible?

Post by bn » Fri May 11, 2012 12:21 pm

Hi Sjat,
here is a version of the stack that reacts to mouse movements in the animation. Markers move either towards the mouse or away from the mouse.
Collision testing still only tests for point of marker, not area of marker. When colliding the two markers get new random x,y velocities. I have to figure out a fast way to do area-collision for many points.

I also added a "SJAT" marker. :)
SandStackSjatplat_0.1.1.livecode.zip
(13.73 KiB) Downloaded 580 times
Kind regards
Bernd

Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

Re: Thousands of simple sprites with collision...possible?

Post by Sjatplat » Fri May 11, 2012 10:13 pm

Bernd!!!

I don't know what to say...this was worth a lot more than gratitudal words in a forum! Fantastic. I've been away and experimenting with agk(app game kit) for this task. But this really made me believe that this is doable in Livecode. With an acceptable framerate at around 1000 sprites I can do som tricks - like only checking the particles in a set radius around the mousepointer. I want to combine this with livecodes excellent string and field capabilites....and AGK is nowhere near livecode in that apartment...but has faster and better sprite support...

I will try to make something based on this and give feedback.

Again Bernd.....Fantastic help....Hope you got something out of this little experiment too - I Sure did - in spades!

THANKS

Sjat

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4168
Joined: Sun Jan 07, 2007 9:12 pm

Re: Thousands of simple sprites with collision...possible?

Post by bn » Sat May 12, 2012 10:55 pm

Hi Sjat,
Hope you got something out of this little experiment too
as you have found out Livecode is not very good at manipulating many sprites. But when you were asking for "sand" like simple forms I was intrigued and wanted to try out to make just one graphic that does all the "sand" sprites. Livecode is not bad at it and afterall one grain of sand looks like the other. :) So it would not be an obstacle that all "sprites" look the same. I was surprised how many of the "sand sprites" Livecode could handle.
So I did get something out ot this experiment. And it was fun to do it. It is at the same time a lot easier to just script one graphic object which on the other hand has it's restrictions.

I am interested in what you come up with.

Kind regards

Bernd

Post Reply