Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: 1 2 [All]

Author Topic: Animated cursors problem  (Read 13646 times)

0 Members and 1 Guest are viewing this topic.

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Animated cursors problem
« on: July 07, 2003, 03:53:10 PM »

I'm using an animated arrow as cursor for showing a "change location" region. But I noticed that, when the mouse adopts that cursor, the FPS drops A LOT and the main actor walks very slowly and jerky. It happends only when the animated cursor is being displayed. If I change that cursor for an static one, there's no problem. It's a bug or what I'm doing bad? The code is so simple that I don't think it could be the problem...

P.S. you can test it by going to the Sam n' max location in fred PreAlpha, clickng near a stair so fred has to walk there, and then putting the mouse over the stair, so the animated cursor appears.
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #1 on: July 07, 2003, 04:01:22 PM »

I have tested it to and I can confirm it. Maybe you should upload the animated sprite (the png) to test it in my project.
Logged
fl*p

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #2 on: July 07, 2003, 04:31:22 PM »

OK... I tested it (McCoy send me the sprite) and works great in my project. I can't even guess what the problem might be.
Logged
fl*p

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Animated cursors problem
« Reply #3 on: July 07, 2003, 04:32:41 PM »

Did you used it as mouse cursor? well, I'm going to post the code then, as soon as I come back from Madrid, I have a date with a cutie...  ;D
« Last Edit: July 07, 2003, 04:33:16 PM by McCoy »
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #4 on: July 07, 2003, 04:35:01 PM »

Did you used it as mouse cursor?

Yes, I change one of my cursors with your. and it works fine. No slowdowns (not even 1 frame).

well, I'm going to post the code then, as soon as I come back from Madrid, I have a date with a cutie...  ;D

GoodLuck!!!
 ;D ;D ;D
Logged
fl*p

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Animated cursors problem
« Reply #5 on: July 07, 2003, 04:38:05 PM »

Huh ??? I'm curious about the code then...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Animated cursors problem
« Reply #6 on: July 08, 2003, 12:17:32 AM »

Owww... I didn't remember that... there's no code!! I only putted the path to the sprite of the animated arrow in the "cursor" variable of the stairs region in SceneEdit!!

The animated sprite has 11 TGA frames with a 40ms delay between frames...
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #7 on: July 08, 2003, 08:26:58 AM »

I tested it in a 1024x768 (Fred is in 800x600) scene with no scrolling or animations with the exact same way as McCoy did (just place the sprite of the cursor in the cursor variable of exit region - just as it is in the wme_demo) and the FPS didn't drop not even 1 frame. With "Fred PreAlpha" I loose 30 frames when the cursor activates!!! :( How can this be possible? Some conflict/problem with a script in the background maybe?
Logged
fl*p

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Animated cursors problem
« Reply #8 on: July 08, 2003, 10:03:52 AM »

Well, In the second location, where the animated cursor is, there's no animated background, it's only in the Fred's room... and there are only 2 running scripts, so I don't think that's the problem...
« Last Edit: July 08, 2003, 10:09:02 AM by McCoy »
Logged

Click here to sign my sig!

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Solved!!! ;D
« Reply #9 on: July 08, 2003, 11:43:01 PM »

Yeah  I solved it! has I said in the other post (the best approach...), the problem was the game_daemon.script . I was using it for, beside other things, showing the text of the bottom of the screen. That whas the problem: it overloaded the script. But now I ralised that all that could be done by events! I have realised now because, at a first time, I implemented it just by copying and modifiying the "use something with something" text routine from the game_daemon of the WME demo project, so I supposed that the only way of making the verbs appear and all that whas imitating that way... but nope, for things that are not "use this with that", like "take something" "eat something" and all that, it could be done by events, thus, there's no loop needed, ergo, there's no slowdown!!!!!

Anyway, I splitted the game_daemon: one script for the floating caption, with 40ms, another one for the "use this with that" management, 110ms, and another one for the corner buttons, 150 ms. Now it works great!  ;D

Thanx everybody for all the help, specially to odnorf! ;)

P.S. As ever, I hope that you understand everything... :S
« Last Edit: July 08, 2003, 11:44:30 PM by McCoy »
Logged

Click here to sign my sig!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Animated cursors problem
« Reply #10 on: July 09, 2003, 07:07:29 AM »

I'm curious about how do you use the events to display the right captions. Could you share more details with us, phluease? ;)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Animated cursors problem
« Reply #11 on: July 09, 2003, 12:40:48 PM »

Ok, I'll try, but don't blame me if you don't catch everything... my english does not help at all...

Now, the code for showing the bottom text is located in it's appropriate button of the right-hold menu . The "Take something" text routine is located in a script called "take.script" attached to the "take" action button of the right-hold menu.

Here's the code that it has:

Code: [Select]
global WinCaption;
global MenuObject;

////////////////////////////////////////////////////////////////////////////////
on "MouseEntry"
{
          var ObjCapt = new String(MenuObject.Caption);  //save the name of the object
          WinCaption.X = 0; //place the caption at the left side of the screen
          WinCaption.Y = 580; //and at the bottom
          WinCaption.Width = Game.ScreenWidth; //and make it fill it all the way to the right
          WinCaption.TextAlign = TAL_CENTER; //now align the text ot the centre.
         
          if (MenuObject.hand!=null) //if the object has a special properity for the
                                     //"hand" action (for example, use, pull, shake...)
          {
            WinCaption.Text = Game.ExpandString(MenuObject.mano) + " " + ObjCapt.ToLowerCase(); //use it
                                                //and attach the name of the object in lowercase
                                                //to it. This will show something like
                                               //MenuObject.Hand->"Pull lever"<-ObjCapt in lowercase
          }
          else //if it only needs the default action (Pick up)
          {
             WinCaption.Text = Game.ExpandString("/ACTDEF0002/Take") + " " + ObjCapt.ToLowerCase();
                                                                                                //use it.
          }
          WinCaption.Visible = true; //the caption text is finished, show the caption.
}

////////////////////////////////////////////////////////////////////////////////
on "MouseLeave"
{
   WinCaption.Visible = false; //when the mouse exits the button, hide the caption.
}


The code is smillar for "Talk to" and "Look".

I added some initiallitation code to the right-hold menu script that activates everytime it shows in the screen, not only when it loads. When you press the right mouse button over an interactive zone, the game.script, besides other things, sends an "open" event to the menu.script, so it does this:

Code: [Select]
on "open"
{     
     WinCaption.Visible = false;      
          WinCaption.SetFont("fonts\bottomtext.font");          
}

It Just changes the font and hide the floating caption, because we're going to use it for the bottom text, there's no need of load a new object and waste memory.

But there's still a problem: the game_daemon script is truying to do wird thing with the caption all the time if the mouse is not over an interactive region because of this code:

Code: [Select]
// handle the standard foating caption
  if(Game.Interactive && ActObj!=null)//<-here's a problem...
  {
    if (Game.SelectedItem==null)
    {
     ...
     }
    // handle the caption when you want to use an object with another
    else {
      ...
    }
   ...
  }
  else WinCaption.Visible = false; //<-here too

So, just by changing that for

Code: [Select]
//upper problem
if(Game.Interactive && ActObj!=null && !WinMenu.Visible)
  {

Code: [Select]
//bottom problem
}
  else if(!WinMenu.Visible) WinCaption.Visible = false;

We solve that, and now the text appears in the screen when the cursor is over a right-hold menu button, and disappears when it leaves it, just by using events, with no loop required, so there's no slowdown!!  ;D ;D

Of course you must add a WinCaption.SetFont("whatever"); thing to the game_daemon.script in the floating caption management section if you want to use different fonts for the down text and the floating caption text.

I hope that you got it all! If something is not clear, post it and I'll try to explain that part better...

P.S. BTW, I have not found a way of using events for the "use object with object" text, so I keept it like the demo project, it uses a loop, so the game slowdows quite a lot... this can be partially fixed by splitting the game_daemon.script and using a longer sleep time for it, a lot more than 20ms... If anyone finds a methot of doing that with events, please tell me!!

P.S.2 This is not *exactly* the code I have, it's a simplified version, because in my game there's some more things that need to be checked and performed, but I think that this simplified version is easier to understand, easier to explain, and more general, thus, more useful for everyone.
Code: [Select]
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #12 on: July 09, 2003, 12:51:25 PM »

Oh! I will sure test this when I get home! Thanks McCoy for the good work. :)

PS. Hm... I think that this should be in the scripts/plugins forum so that it will be easily accessible by new members in the future. Maybe we should move it?
Logged
fl*p

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Animated cursors problem
« Reply #13 on: July 09, 2003, 12:53:27 PM »

Do what you think is correct, if you think that the explanation is clear enought to go to that section... then move it  ;D
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Animated cursors problem
« Reply #14 on: July 09, 2003, 01:05:41 PM »

Do what you think is correct, if you think that the explanation is clear enought to go to that section... then move it  ;D

I'll check it first (too fully understand if first), and if Jan don't have any problems with it I'll (or he'll) move it to the scripts foum.
Logged
fl*p

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Animated cursors problem
« Reply #15 on: July 09, 2003, 03:13:35 PM »

Thanks, McCoy. It's a cute piece of code. I must explain why the WME demo doesn't take advantage of the "MouseEntry" and "MouseLeave" events. That's simply because they didn't exist back then; they were added later on :-) And it's indeed much more elegant solution than the "daemon script" approach.
I also like your use of the custom properties.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
Pages: 1 2 [All]
 

Page created in 0.069 seconds with 21 queries.