Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: A more elegant way to make a nice sky  (Read 3087 times)

0 Members and 1 Guest are viewing this topic.

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
A more elegant way to make a nice sky
« on: August 23, 2006, 05:29:20 PM »

Hi there we created a little script to create a moving sky. Unfortunately it was a bit to fast, so we slowed our sky down.
The result is that it is slower now, but it lags, when decreasing the sleep value lesser than 100.

/////////////////////////////////// Himmel ///////////////////////////////////////////
var SomeEntity;
SomeEntity  = Scene.GetNode("himmel");
SomeEntity.SkipTo(-256,-3);

Game.Msg(SomeEntity.Visible);
while (true)
{var himmel;
   for(var i=-256; i < 256; i=i+1)
   {
      SomeEntity.SkipTo(i,-3);
      Sleep(100);
      if( i == 256) { i = -256;}
   }
}

Is there a more elegant way to solve that?

Thanks for upcoming help.

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: A more elegant way to make a nice sky
« Reply #1 on: August 23, 2006, 06:23:10 PM »

this is some dirty coding. I presume it's taken from some larger script?

Here's simplified version:

Code: [Select]

var Himmel  = Scene.GetNode("himmel");
Himmel.SkipTo(-256,-3);

while (true)
{
   for(var i=-256; i < 256; i=i+1)
   {
      Himmel.X = i;
      Sleep(100);
   }
}


It's usually good idea to name variables according to their purpose in the scripts. It will get less messy. Also note that by eliminating
surplus lines, the actual loop is only 3 lines of code.

Again I have no clue what do you mean by lag? Please for all future references, try to be as exact as possible. My opinion for moving sky to look good is to use theora video entity though.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: A more elegant way to make a nice sky
« Reply #2 on: August 23, 2006, 07:21:20 PM »

Hm... lag was the best word I could find. Erm... it does not run fluently, it stops for milliseconds, it seems so.

adonf

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
    • View Profile
Re: A more elegant way to make a nice sky
« Reply #3 on: August 24, 2006, 10:12:05 AM »

i guess the problem is that Sleep(100) doesn't guarantee the script will resume after 100 ms. the actual time may be more, so you need to check how much time has actually passed and update the position accordingly.

but i agree with metamorphium, a video will look better because the offset on a given frame doesn't have to be an integer number of pixels. this is especially important if the animation is slow.

if playing a video is not an option you could also try using an animated sprite, this way you won't have as many timing problems as you might get in script (and you can use several images to achieve movements of less than 1 pixel :D )
Logged
I am the Milkman. My milk is good.

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: A more elegant way to make a nice sky
« Reply #4 on: August 24, 2006, 10:29:59 AM »

Ok, thank you for the info, if there is no better way, we have to use that one.
 

Page created in 0.027 seconds with 20 queries.