Sand Physics

Game Editor comments and discussion.

Sand Physics

Postby jimmynewguy » Sun Oct 23, 2011 11:56 pm

Found a nifty little thing about sand particles and decided to test it in GE. Fast for a few particles then drops the frame rate. Don't know why I always mess with stuff like this and water, wayyyy too many actors will get on the screen. Pretty cool to watch in action though! (looks coolest at 60fps) :)
Code: Select all
int left  = (getactor(x-1, y+1)->cloneindex != -1);
int under = (getactor(x, y+1)->cloneindex != -1);
int right = (getactor(x+1, y+1)->cloneindex != -1);
int bitfield = (left | (under << 1) | (right << 2));
int dir = rand(1);

switch(bitfield)
{
case 0: // ___
case 1: // x__
case 4: // __x
case 5: // x_x
y++;
break;

case 3: // xx_
y++;
x++;
break;

case 6: // _xx
y++;
x--;
break;

case 2: // _x_
y++;
x += ((dir << 1) - 1); // 'randomly' go right or left
break;
}
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Sand Physics

Postby lcl » Mon Oct 24, 2011 12:12 am

Could you send an example ged? :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Sand Physics

Postby jimmynewguy » Mon Oct 24, 2011 1:33 am

Yes. :)
Attachments
Sand.zip
(2.18 KiB) Downloaded 87 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest