Game Development Community

World limits

by Anthony Ratcliffe · in Torque Game Builder · 06/02/2008 (9:07 pm) · 5 replies

I'm making a game where a crusher will go right > across the screen and if it fits its world limit the game is over, however it doesnt seem to reach its world limit it goes through it, i've set it up using the editor and wrote this script

crusher.cs


function crusher::onLevelLoaded(%this, %scenegraph)
{
%this.setLinearVelocityX(%this.maxSpeed);
}


function crusher::onWorldLimit(%this, %mode, %limit)
{
echo ("entering switch function");
switch$ (%limit)
{

case "right":
echo ("right world limit");
leveldie("game/data/levels/end.t2d");
}
}


game.cs // handles the level movment



//---------------------------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------
// startGame
// All game logic should be set up here. This will be called by the level builder when you
// select "Run Game" or by the startup process of your game to load the first level.
//---------------------------------------------------------------------------------------------
function startGame(%level)
{
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);

new ActionMap(moveMap);
moveMap.push();

$enableDirectInput = true;
activateDirectInput();
enableJoystick();

sceneWindow2D.loadLevel(%level);
}

//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}


function leveldie(%nextLevel)

{

if(%nextLevel $= "" || %nextLevel $= " ")
{
%nextLevel = expandPathname("~data/levels/end.t2d");
}


new t2dScenegraph(play_scene) {};
play_scene.loadLevel(%nextLevel);
sceneWindow2D.setScenegraph(play_Scene);
}


any ideas?

#1
06/02/2008 (9:39 pm)
Could you also paste your crusher object as it is defined in your level file.

Note: use {code} ... {/code} to make pasted code easier to read -- replace curly with straight braces.
#2
06/03/2008 (10:59 pm)
%levelContent = new t2dSceneGraph() {
   canSaveDynamicFields = "1";
   UseLayerSorting = "1";
   layerSortMode0 = "Normal";
   layerSortMode1 = "Normal";
   layerSortMode2 = "Normal";
   layerSortMode3 = "Normal";
   layerSortMode4 = "Normal";
   layerSortMode5 = "Normal";
   layerSortMode6 = "Normal";
   layerSortMode7 = "Normal";
   layerSortMode8 = "Normal";
   layerSortMode9 = "Normal";
   layerSortMode10 = "Normal";
   layerSortMode11 = "Normal";
   layerSortMode12 = "Normal";
   layerSortMode13 = "Normal";
   layerSortMode14 = "Normal";
   layerSortMode15 = "Normal";
   layerSortMode16 = "Normal";
   layerSortMode17 = "Normal";
   layerSortMode18 = "Normal";
   layerSortMode19 = "Normal";
   layerSortMode20 = "Normal";
   layerSortMode21 = "Normal";
   layerSortMode22 = "Normal";
   layerSortMode23 = "Normal";
   layerSortMode24 = "Normal";
   layerSortMode25 = "Normal";
   layerSortMode26 = "Normal";
   layerSortMode27 = "Normal";
   layerSortMode28 = "Normal";
   layerSortMode29 = "Normal";
   layerSortMode30 = "Normal";
   layerSortMode31 = "Normal";
   DebugRendering = "0";
      cameraPosition = "0.000000 0.000000";
      cameraSize = "156.285446 117.214081";

   new t2dStaticSprite() {
      imageMap = "imageholderImageMap";
      frame = "0";
      canSaveDynamicFields = "1";
      Position = "0.110 48.431";
      size = "156.506 20.352";
      Layer = "31";
      SrcBlendFactor = "ONE_MINUS_DST_COLOR";
      BlendColor = "1 0.352941 0.313726 1";
         mountID = "2";
   };
   new t2dStaticSprite(crush) {
      imageMap = "cruserImageMap";
      frame = "0";
      canSaveDynamicFields = "1";
      class = "crusher";
      Position = "-96.016 -4.194";
      size = "62.032 84.544";
      WorldLimitMin = "-180.000 -58.655";
      WorldLimitMax = "62.734 128.921";
      CollisionActiveSend = "1";
      CollisionActiveReceive = "1";
      CollisionPolyList = "-1.000 -0.005 -1.000 -0.236 0.502 -0.923 0.991 -0.992 1.000 0.904 0.556 0.845";
         maxSpeed = "100";
         mountID = "3";
   };
   new t2dStaticSprite() {
      imageMap = "aaaImageMap";
      frame = "0";
      canSaveDynamicFields = "1";
      Position = "-56.726 48.477";
      size = "20.903 19.145";
         mountID = "4";
   };
};
#3
06/03/2008 (11:28 pm)
You have to specify that you want to receive world limit callbacks for your object.

There is a checkbox for it in the editor or put this in your crush-object definition:
WorldLimitCallback = true;
#4
06/04/2008 (8:34 pm)
Checked callback nothing changing no script errors still goes past world limit
#5
06/06/2008 (9:19 pm)
Just looked into some old code i wrote a while back ran pretty similar to this still nothing tho