Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Pages: 1 [2]  All

Author Topic: Script runs slowly when VSYNC is on  (Read 9280 times)

0 Members and 1 Guest are viewing this topic.

adonf

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
    • View Profile
Re: Script runs slowly when VSYNC is on
« Reply #15 on: April 18, 2006, 05:39:59 PM »

Quote from: Mnemonic
No, no, not at all. I must have confused you. The script only yields if you call one of the "blocking" methods (GoTo, Talk, TurnTo...), Sleep() or if you call a custom method which is defined in another script.

Well, exactly ! Originally I had two classes for my minigame: let's call them MiniGame and GameElement ; I only called the Update function for the MiniGame class once every 1/5 second from the level's script_init.script, but this function called a lot of methods on the GameElement objects. GameElements had their own script file and methods and so the main Update script would yield many, many times per iteration of the main loop.

I sorta solved this problem by removing the GameElement class and putting everything in functions in the same .script file as the Game class, but that's very poor code design. It works because it's a simple minigame but if I had to do something more complicated it would be hell to write and maintain...

Of course, WME is a point-and-click adventure game engine, not a tetris-like engine and minigames may not seem too important to you, but I believe that they add a lot to gameplay variety and they are definitely part of the genre: even Space Quest 1 had a landspeeder racing minigame (ok, it sucked but it exists ;) )


As a side note, I think that Entity.GetSprite and entity.SetSprite slow down the game a lot. It might or might not be related to the problem discussed above. Is there a way to prevent that ?

Logged
I am the Milkman. My milk is good.

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Script runs slowly when VSYNC is on
« Reply #16 on: April 18, 2006, 06:08:08 PM »

As a side note, I think that Entity.GetSprite and entity.SetSprite slow down the game a lot. It might or might not be related to the problem discussed above. Is there a way to prevent that ?
SetSprite can be slow if it's being called repeatedly because it loads the images from disk. You can prevent it by pre-caching the images (by assigning them to some bogus hidden entity or something like that).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

adonf

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
    • View Profile
Re: Script runs slowly when VSYNC is on
« Reply #17 on: April 19, 2006, 09:44:45 AM »

ok, thanks for the advice :D
Logged
I am the Milkman. My milk is good.
Pages: 1 [2]  All
 

Page created in 0.035 seconds with 19 queries.