View Single Post
  #333 (permalink)  
Old 12-20-2007, 06:40 PM
neilnapier neilnapier is offline
Senior Member
 
Join Date: Oct 2007
Posts: 147
Default

Here is microsand.

EDIT: oops wrong one.

Code:
#include <SDL/SDL.h> 
int main(int,char**){SDL_Surface*s=SDL_SetVideoMode(640,480,8,0);SDL_Event e; 
int r,u,x,y,a=-1,b,h=s->h,z=s->pitch,q[]={0,r=91,u=140,200};Uint8*o,*p=(Uint8*) 
s->pixels+z;SDL_WM_SetCaption("MicroSand 2 by Max Nagl",0);while(!SDL_Flip(s)) 
{for(x=0;++x<s->w;p[x-z]=p[(h-2)*z+x]=1);for(o=p+(h-2)*z;--o>p;){if(*o-200)if 
((*o>(b=*(o+z)))&&((r*=5)%((*o-b)/5+2)>5)){*(o+z)=*o;*o=b-1?b:0;}else if((b=*o) 
>*(o+(y=1))&&((r*=7)%97)>1||b>*(o+(y=a))){*o=*(o+y);*(o+y)=b-1?b:0;}}while( 
SDL_PollEvent(&e)){switch(e.type){case 2:u=q[e.key.keysym.sym%4];break;case 12: 
return 0;case 4:case 5:SDL_MouseMotionEvent m=e.motion;for(y=m.y-9;y++<m.y+9&& 
m.state;)for(x=m.x-9;x++<m.x+9;)if((x>a)*(x<s->w)*(y>a)*(y<h))p[y*z+x]=u;}}}}

Last edited by neilnapier : 12-20-2007 at 06:43 PM.
Reply With Quote