Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 3:19 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: How to use object properties as variables
PostPosted: November 20th, 2007, 12:53 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Thanks to Chris Jones, I picked up on this technique. To assign or use an object's properties within a script.

viewtopic.php?t=1153&highlight=dropped+script
There he uses
Code:
this.dropped


Several questions:
1- Is there any DW documentation on this, deeper than the Help files and Scripting Guide?
2- How to know which properties are "built-in" (therefore caution when overwriting)?
3- What guidelines, or gotchas, if I want to script my own? ~adhoc. For example
Code:
Vector_1.movingcolour = "green"
Vector_1.stillcolour = "red"
Button_5.locate = otherobj.GetPosition()    // might use for presets, user preferences, etc.

4- If use this scheme, how to "poll" or "identify" all objects with some particular value for an adhoc property?


I realize this is really an off-the-wall, open-ended question. So any ideas appreciated. :twisted:

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 10:59 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
OpusScropt is an Object Oriented Program. If used 'in anger' it is an incredibly powerful language. To see an example of OOP using OpusScript,
Have a look at the Lander Game to see what it is really capable of. Unfortunately The link in this post to the old documentation no longer works viewtopic.php?t=413&highlight=lander

I will have a copy of it somewhere??? The full script appears in the Opus PRO (Additional Features) book, which you possibly don't have and I can't find it in the documentation on-line viewtopic.php?t=908

If you really want to get into OOP, there are lots of books on the topic :-) (for my sins, I studied Java at Uni) The beauty of Opus and OpusScript is it's simplicity in use. In Java, you need all kinds of constructors to create the objects before you can do anything with them---it's extremely powerful of course, But what would take me 2 hours in Java, I could do in 10 minutes in Opus with OpusScript.
So in answer to Q1 look at the manuals on line, but I think almost everything is covered in the OPUS help. There are many undocumented features which I would like to see listed somewhere. I find references to them, then forge where. If you look at books on OOP--I doubt they will be of much help, because they tend to be aimed at specific languages and the basics of OOP is lost among the semantics of the language.

Q2--I'm not really sure what you mean, but in OOP, you can create new Objects and assign properties to them, for example, the lander script has

Code:
function GetSpaceship()
{
var Vessel= new Object
Vessel.Shell= GetCurrentShip()
Vessel.Height=Vessel.Shell.GetHeight()/2
Vessel.Width= Vessel.Shell.GetWidth()/2

etc

this is real OOP programming. A new object is created ---the Vessel---- and the attributes of the new object are assigned from either other functions, or built in functions, but notice how you can 'string' the attributes together, so that the Vessel.Shell is the name of the current ship returned by the GetCurrentShip() function, but you can then extend the function to get the height of the Vessel.Shell. You can call the attributes anything (except key names) so the properties aren't built in---they are assigned by you.

Q3 Hack it and see :-)

Q4 Again---not sure what you mean, but this is Object oriented, so you always have to be referencing an object to get properties, but as you mention above the "this" keyword allows abstraction---say you wanted to find the properties if an object and you have 200 objects. You wouldn't have to write 200 functions ...Object1.GetHeight()...then Object2.GetHeight()---you would write the function----- this.GetHeight() but you would still have to reference it 200 times to get the property...BUT...if you have Object1, Object2, Object3, you could further abstract it by using Objecti...where "i" is a loop counter :-)
Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 11:48 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
This technique (OOP) is extremely powerful and the bases for how our IKIQ software works.

Like Sandyn points out we actually create a custom object as well as its properities because we don't have a physically object (such as your vectors) to use the 'this' command with.

However, 'this' will work perfectly with your example as you can extract properties when working directly with the object on screen using this or can refer to the actual name in a script - win - win.

With regards to loop accessing properities in all your objects you can do this by either using the 'eval' statement if necessary or in the case of IKIQ we assign each object to an array cell.

With custom objects you don't have to worry about conflicting properities but if you are going to use 'this' then just ensure that the property name is unique perhaps by ensure that all names are prefixed.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 20th, 2007, 12:22 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Sandy,

Thanks for chiming in, and thanks taking time to explain around this. Some good 'filling the gap' for me.

Quote:
If you look at books on OOP--I doubt they will be of much help, because they tend to be aimed at specific languages and the basics of OOP is lost among the semantics of the language.


I started looking on-line web, and the bookstores. Looked thru some Actionscript books, but even there the language and its uses seem to go off into other 'purposes', and certainly when laid-out in context of MM Flash MX or 8, the language and syntax are different.

re: Q2

Quote:
Q2--I'm not really sure what you mean, but in OOP, you can create new Objects and assign properties to them, for example, the lander script has

'Yes'. That.
* Specifically I meant... for example 'this.dropped', 'dropped' seems to be a specific word that Opus recognizes (I am not 'assigning' it, but using Cap word 'Dropped' won't work the same way.) However other words 'returning' or 'returned' or 'removed' do not work in Opus to detect or use a dragged object's drop state. (these word appear in some other languages).
* Microsoft has some OOP words for mousewheel.up and mousewheel.down, also mousewheel.left and mousewheel.right --- Opus can use the up/down, but not the left/right. (it seems?)
* as you noted... not all documented.

Quote:
Q3 Hack it and see

I did just start to scratch that itch.
I'm not a programmer by paycheck, so my 'sandbox' has "sand everywhere" and hardly a castle.

re: Q4
Quote:
how to "poll" or "identify" all objects with... property?

and
Quote:
--- this.GetHeight() but you would still have to reference it 200 times to get the property...BUT...if you have Object1, Object2, Object3, you could further abstract it by using Objecti...where "i" is a loop counter

You answered that... 'for loop'. Great! At least I know what to expect... will have to 'play a bit'. If I can get a handle on the basics, I'd be happy and will figure out where to leverage these. ( but 'no', don't want to get heavy into OOP and constructors).

If you do find the Lander Works, please post. Otherwise, I'll nose around in the forum later.

Thanks again.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 12:30 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Mac,

Thanks for the tips.

I associate 'this' with an 'instance' of something. But I could see how being careless could yield some errant results.

Some things I'll have to play with to understand is how to abstract these object.myownproperty1, 2 etc in functions. And then make sure how I call them from different pages doesn't screw up the works.

Good to know Opus is all so flexible.

I also figured I'd have to get skilled and navigating thru parent and childs to make some of this work. Someday.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 2:34 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
multiple pages :-(

You'd need to make sure you can access the objects properties as these are normal page based.

I have used scripts to deal with other pages (it should be in the Opus functions example on my website - it free) - it gets the name of all the pages in a publication to build a navigation and TOC. I seem to remember that the idea works well but was quite hard to impliment.

If you are going to need access to properties from another page IE you want to know if a partiular object was dropped or not, I'd suggest feeding the objects into a publication array IE

myVectors[x] = new BouncingBall()

This can be a little confusing but powerful:

BouncingBall is a function that sets the default properities for the object:


function BouncingBall()
{
this.colour = 'red'
this.positionY = 20
this.positionX = 20
this.dropped = false
}

The object is the Array Cell IE myVectors[0] is an object with the above properties and myVectors[1] is the next object. You can change, call or add properites for any of the objects like this:

if (myVectors[123].dropped)
{
//Do something here
}

Using this, you do what has already been described before by linking the object (myVectors[x]) to an actual object. IE call your actual vectors on screen v1 to v123. Then pass just the numerical part of the name as the 'x' in the objects array.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 20th, 2007, 9:04 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
FYI. the lander script. I found it on Opus V2.6 disk.
Code:

function StartButton()
{
   // set up landing pad position/dimensions
   Landing = GetLandingPad();
   
   // Set Up The Thrusters
   SetThruster(0, Aft_Thrusters, Thrust_Main_Cur_Pow,Thrust_Main_Cur_Eff);
   SetThruster(1, For_Thrusters, Thrust_Retro_Cur_Pow,Thrust_Retro_Cur_Eff);
   SetThruster(2, Port_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
   SetThruster(3, Stb_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
   
   SpaceShip = GetSpaceShip();
   //Build the spaceship.
   var x = Clamp.GetXPosition() - SpaceShip.Shell.GetXPosition();
   var y = Clamp.GetYPosition()+30 - SpaceShip.Shell.GetYPosition();      
      
   //MoveObject(x,y);
   Docked = 1;   
   Money = 1000;
   //Build the spaceship.
   
   SpaceShip.Shell.Show();
   SpaceShip.Thrust_Retro.Obj.Show(true);   
   SpaceShip.Thrust_Stb.Obj.Show(true);
   SpaceShip.Thrust_Port.Obj.Show(true);
   SpaceShip.Thrust_Main.Obj.Show(true);
   
   MenAboard    = 0;
   Lives       = 3;
   Reward      = 100;
   PowerupTime = TimeGetSeconds();
   PowerupOn   = false;
   
   if(FirstRun)
   {
      ThrustSound = OpenSound("sfx00004.wav", -1, true);
      FirstRun = false;
   }

   
   //REMOVE
   //Debug.trace("StartButton!!!\n\n")
   //var shipPos = SpaceShip.Shell.GetPosition()
   //Debug.trace("shipPos.x = " + shipPos.x + "         shipPos.y = " + shipPos.y + "\n\n")
   //REMOVE
   
   //Run the Game....
   main();
}

function GetSpaceShip()
{
   var Vessel = new Object;
   Vessel.Shell = GetCurrentShip();
   Vessel.Height = Vessel.Shell.GetHeight()/2;
   Vessel.Width = Vessel.Shell.GetWidth()/2;
   Vessel.Thrust_Main = GetCurrentThruster(0);   // update the thrusters from the thruster objects....
   Vessel.Thrust_Retro = GetCurrentThruster(1);
   Vessel.Thrust_Port = GetCurrentThruster(2);
   Vessel.Thrust_Stb = GetCurrentThruster(3);
   Vessel.Fuel = FuelTank;
   
   return Vessel;
}

function GetLandingPad()
{
   var LandPad = new Object;
   LandPad.Pad = LandingPad;
   LandPad.Height = LandPad.Pad.GetHeight()/2;
   LandPad.Width = LandPad.Pad.GetWidth()/2;
   LandPad.x = LandPad.Pad.GetXPosition();
   LandPad.y= LandPad.Pad.GetYPosition();
   return LandPad;
}

function GetCurrentShip()
{
   return Ship;
}

function GetCurrentThruster(T)   // set up the current thruster characteristics....
{
   if (T==0) return Thrust_Main;
   if (T==1) return Thrust_Retro;
   if (T==2) return Thrust_Port;
   if (T==3) return Thrust_Stb;
}

function SetThruster(ID,Obj,Pow,Eff)   // write the current thruster characteristics - i.e. in the ship
{
   var THRUSTER = new Object;
   
   THRUSTER.Obj = Obj;   // the object to use...
   THRUSTER.pow = Pow; // the power...
   THRUSTER.eff = Eff; // the Effect...

   if (ID==0)   Thrust_Main = THRUSTER;
   if (ID==1)   Thrust_Retro = THRUSTER;
   if (ID==2)   Thrust_Port = THRUSTER;
   if (ID==3)   Thrust_Stb = THRUSTER;
}

function ApplyForces(Vel){
   Vel+=Gravity;
   return Vel;
}

function Thrusters()
{
   var Vector = new Object;
   Vector.x = 0;
   Vector.y = 0;
   Vector.Rate = 0.0;
   
   
   if (SpaceShip.Fuel >0)
   {
      if(IsKeyPressed("Up"))         
      {
         Vector.y = -SpaceShip.Thrust_Main.pow;
         Vector.Rate += SpaceShip.Thrust_Main.pow / SpaceShip.Thrust_Main.eff;
      }
      else if(IsKeyPressed("Down"))
      {
         Vector.y = SpaceShip.Thrust_Retro.pow;
         Vector.Rate += SpaceShip.Thrust_Retro.pow / SpaceShip.Thrust_Retro.eff;
      }
      
      
      if(IsKeyPressed("Left"))
      {
         Vector.x = -SpaceShip.Thrust_Stb.pow;   // right engine to go left...
         Vector.Rate += SpaceShip.Thrust_Stb.pow / SpaceShip.Thrust_Stb.eff;
      }
      else if(IsKeyPressed("Right"))
      {
         Vector.x = SpaceShip.Thrust_Port.pow;
         Vector.Rate += SpaceShip.Thrust_Port.pow / SpaceShip.Thrust_Port.eff;
      }
   
   }
   return Vector;
}

function Move(time)
{
   var ychange = Velocity*time;
   var xchange = XVelocity*time;   
   
   //REMOVE
   //Debug.trace("Entering Move!!!\n")
   //Debug.trace("Velocity = " + Velocity + "\n")
   //Debug.trace("XVelocity = " + XVelocity + "\n")
   //Debug.trace("time = " + time + "\n\n")
   //REMOVE
         
   MoveObject(xchange,ychange);

}

function Draw()
{
   
   if (IsKeyPressed("Up")&&SpaceShip.Fuel)
   {
      SpaceShip.Thrust_Main.Obj.Show(false);
      if(ThrustSound.GetPosition() == 0.0)
      {ThrustSound.Play();}
   }
   else SpaceShip.Thrust_Main.Obj.Hide();

   if (IsKeyPressed("Down")&&SpaceShip.Fuel)
   {
      SpaceShip.Thrust_Retro.Obj.Show(false);
      if(ThrustSound.GetPosition() == 0.0)
      {ThrustSound.Play();}
   }
   else SpaceShip.Thrust_Retro.Obj.Hide();
   
   if (IsKeyPressed("Left")&&SpaceShip.Fuel)
   {
      SpaceShip.Thrust_Stb.Obj.Show(false);
      if(ThrustSound.GetPosition() == 0.0)
      {ThrustSound.Play();}
   }
   else SpaceShip.Thrust_Stb.Obj.Hide();
   
   if (IsKeyPressed("Right")&&SpaceShip.Fuel)
   {
      SpaceShip.Thrust_Port.Obj.Show(false);
      if(ThrustSound.GetPosition() == 0.0)
      {ThrustSound.Play();}
   }
   else SpaceShip.Thrust_Port.Obj.Hide();
   
   // code to display smoke if we are near a surface.....
   // collision detect the thruster effect frame with the surface or something
}


function Land()
{
   // get the landing pad details....
   var x = SpaceShip.Shell.GetXPosition();
   
   var s = SpaceShip.Width-Landing.Width;
   var left=Landing.x+s;
   var right=Landing.x-s;
   
   if ( (x>left)&&(x<right) )
   {
      if (SpaceShip.Shell.IsObjectIntersecting(LandingPad))
      {
         if (Velocity < 50)
         {
            var y = SpaceShip.Shell.GetYPosition()-(Landing.y-Landing.Height-SpaceShip.Height+15);
            if (y<2) y=0;
            if (y>-2) y=0;
         
             MoveObject(0,y);
             if (Velocity>0) Velocity = 0;
             return 2; // landed safely
         }
         else return 1;  // crashed
      }
   }
   return 0;   // carry on
}

function MoveObject(x,y)
{
   SpaceShip.Shell.Move(x,y);
   SpaceShip.Thrust_Main.Obj.Move(x,y);   
   SpaceShip.Thrust_Retro.Obj.Move(x,y);   
   SpaceShip.Thrust_Port.Obj.Move(x,y);   
   SpaceShip.Thrust_Stb.Obj.Move(x,y);
}

function Objects()
{
   if (SpaceShip.Shell.IsObjectIntersecting(Asteroid))
   {
      return 1;
   }
   
   if (SpaceShip.Shell.IsObjectIntersecting(Shuttle))
   {
      return 1;
   }

   if (SpaceShip.Shell.IsObjectIntersecting(Plane))
   {
      return 1;
   }
   
   if (SpaceShip.Shell.IsObjectIntersecting(Console))
   {
      return 1;
   }

    if (SpaceShip.Shell.IsObjectIntersecting(Ground))
   {
      return 1;
   }
   
   if (SpaceShip.Shell.IsObjectIntersecting(Shield))
   {
      return 1;
   }

   return 0;
}
 

function Bonus()
{
    // bonus to equiment  - retros, thrusters, fuel.
}

function LoadShip()
{
   // trigger a man added to ship
}

function UnloadShip()
{
    // trigger a man left the ship.
}

function BurnFuel(Rate,Time)
{
   // fuel burning depends upon thruster power and efficiency.
   SpaceShip.Fuel -= (Rate*Time)*2;
   if (SpaceShip.Fuel<0) SpaceShip.Fuel=0;   
//   Debug.trace("Fuel = "+SpaceShip.Fuel+"\n");
}

function Refuel(Time)
{

   // fuel cost from money......
   // fills up at rate but costs money for rate.....
         
   var totalfuel = FuelTank*Time/5;
   var d = SpaceShip.Fuel+totalfuel;
   if (d>=FuelTank)
   {
      totalfuel = FuelTank - SpaceShip.Fuel;
      Time = (totalfuel*5)/FuelTank;
   }
   
   var totalcost = FuelPrice*Time*5;
   if (totalcost > Money){
      totalfuel = totalfuel*(Money/totalcost);
      totalcost = Money;
   }
   
   SpaceShip.Fuel += totalfuel;

   var roundcost = Math.round(totalcost);
   if (roundcost < totalcost) roundcost++;
   
   Money -= roundcost;
   
//   Debug.trace("Fuel = "+SpaceShip.Fuel);
//   Debug.trace("Money = "+Money+"\n");

      
}

function main()
{
   while(true)
   {
      var Time = TimeGetSeconds();
      var TimeStep = Time - CurrentTime;
      CurrentTime = Time;
      
      Velocity = ApplyForces(Velocity);
      var Thrust = Thrusters();
      Velocity += Thrust.y;
      XVelocity += Thrust.x;
      BurnFuel(Thrust.Rate,TimeStep);
      SetFuelGauge();
      if (Objects())
      {
         ShipStatus = "***Crashed***";
         Crash=1;
         var soundPath = "bexpl2.wav";
         
         PlaySound(soundPath);
         break;
       }
        
      var n=0;
      var m = DockSpaceStation();
      if (m)
      {
         if (IsKeyPressed(" ")) Docked = 0;
         ShipStatus = "Docked!";
         LandTime+=TimeStep;
         n=1;
         
         if(MenAboard > 0)
         {
            UnloadShip()
         }
      }
      var l = Land();
      if (l==2)
       {
          ShipStatus = "Landed!";
         if (IsKeyPressed(" ")) Refuel(TimeStep);
         XVelocity = 0;
         Berth();
         LandTime+=TimeStep;         
         n=1;
         
         if(MenAboard < 4)
         {
            BoardShip();
         }
       }
       else if (l==1)
       {
          ShipStatus = "***Crashed***";
          Crash=1;
         var soundPath = "bexpl2.wav";
         
         PlaySound(soundPath);
         break;
       }
      
      if (!n)
      {
            ShipStatus = "Okay";
         LandTime=0;
      }
      
      if(!PowerupOn)
      {
         if(Time - PowerupTime >= 5)
         {
            var rand = Math.random();
            
            if(rand > 0 && rand <= 0.25)
            {
               Item_Upg_2.Show();
               PlaySound("sfx00582.wav");
            }
            else if(rand > 0.25 && rand <= 0.5)
            {
               Item_Upg_3.Show();
               PlaySound("sfx00582.wav");
            }
            else if(rand > 0.5 && rand <= 0.75)
            {
               Item_Upg_4.Show();
               PlaySound("sfx00582.wav");
            }
            else if(rand > 0.75 && rand <= 1.0 && Lives < 3)
            {
               Item_Upg_1.Show();
               PlaySound( "sfx00582.wav");
            }
            rand = Math.random()
            
            PowerupOn   = true
            PowerupLast = 5 + (10 * rand);
            PowerupTime = Time;
         }
      }
      else
      {   
         TestPowerups();
      }   
      
      Move(TimeStep);
       Draw();
   
      //REMOVE
      //var shipPos = SpaceShip.Shell.GetPosition()
      //Debug.trace("ShipPosition after main!!!\n")
      //Debug.trace("shipPos.x = " + shipPos.x + "    shipPos.y = " + shipPos.y + "\n\n")
      //REMOVE
      
       wait(0);
   }
}


function SetFuelGauge()
{
   // slider nneds to position self as percentage of fuel left...
   
   // i.e. position determined by SpaceShip.Fuel/FuelTank;
   
   var Percentage = (SpaceShip.Fuel/FuelTank);
   
   var yh = Fuel.GetHeight()*Percentage; // if no fuel this is zero - if full this is yh!
   var y = Fuel.GetYPosition();
   Empty_Fuel.SetPosition(Empty_Fuel.GetXPosition(),y-yh);   
}

var last_time_fraction=0.1   
function Berth()
{
  // for every second you are landed there is a charge of landing fee.
   var y = LandTime/3;
   var x = Math.round(y-0.5);  // should always give integer part of LandTime
   var time_fraction = y-x;
   if (time_fraction < last_time_fraction)
   {
      Money -= SpacePortFee;
      BerthingCharge.SetPosition(SpaceShip.Shell.GetXPosition()+20,SpaceShip.Shell.GetYPosition(),0);
      BerthingCharge.Show();
   }
   
   last_time_fraction = time_fraction;
}


function DockSpaceStation()
{
   // if the object is not docked and can dock then dock and set docked......
   
   //if we are intersectng and docked =1 then kill velocity.
   if (SpaceShip.Shell.IsObjectIntersecting(Clamp))
   {
      if (Docked)
      {
            Velocity = 0;
            XVelocity=0;
            return 1;   // we are officially docked!
      }
      else
      {
         return 0;   // docking clamps released
      }
   }
   else
   {
       Docked = 1;
       return 0;
   }      
}

         
function Reset()
{
   // move the ship back to the start.....
   Crashed=0;
   Boom.Hide();
      
   XVelocity=0;
   Velocity=0;
   
   //Debug.trace("Lives = " + Lives + "\n")
   if(Lives == 3)
   {
      Life_1.Hide();
   }
   else if(Lives == 2)
   {
      Life_2.Hide();
   }
   else if(Lives == 1)
   {
      Life_3.Hide();
   }
   Lives--;
   
   if (Lives <=0){
       ShipStatus = "GameOver";
       return;
   }
   
   CurrentTime = TimeGetSeconds();
   
   // need to set te position of the objects to the start position.
   // set up landing pad position/dimensions
   Landing = GetLandingPad();
   
   // Set Up The Thrusters
   SetThruster(0, Aft_Thrusters, Thrust_Main_Cur_Pow,Thrust_Main_Cur_Eff);
   SetThruster(1, For_Thrusters, Thrust_Retro_Cur_Pow,Thrust_Retro_Cur_Eff);
   SetThruster(2, Port_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
   SetThruster(3, Stb_Thruster, Thrust_Side_Cur_Pow,Thrust_Side_Cur_Eff);
   
   //Build the spaceship.   
   SpaceShip = GetSpaceShip();
   var x = Clamp.GetXPosition() - SpaceShip.Shell.GetXPosition();
   var y = Clamp.GetYPosition()+30 - SpaceShip.Shell.GetYPosition();            

   Docked = 1;   
   SpaceShip.Shell.Show(true);
   Thrust_Main.Obj.Show(true);
   SpaceShip.Thrust_Retro.Obj.Show(true);   
   SpaceShip.Thrust_Stb.Obj.Show(true);
   SpaceShip.Thrust_Port.Obj.Show(true);
   SpaceShip.Thrust_Main.Obj.Show(true);
   
   MenAboard = 0;
   ManAboard1.Hide();
   ManAboard2.Hide();
   ManAboard3.Hide();
   ManAboard4.Hide();
   
   PowerupTime = TimeGetSeconds();
   PowerupOn   = false;
      
   //Run the Game....
   main();   
   
}

function   BoardShip()
{
   //Debug.trace("BoardShip!!!\n");
   Passenger.SetPosition(Passenger.GetXPosition() + 2, Passenger.GetYPosition());
   
   if(Passenger.IsObjectIntersecting(SpaceShip.Shell))
   {
      //Debug.trace("CollisionDetected!!!\n");
      Passenger.Hide();
      Passenger.Show(true);
      MenAboard++;
      
      if(MenAboard == 1)
      {
         ManAboard1.Show()
      }
      else if(MenAboard == 2)
      {
         ManAboard2.Show()
      }
      else if(MenAboard == 3)
      {
         ManAboard3.Show()
      }
      else if(MenAboard == 4)
      {
         ManAboard4.Show()
      }
   }
}

function   UnloadShip()
{
   var y = LandTime/3;
   var x = Math.round(y-0.5);  // should always give integer part of LandTime
   var time_fraction = y-x;
   if (time_fraction < last_time_fraction)
   {
      if(MenAboard == 1)
      {
         ManAboard1.Hide();
      }
      else if(MenAboard == 2)
      {
         ManAboard2.Hide();
      }
      else if(MenAboard == 3)
      {
         ManAboard3.Hide();
      }
      else if(MenAboard == 4)
      {
         ManAboard4.Hide();
      }
   
      Money += Reward;
      PassengerReward.Show();
      MenAboard--;
   }
   
   last_time_fraction = time_fraction;
}

function TestPowerups()
{
   var Time = TimeGetSeconds()
   
   if(Item_Upg_1.IsShowing())
   {
      if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_1))
      {
         Lives++;
         if(Lives == 3)
         {
            Life_1.Show();
         }
         else if(Lives == 2)
         {
            Life_2.Show();
         }
         else if(Lives == 1)
         {
            Life_3.Show();
         }
         Item_Upg_1.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
         PlaySound( "sfx00099.wav");
      }
      else if(Time - PowerupTime >= PowerupLast)
      {
         Item_Upg_1.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
      }
   }
   
   if(Item_Upg_2.IsShowing())
   {
      if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_2))
      {
         SpaceShip.Fuel = 1000;
         Item_Upg_2.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
         PlaySound( "sfx00099.wav");
      }
      else if(Time - PowerupTime >= PowerupLast)
      {
         Item_Upg_2.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
      }
   }
   
   if(Item_Upg_3.IsShowing())
   {
      if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_3))
      {
         //Thruster Bonus
         Item_Upg_3.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
         PlaySound( "sfx00099.wav");
      }
      else if(Time - PowerupTime >= PowerupLast)
      {
         Item_Upg_3.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
      }
   }
   
   if(Item_Upg_4.IsShowing())
   {
      if(SpaceShip.Shell.IsObjectIntersecting(Item_Upg_4))
      {
         Money += MoneyBonus;
         Item_Upg_4.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
         PlaySound("sfx00099.wav");
      }
      else if(Time - PowerupTime >= PowerupLast)
      {
         Item_Upg_4.Hide();
         PowerupTime = Time;
         PowerupOn   = false;
      }
   }

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject: Gulp!
PostPosted: November 21st, 2007, 6:17 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
:shock:

Thx Sandy. I appreciate the extra flw-up finding/posting the code. That's going to require I get some new mental enzymes... to digest that and what you've explained earlier.

Mac,
Excellent! You've brought me just about to the edge of my capacity. Very very useful and very instructive. I think I have a good sense of boundaries for where I want to take this.

Quote:
multiple pages :(

'Okay'... now I'm getting a better sense of organization (what's going on at runtime) regarding Pages. I may want to 'push' that a bit later on... work with Views which I expect will help keep some objects 'alive' from a prior View. ( View ~ Pub window??).

Plenty for me to work on now.

Thanks all. Great help.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 53 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group