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: COMPASS  (Read 6578 times)

0 Members and 1 Guest are viewing this topic.

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
COMPASS
« on: November 19, 2004, 12:34:23 PM »

Hi,
   I want to implement a compass that stays at the bottom right hand corner of the screen even when the scene scrolls.

I also want the compass needle to spin around in the compass and when the players mouse pointer moves over an exit the compass needle points to that direction (highlighted etc)

Also in some scenes like cutscenes etc I do not want the compass to be displayed.


I have created the compass as a sprite and the needdle spins in a loop.


How would I code the above?? any ideas



Many thanks
 >:D

Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: COMPASS
« Reply #1 on: November 20, 2004, 12:35:23 PM »

To display the compass, use a window. It will be transparent and will only contain one static control, representing the compass. Store the window in a global variable so that you can hide/show it when needed.

Making the compass show a direction will be more tricky. I suppose you have several frames with different directions of the needle, how many of them? The script will have to use the goniometry functions to determine the right angle depending on mouse pointer position and select an appropriate frame..
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: COMPASS
« Reply #2 on: November 20, 2004, 06:08:42 PM »

Making the compass show a direction will be more tricky. I suppose you have several frames with different directions of the needle, how many of them? The script will have to use the goniometry functions to determine the right angle depending on mouse pointer position and select an appropriate frame..

I don't really get why you should have many frames of the needle. Can't you just have it in one frame and just rotate the entity that belongs to? Or am I missing something?
Logged
fl*p

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: COMPASS
« Reply #3 on: November 20, 2004, 11:33:09 PM »

Making the compass show a direction will be more tricky. I suppose you have several frames with different directions of the needle, how many of them? The script will have to use the goniometry functions to determine the right angle depending on mouse pointer position and select an appropriate frame..
I don't really get why you should have many frames of the needle. Can't you just have it in one frame and just rotate the entity that belongs to? Or am I missing something?

I had the same thought, maybe Mnemonic didn't get used to his self-written newer properties. ;) Ok, but seriously - the rotate property only works in accelerated mode, maybe that's the reason.

@SBOVIS:
Ok, you want the compass (needle) to show something special when you move the mouse over an exit... my approach would be a) to use the window as Mnemonic already mentioned and then b)to find out the absolute rotation values for the needle (to point to the desired position for those exits) and make the needle rotate to that point on the "MouseEntry" event of your exit entities.
The rotating should be easy - you just compare the current rotation value with the one you want to get - and then just increase or decrease the current rotation in a loop until the wanted value is reached.

Too late for me to try out some sample code today - if you don't succeed, just send us the code how you tried it. ;)
Logged
Mooh!

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: COMPASS
« Reply #4 on: November 22, 2004, 12:07:41 PM »

Thanks for all your help,
                                 But I was not worried too much about the arrow moving properly etc.
I was going to create a loopin sprite that rotates the needle. This is the default.
Then I was going to create 8 seperate sprites of the needle in the 8 directions (glowing)

Then What I needed was some code so that when the players mouse moved over an exit the needle would auto shift to that position by playing the corresponding direction sprite over the default one.
When the player moves the mouse away from the exit the direction sprite would disappear.

I am not to good with window code and global variables etc as I am still learning, any examples??


Regards


Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: COMPASS
« Reply #5 on: November 29, 2004, 03:19:07 PM »

HI,
    Anyone had chance to test this?? has anyone got any test code I can test this idea with??


Mnay thanks
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Castler

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 15
    • View Profile
    • Limbo of the Lost
Re: COMPASS
« Reply #6 on: December 08, 2004, 05:48:32 PM »

I can think of a way, but I'm very new, so, just an idea.

Give every exit a property or method that returns the name of the correct sprite to overlay the compass with. I would make four different script files, say, westexit.script, eastexit.script, etc, one for each direction. They would look something like this:

method GetSpriteName() {
  return "westexit.sprite";
}

For each exit, you would attach one of these scripts.

Then, on the mouse entry event for the exit, call this method to figure out which sprite to use. For instance, attach the following script to each exit. This means you will have two scripts attached to each exit. NOTE: This is erroneous code. I don't really know how to reference the compass window, which I called winCompass.

var winComp2;

on "MouseEntry" {
  //Create a new window, winComp2, and place it right over the compass one.
  winComp2 = Game.CreateWindow("winComp2");
  winComp2.X = winCompass.X;
  winComp2.Y = winCompass.Y;
  //Set the window's sprite.
  winComp2.SetImage(GetSpriteName());
}
on "MouseLeave" {
  Game.DeleteWindow(winComp2);
}

Does that help at all? Like I said, I'm new. I'm just figuring out how things work.

C

...
Oh, and anyone who wants to can point out that I'm wrong, because I probably am.
« Last Edit: December 08, 2004, 05:54:28 PM by Castler »
Logged
 

Page created in 0.021 seconds with 23 queries.