Topic: Need help on creating game object using script
by Simon Shum · in Torque Game Engine · 03/07/2007 (2:07 am) · 0 replies
Dear all,
I try to create my map using script (putting in game object through script, not by using the internal editor). I first setup an array, then define the game object, finally put into the map like this:
Exec("./map/initMapLd.cs"); //for setting up the array
...
function InsertBattleLand(%locX, %locY, %boxType , %level)
{
switch(%boxType)
{
case 1:
%land = new StaticShape() {
datablock = Grass;
rotation = "0 0 1 0"; // initialize the values
....
}
%land.setTransform( " " @ 98-%locX*2 @ " " @ 0+%locY*2 @" " @ 70+(%level-1)*1 @ " 0 0 0 0");
MissionCleanup.add(%land);
// Player setup
return %land;
}
The script works and the map is built (game object filling up the space). However, the video memory will fill up very quickly because each game object is treated as a new object (identical texture map will be used many times).
How can i fix that problem? Is there anyway around using this method? I'm a very inexperienced programmer so please bear with me with this question. Any suggestion is welcome. Thanks a lot!!
SS.
I try to create my map using script (putting in game object through script, not by using the internal editor). I first setup an array, then define the game object, finally put into the map like this:
Exec("./map/initMapLd.cs"); //for setting up the array
...
function InsertBattleLand(%locX, %locY, %boxType , %level)
{
switch(%boxType)
{
case 1:
%land = new StaticShape() {
datablock = Grass;
rotation = "0 0 1 0"; // initialize the values
....
}
%land.setTransform( " " @ 98-%locX*2 @ " " @ 0+%locY*2 @" " @ 70+(%level-1)*1 @ " 0 0 0 0");
MissionCleanup.add(%land);
// Player setup
return %land;
}
The script works and the map is built (game object filling up the space). However, the video memory will fill up very quickly because each game object is treated as a new object (identical texture map will be used many times).
How can i fix that problem? Is there anyway around using this method? I'm a very inexperienced programmer so please bear with me with this question. Any suggestion is welcome. Thanks a lot!!
SS.