Page 2 of 4

Re: Screensaver

PostPosted: Sat Oct 15, 2011 8:22 pm
by tintran
change canvas->Create Actor->Script to
Code: Select all
int loop;
init();
for (loop=0;loop<LINES;loop++)  run();

Re: Screensaver

PostPosted: Sat Oct 15, 2011 8:56 pm
by EvanBlack
cool, also instead of using DrawActor event for run(). It would probably be better to switch it to a timer, but there is a noticable pause as the screen saver starts but it stops run from being called more then it has too. Also allows for the lines to scroll smoother and not slow down at certain parts. This is probably dependant of computer, the FPS drop.

Re: Screensaver

PostPosted: Sat Oct 15, 2011 11:56 pm
by Game A Gogo
cos, and sin returns values from -1 to 1, so if I add 1 to it, it will give me a value from 0 to 2.
now the multipliers are there so that over time, the lines won't be always the same color!

Re: Screensaver

PostPosted: Sun Oct 16, 2011 1:21 am
by tintran
also if you increment variable tick by 5 or 6 or even 10, you get some really nice gradients.

Re: Screensaver

PostPosted: Sun Oct 16, 2011 6:50 pm
by tintran
star field
Code: Select all
#define STARS 1000
#define MAXDEPTH 50
#define SPEED .5
float X[STARS],Y[STARS],Z[STARS],OZ[STARS];
int i;
double midx,midy;
void init()
{
  midx = 1.0*view.width/2;
  midy = 1.0*view.height/2;
  for (i=0;i<STARS;i++)
  {
      X[i] = rand(view.width*MAXDEPTH)-view.width*MAXDEPTH/2;
      Y[i] = rand(view.height*MAXDEPTH)-view.height*MAXDEPTH/2;
      Z[i] = rand(MAXDEPTH)+1;
      OZ[i] = Z[i];
  }
}

void run()
{
 
  for (i=0;i<STARS;i++)
  {
      OZ[i] = Z[i];
      Z[i]-=SPEED;
      if (Z[i]<=0) Z[i] = MAXDEPTH;
  }
 
  for (i=0;i<STARS;i++)
  {
    //erase stars
    setpen(0,0,0,0,1);
    moveto(midx + X[i]/OZ[i],        midy + Y[i]/OZ[i]);
    lineto(midx + X[i]/(OZ[i]+SPEED),midy + Y[i]/(OZ[i]+SPEED));
 
    //draw stars
    setpen(255-Z[i]*5,255-Z[i]*5,255-Z[i]*5,0,1);
    moveto(midx + X[i]/Z[i],        midy + Y[i]/Z[i]);
    lineto(midx + X[i]/(Z[i]+SPEED),midy + Y[i]/(Z[i]+SPEED));
  }
 
}

Re: Screensaver

PostPosted: Mon Oct 17, 2011 12:50 am
by Jagmaster
:shock: Awesome!

Re: Screensaver

PostPosted: Mon Oct 17, 2011 1:43 am
by jimmynewguy
Trintran, these look sweet. But your run for the starfield would be faster with this.

Code: Select all
void run()
{
   erase(0, 0, 0, 1);
  for (i=0;i<STARS;i++)
  {
      OZ[i] = Z[i];
      Z[i]-=SPEED;
      if (Z[i]<=0) Z[i] = MAXDEPTH;
  }

  for (i=0;i<STARS;i++)
  {
    //draw stars
    setpen(255-Z[i]*5,255-Z[i]*5,255-Z[i]*5,0,1);
    moveto(midx + X[i]/Z[i],        midy + Y[i]/Z[i]);
    lineto(midx + X[i]/(Z[i]+SPEED),midy + Y[i]/(Z[i]+SPEED));
  }
}

Re: Screensaver

PostPosted: Mon Oct 17, 2011 6:51 pm
by tintran
nice, it means i can get rid of OZ as well. :)

Re: Screensaver

PostPosted: Wed Oct 19, 2011 10:40 pm
by 157pl
wow thanks i have made multiple things i wished i could use as screen savers but i never thought i could :shock:

Re: Screensaver

PostPosted: Thu Oct 20, 2011 1:20 am
by 157pl
i made a fiew
the clock uses Hblade's 24 hr clock code :D

Re: Screensaver

PostPosted: Sat Oct 22, 2011 5:31 pm
by 157pl
we should put this file extension under the export tab thing so people will know you can do it

Re: Screensaver

PostPosted: Sun Dec 04, 2011 12:31 am
by tintran
bezier curve screen saver :)

Re: Screensaver

PostPosted: Sun Dec 04, 2011 1:54 am
by SuperSonic
Dude, that's awsome :D

Re: Screensaver

PostPosted: Sun Dec 04, 2011 10:18 pm
by tintran
8 beziers :D

Re: Screensaver

PostPosted: Mon Dec 05, 2011 12:21 am
by tintran
A higher order bezier curve (4th order, defined by 5 points).
(and a 6th order bezier, defined by 7 points)