Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Stars of the background  (Read 2659 times)

0 Members and 1 Guest are viewing this topic.

HIman

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 24
  • Russian adventure !
    • View Profile
    • Home WEB by QSP
Stars of the background
« 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?
Logged

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re: Stars of the background
« Reply #1 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.
Logged

Click here to sign my sig!

HIman

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 24
  • Russian adventure !
    • View Profile
    • Home WEB by QSP
Re: Stars of the background
« Reply #2 on: November 21, 2005, 10:40:40 PM »

Well, it I also wanted to see thanks...
All works wonderfully.
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: Stars of the background
« Reply #3 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
Logged
Mooh!

HIman

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 24
  • Russian adventure !
    • View Profile
    • Home WEB by QSP
Re: Stars of the background
« Reply #4 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  :)
Logged
 

Page created in 0.024 seconds with 19 queries.