Programming a "sand game"

For questions about using Classic.

Post » Sun Aug 01, 2010 3:51 pm

Hello, this is my first post on this forum, but I have been watching it for some time. I started programming a "sand game", something like http://dan-ball.jp/en/javagame/dust/

Now I used a 3x3 px objects for various elements, with "physics" behavior, and in the events sheet I shaped various interactions between them, or some unique properties (like fire floating instead of falling down). It all works fine until I get a few dozens of particles on the layout, then it starts to freeze and/or crash, which is only to be expected. Seems I'll need to approach that problem at a different angle, and this is the moment when I ask for your help. How do you think I can solve that problem?
B
1
G
2
Posts: 8
Reputation: 641

Post » Sun Aug 01, 2010 6:33 pm

Might try the custom movement behavior with speed set to bottom, and bounce, or push out, off "solid".
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sun Aug 01, 2010 7:43 pm

Hey, thats great idea, i dont think anyone did that in construct before You. Actually I'm thinking about something like that for a while. I would Suggest that You shouldnt use physics behaviour for particles. It uses too much of computing power, and often is obsolete because You want to simulate very basic and small particles. Personally i think that in this case white 1X1 pixel sprite will be best, and its physical properties should be coded by You. I might do a quick sketch when i got time.
B
5
S
1
G
2
Posts: 70
Reputation: 1,140

Post » Mon Aug 02, 2010 1:14 am

Actually I think Quanzi has made a falling sand game. Here's the link to the topic, but the link to the file seems to be broken. [url:xr78vxta]http://www.scirra.com/forum/viewtopic.php?f=16&t=1639&p=11505&hilit=falling+sand#p11505[/url:xr78vxta]

I recommend using the image manipulator object to manipulate the pixels themselves instead of a object per pixel. It should allow the frame rate to be somewhat constant as the number of particles increase instead of becoming progressively lower. I got it working but found the frame rate wasn't to great on my low end machine.

Here's a good resource about making falling sand games:
[url:xr78vxta]http://fallingsandgame.com/viewforum.php?f=13&sid=87b24cee4be9f238e27bff5a6a48c240[/url:xr78vxta]

Here's a game made in construct where the physics route was taken:
[url:xr78vxta]http://www.fun-motion.com/forums/showthread.php?t=3135&highlight=lafesim[/url:xr78vxta]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Aug 02, 2010 11:58 am

Could You post .cap file for this?
B
5
S
1
G
2
Posts: 70
Reputation: 1,140

Post » Mon Aug 02, 2010 3:15 pm

Here's what I've got so far:
[url:2chxqxld]http://dl.dropbox.com/u/5426011/examples/sand2.cap[/url:2chxqxld]

I've added a few more features since I've uploaded that but the file is on my other computer.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue Aug 03, 2010 9:52 am

Thats wonderfull work! But actally it isnt clear how do You manage to get collisions, i've never worked before with arrays. And how about reactions with different particles? Can it be done using Your method?
B
5
S
1
G
2
Posts: 70
Reputation: 1,140

Post » Tue Aug 03, 2010 10:34 am

I used black (or 0) to be empty and every other color is a particle. Collisions are done by before moving a particle, check the destination. If the destination is empty, then move the particle. Else if the destination has another particle in it, then you have a collision and the particle isn't moved and you can define some reaction at that point.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue Aug 03, 2010 10:43 am

[quote="R0J0hound":3bilv401]Here's what I've got so far:
[url:3bilv401]http://dl.dropbox.com/u/5426011/examples/sand2.cap[/url:3bilv401]

I've added a few more features since I've uploaded that but the file is on my other computer.[/quote:3bilv401]

Wow, it's really creative. I see and understand how you did that, but what will happen when we want to add some interactions? This would probably require checking neighbors of every field in the array and would probably be very cpu-heavy.
B
1
G
2
Posts: 8
Reputation: 641

Post » Mon Aug 09, 2010 12:00 pm

Im still litlle confused on the methods You used with this example, may I ask You to make super simple version of Your work containing one type of particles? When I openend all branches of event sheet my brain flattened.
B
5
S
1
G
2
Posts: 70
Reputation: 1,140

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests