Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Pages: 1 [2]  All

Author Topic: First Person Game  (Read 16348 times)

0 Members and 1 Guest are viewing this topic.

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #15 on: August 08, 2005, 02:45:14 PM »

Well, I don't know what's the problem now. Try putting a Game.Msg() here and there to see if your script is executed at all and if the button presses are handled. Also you can paste the resulting two files here, we'll take a look.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Magnolia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 30
    • View Profile
Re: First Person Game
« Reply #16 on: August 09, 2005, 04:08:31 AM »

I tried the different messages, no luck.
 
Here is the window file
Quote
WINDOW
{
  X = 200
  Y = 200
  WIDTH = 300
  HEIGHT = 304
  NAME = "keypad"
  SCRIPT = "scenes\FrontAnimals\scr\keypadbuttons.script"
  IMAGE = "scenes\FrontAnimals\keypad1.png"
 
  STATIC
  {
    VISIBLE = TRUE
  }


  BUTTON
  {
    IMAGE = "objects\1a.png"
    NAME = "key1"
    X = 42
    Y = 57
    WIDTH = 54
    HEIGHT = 51
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

  BUTTON
  {
    IMAGE = "objects\2a.png"
    NAME = "key2"
    X = 113
    Y = 58
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\3a.png"
    NAME = "key3"
    X = 187
    Y = 58
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\4a.png"
    NAME = "key4"
    X = 42
    Y = 128
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\5a.png"
    NAME = "key5"
    X = 115
    Y = 128
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\6a.png"
    NAME = "key6"
    X = 186
    Y = 128
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\7a.png"
    NAME = "key7"
    X = 42
    Y = 200
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\8a.png"
    NAME = "key8"
    X = 115
    Y = 200
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }

BUTTON
  {
    IMAGE = "objects\9a.png"
    NAME = "key9"
    X = 187
    Y = 200
    WIDTH = 52
    HEIGHT = 50
    VISIBLE = FALSE
    PARENT_NOTIFY = TRUE
  }
}

and here is the script file:
Quote
#include "scripts\base.inc"

////////////////////////////////////////////////////////////////////////////////
on "key1"
{
  Game.Msg("This is my test method");
  AddKey("key1");
  this.PlaySound("sound\keypad1.ogg");
  var Button1 = this.GetControl("key1");
  Button1.SetImage("objects\1a.png");
}
on "key2"
{
  Game.Msg("This is my test method2");
  AddKey("key2");
}
on "key3"
{
  AddKey("key3");
}
on "key4"
{
  AddKey("key4");
}
on "key5"
{
  AddKey("key5");
}
on "key6"
{
  AddKey("key6");
}
on "key7"
{
  AddKey("key7");
}
on "key8"
{
  AddKey("key8");
}
on "key9"
{
  AddKey("key9");
}

var Pressed = "";
function AddKey(KeyName)
{
 Pressed = Pressed + KeyName;
 if (Pressed=="key1key2key3")
 {
   Game.Msg("This is my test method");
 }
}

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #17 on: August 09, 2005, 05:04:12 PM »

Ow, I see, I see. The problem is the buttons are invisible (VISIBLE = FALSE). You'll have to make them visible, because otherwise the player can't click them. Other than that the code is ok, I tested it and it works.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Magnolia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 30
    • View Profile
Re: First Person Game
« Reply #18 on: August 11, 2005, 04:07:19 AM »

You're right!!!That fixed it.

OK then.  If I use this to turn an object on:

var Button1 = this.GetControl("key1");
Button1.SetImage("objects\1a.png");

and I use this for checking what keys are on:

Pressed = Pressed + KeyName;
if (Pressed=="key1key2key3")

If the above turns out to be a false statement, they selected the wrong buttons, how do I turn off the objects I set with the Button1.SetImage?

Unrelated question:

Is there a way to tell where my 'x' and 'y' coordinates are in the window mode?  During a scene edit, they will display on the screen but window mode doesn't.

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #19 on: August 11, 2005, 03:22:19 PM »

Quote
If the above turns out to be a false statement, they selected the wrong buttons, how do I turn off the objects I set with the Button1.SetImage?
You could use some simple loop to go through all the buttons and set their images back to normal. Something like (untested):

Code: [Select]
for(var i=1; i<=9; i=i+1)
{
   var Btn = this.GetControl("num" + i);
   Btn.SetImage("objects\" + i + "a.png");
}


Quote
Is there a way to tell where my 'x' and 'y' coordinates are in the window mode?  During a scene edit, they will display on the screen but window mode doesn't.
Unfortunately there's no GUI tool for editing windows yet. You can only check the coordinates when running the game in debug mode.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Magnolia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 30
    • View Profile
Re: First Person Game
« Reply #20 on: August 12, 2005, 05:05:42 AM »

I am curious, why will this not work (see changes in red)?  Can you not use an "if" without it being attached to a function or something else?  I tried with a variable and no go.  Or did I script it wrong? The variable is defined as:  var keyspressed;

Is this engine capable of nested if's?

Quote
on "key9"
{
  AddKey("key9");
  this.PlaySound("sound\keypad9.ogg");
  var Button9 = this.GetControl("key9");
  Button9.SetImage("objects\keypad9_gray.png");
  keyspressed = keyspressed + 1;
}

var Pressed = "";
function AddKey(KeyName)
{
 Pressed = Pressed + KeyName;
 if (Pressed=="key4key1key3")
 {
   self.Close();
   Game.ChangeScene("scenes\EntranceHall\EntranceHall.scene");
 }
}

 if (keyspressed==3)
 {
  Game.Msg("This is a test");
}
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #21 on: August 12, 2005, 09:03:26 AM »

To better understand how the scripts are executed, imagine your window has the following script attached:

Code: [Select]
some_code_1

on "SomeEvent"
{
  event_handling_code
}

some_code_2

function SomeFunc()
{
  function_code
}

some_code_3

When the window is created, all the code outside functions and event handlers is executed, in this case the script will execute: some_code_1, some_code_2, some_code_3.
After that the script stays persistent in memory and only waits for the events to be triggered.
It means the "if" code in your example will only be executed once, when the window is created.

I really don't see any reason why this code couldn't be inside the AddKey() function. You need to check the number of pressed key only when some of them has been pressed anyway...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Magnolia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 30
    • View Profile
Re: First Person Game
« Reply #22 on: August 14, 2005, 05:41:58 AM »

That description helps ALOT!!!

Where would I work a counter in the Addkey function.  I only want to flip the images after 3 keys have been clicked on, and then reset the counter to zero so it can be started over.  I tried this:

Quote
var Pressed = "";
function AddKey(KeyName)
{
 Pressed = Pressed + KeyName;
 keyspressed = keyspressed + 1;
 if (Pressed=="key1key2key3")
 {
   self.Close();
   Game.ChangeScene("scenes\EntranceHall\EntranceHall.scene");
 }
 else
    if (keyspressed > 3)
{
  Game.Msg("This is a buttontest");
  var Btn1 = this.GetControl("key1");
  Btn1.SetImage("objects\keypad1.png");
  var Btn2 = this.GetControl("key2");
  Btn2.SetImage("objects\keypad2.png");
  var Btn3 = this.GetControl("key3");
  Btn3.SetImage("objects\keypad3.png");
  var Btn4 = this.GetControl("key4");
  Btn4.SetImage("objects\keypad4.png");
  var Btn5 = this.GetControl("key5");
  Btn5.SetImage("objects\keypad5.png");
  var Btn6 = this.GetControl("key6");
  Btn6.SetImage("objects\keypad6.png");
  var Btn7 = this.GetControl("key7");
  Btn7.SetImage("objects\keypad7.png");
  var Btn8 = this.GetControl("key8");
  Btn8.SetImage("objects\keypad8.png");
  var Btn9 = this.GetControl("key9");
  Btn9.SetImage("objects\keypad9.png");
  keyspressed = 0;
 }
}

But it doesn't seem to recognize the "keyspressed" variable's value.  I also tried adding it to the "on key#" paragraphs by adding +1 to it there.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #23 on: August 15, 2005, 02:05:05 PM »

Um, and where is the "keyspressed" variable declared? It definitely should recognize it.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Magnolia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 30
    • View Profile
Re: First Person Game
« Reply #24 on: August 15, 2005, 06:18:58 PM »

I have it up at the top:

#include "scripts\base.inc"

////////////////////////////////////////////////////////////////////////////////
var keyspressed;
on "key1"
{
  AddKey("key1");
  this.PlaySound("sound\keypad1.ogg");
  var Button1 = this.GetControl("key1");
  Button1.SetImage("objects\keypad1_gray.png"); 
}
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: First Person Game
« Reply #25 on: August 16, 2005, 09:53:51 PM »

It should work then. Are you getting some compile errors or..?
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.066 seconds with 19 queries.