Digital Workshop

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: How do OOP objects get displayed on a Page
PostPosted: April 7th, 2009, 11:13 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
I think I am missing seeing something that might be obvious or simple once clarified.

I am trying to learn and use OOPs as outlined in some examples in earlier Post.
viewtopic.php?t=3001

For example, the BouncingBall
Code:
myVectors[x] = new BouncingBall()

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.


and from the Lander script
Code:
   SpaceShip = GetSpaceShip();    //statement resides in some earlier function

   SpaceShip.Shell.Show();   //also later in the same 'earlier function'


function GetSpaceShip()
{
   var Vessel = new Object;
   Vessel.Shell = GetCurrentShip();        //statement invokes another function below
   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.Fuel = FuelTank;
   
   return Vessel;
}


function GetCurrentShip()
{
   return Ship;
}


So I have some questions: (maybe can be answered all together)
1) How does the BouncingBall object get displayed. That is, does it remain an abstract 'thing' or is it anything the User could see and interact with?
2) I can successfully test for myVectors[1]'s dot properties, but fail to get a result with something like: myVectors[1].GetType()
3) when to use/not-use keyword new
e.g. someVarOrObject = new BouncingBall()
but in the other case,
SpaceShip = GetSpaceShip(); //without the 'new'

4) For Lander especially, but also for BouncingBall example, are there certain required Host Objects that need to be created on the page first? What are they (don't need all, just a few to clarify)?

5) On a couple of the Lander statements:
SpaceShip.Shell.Show() --- what is there to show? Or rather, does this match-up to some host object? How?
return Ship; --- I could not find any other reference to 'Ship' in the script itself

BTW, I am not trying to run the Lander game. I just want to pick out OOPs pieces to learn how to write.... working scripts.

Thanks.much

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


Top
 Profile  
 
 Post subject:
PostPosted: April 17th, 2009, 6:32 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
//The object is the Array Cell IE myVectors[0] is an object with the above properties and myVectors[1] is the next object.

Not exactly. myVectors[0] is an array cell for holding something. The thing that it holds is an object - user object to be precise. It's intangible, in the respect that it is not displayed on screen like a host object.

new is used to create an instance of an object whether user defined or native without you have simple assignment left equal right which is for different OOP purpose.

As for the order of things, yes in the version of EMCA we use for OpusScript object order is import but I believe not so after v1.2 - might be wrong about the version.

Not sure about the show bit, would have to look at the full script.

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: April 18th, 2009, 12:27 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Okay, found whole script - thanks Sandyn.

The reason for not using new is that it's being interpreted as a procedure not a constructor. Seems whoever wrote the script hit the wall of assigning a host object to a property of a user object in the assignment function or had a particular reason for having 'Landing' as a procedure rather than an instance.

Would be interesting to see the original IMP.

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


Last edited by mackavi on April 18th, 2009, 9:36 am, edited 4 times in total.

Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 18th, 2009, 8:24 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
Okay. Thanks Mack... for taking the time and for sharing your experience.

I played around some. Trying things one way or another to see what works, and arrived at some (interim) conclusions. I may have to 'eat' these words and correct them later.

- I assume most of the Lander script examples have a corresponding host object.
- I am still trying to get my mind around how the keyword 'this' is being used in these constructs. (if I can call them constructs). As in the BouncingBall example, it seems the 'this' is FORWARD POINTING to the new Object yet to be created. ?
- I experimented with 'new' keyword. And I am starting to see it now. 'Yes', thanks... "instances". Sometimes the constructing statement is inside a function and sometimes not. If it is 'inside', then do not use 'new' keyword in front of the functionname when calling it. That would be redundant (and not work). Reminds me of a book: "The New New Thing" ;)
- regarding my 'Show()' question, I am assuming there was a host object and that it has an initial state of 'hidden' which is inherited in the created object.
- re: "myVectors[0] is an array cell for holding something." So by referring to the array cell, I manipulate some object and its properties.

Which prompts me to think another question: "What can I store in a DB outside of the Pub?" - I guess I can store data 'about' the object, but not the object itself. And I will have to detail every piece of data explicitly (no properties will get stored unless the SQL code handles the assignment).


This whole realm of OOPs has now gotten to be my critical path. Doesn't make sense to move forward with the current Pub until I master this. Or at least understand its implications: match-up page host-objects to OOPs objects; make a design decision on populating CONTENT to where? (host-objects, OOPs objects, or Cloned objects); and of course building functions for those 'super-Arrays', DB I/O.

As a footnote, it seems to me the Lander script (and other Pubs) could just as easily have used Cloned-objects. So I wonder if there is something MORE that OOPs code brings to the game that clones cannot.

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


Last edited by Lar_123 on April 18th, 2009, 8:25 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: April 18th, 2009, 8:25 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I have attached two files. LanderImp.Zip, which is the IMP and resource folder. Also Lander.Zip, which is just the EXE file zipped.

It's a very interesting example of some very slick scripting. I think this is the best example of OOP with Opus.

If you want some very useful reading on Javascript OOP and how it compares to Java, C# and C++ have a look here
http://www.codeproject.com/KB/aspnet/JsOOP1.aspx
This will explain a lot of the lander script.

Sandy


You do not have the required permissions to view the files attached to this post.

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: April 18th, 2009, 8:32 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 Sandy.
Will take a look too. Seeing the Lander/Ship in operation, and confirming what is a host object is a valuable piece.

I have looked at several JS and other language examples, and I find it very difficult at times to see beyond the syntax differences. Or rather I should say, it helps to see JS code and get a partial picture, but actually trying to go from there to implementing in OpusScript is very much 'uphill'.

Thx.

[Edit:] okay. Can see and confirm which are the host objects. Can see page = Game in the Organizer (but nothing visible in the Opus v6.4 Editor page display).

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


Top
 Profile  
 
 Post subject:
PostPosted: April 19th, 2009, 10:27 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Sandyn,

Thanks for posting the lander game. I've seen the script before, but never played the game.

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: April 19th, 2009, 1:37 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
It ran first time for me, then when I tried it again, it wouldn't, but I haven't looked to see why.

Sandy

_________________
Whoever designed this, never actually used it!


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