xmoonproductions.org
https://www.xmoonproductions.org/

Example: Dynamic Object Creation
https://www.xmoonproductions.org/viewtopic.php?f=28&t=773
Page 1 of 1

Author:  xpadmin [ Tue Sep 17, 2013 3:17 pm ]
Post subject:  Dynamic Object Creation

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 9990 times ]


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


Attachment:
screenshot3.jpg
screenshot3.jpg [ 219.85 KiB | Viewed 9990 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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/