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: Very long Scene Change  (Read 6758 times)

0 Members and 1 Guest are viewing this topic.

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Very long Scene Change
« on: April 09, 2010, 10:31:13 AM »

Hi y'all,

I have a scene with a lot of entities. A lot! It's a minigame, a clone of Minesweeper (like in Windows). There are about 132 (12x11) entities representing the tiles and an equal number of entities that work as number overlays (like '3 mines adjacent to this tile'). Combined with a few other entities the total number in this scene is close to 300.

A Game.Changescene from this scene to the next takes very long. On slower computers (and the game is aimed to be playable on 1 Ghz single core machines with 256 megs of RAM) it takes a minute or more - which most testers identify as a crash.

My questions: is the long Scene Change linked with the unusually high number of entities? If so, is there anything I can do about it?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Very long Scene Change
« Reply #1 on: April 09, 2010, 01:15:47 PM »

First of all you need IMO way less entities - you need background grid entity (1) and then 12x11 entities for overlays which equals to 133 entities for the whole scene.
As WME reuses the visual assets, it shouldn't be a problem at all.

Without more exact knowledge of your goal I can't unfortunately help you, but if you PM me some minimalistic repro project, I might push you in the right direction. I use dynamically generated entities myself with quite a big count and these load in no time.
 
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #2 on: April 09, 2010, 02:07:04 PM »

For clarification purposes:

The Minesweeper clone is set on a roof. The shingles are the tiles and the "mines" are loose shingles that break/fall if clicked.

To make things difficult, the perspective is not flat, that means the tiles/shingles are not all the same size. Instead, each shingle is pretty much its own graphic and they are NOT interchangable.

I use 132 shingle-entities. Because they're not interchangable, each one has its own sprite, so there are 132 pngs. Each one gets highlighted (Shingle.AlphaColor = ...) when the cursor hovers above it and each one gets darkened, if clicked and it's "safe". Each one is removable if it's a "mine" and clicked on. So each shingle has 4 possible states (normal, highlight, darkened, gone).

On top of that are the 132 number overlays. Each number is a graphic and set as the overlay entity's sprite. The graphics are interchangable, so in total there are just 9 pngs for that (1..8, marked). But their position is not interchangable, because of the non-flat perspective. The numbers are centered on the shingle and for shingles "closer" to the viewer that means different x,y offsets than for shingles further away. Since Wintermute doesn't properly support Entity.Width, it cannot be calculated dynamically.

(To better illustrate that: A small shingle in the back might be 30x32 pixels, so it's center has offsets of 15 and 16. A larger tile in the front might be 64x70, so the offset would be 32x35)

I can't mail you a repro project because I wouldn't know how to do one in reasonable time and I'm afraid my employer won't let me mail you the real project (although it's not commercial...).
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Very long Scene Change
« Reply #3 on: April 09, 2010, 06:30:00 PM »

are you loding all the gfx into Scene editor or are you loading them dynamically at the runtime?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Very long Scene Change
« Reply #4 on: April 10, 2010, 12:06:14 PM »

What happens when you're opening the scene file in SceneEdit? Does it take ages as well?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #5 on: April 12, 2010, 11:29:10 AM »

are you loding all the gfx into Scene editor or are you loading them dynamically at the runtime?

They're all loaded in the Scene editor (because of the exact placement).

What happens when you're opening the scene file in SceneEdit? Does it take ages as well?

No, SceneEdit loads it just as fast as any other scene.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Very long Scene Change
« Reply #6 on: April 12, 2010, 11:49:07 AM »

That's interesting, because SceneEdit loads the scene exactly the same way as the engine does. Except that SceneEdit doesn't execute scripts. Are there many scripts? Are they doing something during startup?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #7 on: April 12, 2010, 01:27:18 PM »

Each of the 132 shingle-entities has a script attached. This script is just 7 lines, basically just passing MouseEntry and MouseLeave through to the main.script. Apart from that only one more script, the mainscript for the scene, is attached.

Maybe it's that? Attaching 132 scripts (or better attaching 1 script 132 times) and later having to detach them?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Very long Scene Change
« Reply #8 on: April 12, 2010, 10:20:55 PM »

you'd be imo performance-wise better off with a single loop - checking Game.ActiveObject

132 scripts might really affect the performance and they seem useless to me in your example.

I would use something like this (entirely untested):

Code: WME Script
  1.  
  2. var activeObject = null;
  3.  
  4. while (1)
  5. {
  6.    if (Game.ActiveObject != activeObject)
  7.    {
  8.       // we register change!
  9.       if (Game.ActiveObject == null)
  10.       {
  11.              activeObject = Game.ActiveObject;
  12.              
  13.              // do your mouse out code here
  14.       }
  15.       else
  16.       {
  17.             activeObject = Game.ActiveObject;
  18.  
  19.             // do your mouse entry code
  20.  
  21.       }
  22.    }
  23.    Sleep(30);
  24. }
  25.  
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #9 on: April 13, 2010, 02:32:16 PM »

I'll try that. The script attaching was something I did a couple of months ago when I was pretty new to WME. Maybe performance will improve.
Logged

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #10 on: April 15, 2010, 07:30:05 PM »

Removing all the scripts and solving it with a simple loop like metamorphium suggested does work and is a whole lot more elegant, but it DOES NOT help with the speed (or better the lack thereof) of the loading and saving of that particular scene.  :(
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Very long Scene Change
« Reply #11 on: April 15, 2010, 08:40:35 PM »

hmm. unless I see the scripts you're using there, I can't help anymore.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Very long Scene Change
« Reply #12 on: April 15, 2010, 11:41:05 PM »

No worries, pal. You've done plenty!
Logged
 

Page created in 0.065 seconds with 22 queries.