Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: HIman on November 21, 2005, 11:58:45 AM

Title: Stars of the background
Post by: HIman on November 21, 2005, 11:58:45 AM
 All greetings!
I try to make running up stars, from the center to edges of the screen.
Also there were some questions:
1. How to place sprite stars in a starting position after she has reached edge of the screen?
2. Why twitching moving of stars, though FPS = 100 is appreciable?

The script of a star is resulted below:
Code: [Select]
#include "scripts\base.inc"

//this script moves the stars of the background of the menu

//start on center
self.X = 1024/2;
self.Y = 768/2;

//ramdom movement direction
var a = Random(0,359);
var incX = sin(a);
var incY = cos(a);

while(true)
{
//move the sprite
self.Y = self.Y + incY*4;
self.X = self.X + incX*4;

Sleep(20);
}

Can eat easier with the decision?
Title: Re: Stars of the background
Post by: McCoy on November 21, 2005, 07:51:29 PM
Point 1 is easy:

Code: [Select]
If (self.X > 1024 || self.X < 0 || self.Y > 768 || self.Y < 0){
//start on center
self.X = 1024/2;
self.Y = 768/2;

//ramdom movement direction
var a = Random(0,359);
var incX = sin(a);
var incY = cos(a);
}


I don't know if that's how IFs with ORs were done in WME, I've not coded in quite long time. But you get the idea.
Title: Re: Stars of the background
Post by: HIman on November 21, 2005, 10:40:40 PM
Well, it I also wanted to see thanks...
All works wonderfully.
Title: Re: Stars of the background
Post by: Jerrot on November 22, 2005, 11:15:35 AM
Well, it I also wanted to see thanks...
All works wonderfully.

Did I miss something or shouldn't it be Math.sin() and Math.cos()?  :-X
Title: Re: Stars of the background
Post by: HIman on November 22, 2005, 11:55:31 AM

Did I miss something or shouldn't it be Math.sin() and Math.cos()?  :-X
[/quote]

Certainly  :)