View unanswered posts | View active topics It is currently Thu Mar 28, 2024 9:47 am



Reply to topic  [ 1 post ] 
 Example: Dynamic Object Creation 
Author Message
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
Here is an example script that adds objects (in this case 6 sharks) dynamically to a scene:

scene SWIMPOOL
{
shark1_objecti:SHARK SHARK1
{
// The location where the shark is instantiated
waypoint = SWIMPOOL:SHARK1WP;

// The centre of the sharks movement
swim_mp = (17.310,-1.0,-1.155);

// The speed
speed = 8.0;
}

shark1_objecti:SHARK SHARK2
{
waypoint = SWIMPOOL:SHARK2WP;

swim_mp = (17.310,-1.0,-1.155);
speed = 8.0;
}

shark1_objecti:SHARK SHARK3
{
waypoint = SWIMPOOL:SHARK3WP;

swim_mp = (17.310,-1.0,-1.155);
speed = 8.0;
}

shark1_objecti:SHARK SHARK4
{
waypoint = SWIMPOOL:SHARK4WP;

swim_mp = (17.310,-1.0,-1.155);
speed = 8.0;
}

shark1_objecti:SHARK SHARK5
{
waypoint = SWIMPOOL:SHARK5WP;

swim_mp = (17.310,-1.0,-1.155);
speed = 8.0;
}

shark1_objecti:SHARK SHARK6
{
waypoint = SWIMPOOL:SHARK6WP;

swim_mp = (17.310,-1.0,-1.155);
speed = 8.0;
}

waypoint_objecti SHARK1WP
{
pos = (17.310,-0.585,-1.155);
}

waypoint_objecti SHARK2WP
{
pos = (17.310,-0.585,-3.155);
}

waypoint_objecti SHARK3WP
{
pos = (17.310,-0.585,-5.155);
}

waypoint_objecti SHARK4WP
{
pos = (18.310,-0.585,-1.155);
}

waypoint_objecti SHARK5WP
{
pos = (18.310,-0.585,-3.155);
}

waypoint_objecti SHARK6WP
{
pos = (18.310,-0.585,-5.155);
}
}


The shark is derived from its base class:

shark1_object SHARK
{
// The XStoryPlayer object file
file_name = "scenes/apartment1/shark1Shape.obj";

// Its default speed
speed = 1.0;
}


So this is what it looks like:

Attachment:
screenshot1.jpg
screenshot1.jpg [ 194.87 KiB | Viewed 9704 times ]


Attachment:
screenshot2.jpg
screenshot2.jpg [ 260.39 KiB | Viewed 9704 times ]


Attachment:
screenshot3.jpg
screenshot3.jpg [ 219.85 KiB | Viewed 9704 times ]


All available objects can be used in any scene. So in this case the shark from John's apartment is used in the swimming pool.

The shark object its behaviour can be changed for example its speed.


Tue Sep 17, 2013 3:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group.
Designed by X-Moon Productions.