Game Development Community

Project will not run

by rennie moffat · in Torque Game Builder · 06/16/2009 (10:01 am) · 18 replies

Hi,
dong a step by step tutorial, but I have gotten a glitch when I try to run/test/play the program. A pop up window comes up and says, "initializeProject could not be found"



I am not sure what this means.. well at least technically. Just so you know I have had to load and reload the program (TGB itself) a few times, and I try to leave the one main TGB in my dock, however since I have about a half dozen TGB main software icons in varous folders, (from downloads, not me) I may have selected one or the other, perhaps the wrong TGB?


Very puzzling, please help.

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
06/16/2009 (10:03 am)
The problem has to do with your project's local scripts. Usually this has to do with out of date DSO files or the main.cs file has been modified incorrectly.
#2
06/16/2009 (10:11 am)
hmm,

Well, for this project, I decided to use Torsion demo I think by default it is running thru Crossover, if not, it at least has the same icon, but visually the program (Torsion) looks for Windows 98ish.
#3
06/16/2009 (10:25 am)
my main.cs



function initializeProject()
{
// Load up the in game gui.
exec("~/gui/mainScreen.gui");

// Exec game scripts.
exec("~/gameScripts/game.cs");

// This is where the game starts. Right now, we are just starting the first level. You will
// want to expand this to load up a splash screen followed by a main menu depending on the
// specific needs of your game. Most likely, a menu button will start the actual game, which
// is where startGame should be called from.
startGame( expandFilename($Game::DefaultScene) );
}

//---------------------------------------------------------------------------------------------
// shutdownProject
// Clean up your game objects here.
//---------------------------------------------------------------------------------------------
function shutdownProject()
{
endGame();
}

//---------------------------------------------------------------------------------------------
// setupKeybinds
// Bind keys to actions here..
//---------------------------------------------------------------------------------------------
function setupKeybinds()
{
new ActionMap(moveMap);
//moveMap.bind("keyboard", "a", "doAction", "Action Description");
}










I did notice a difference in the call for game.cs and player .cs. Game, natively had a "~" and in the same place PLayer had "." so I changed and interchanged looked at others, but no fly.


:?



#4
06/16/2009 (10:39 am)
Rrr.


I've noticed a few things, if yo could please tell me, if you can where I may be right or wrong.


Referencing other demos, mainly the shooter I have noticed some differences.


In the shooter, all scripts are called from the main.cs
In the Batty Demo (2D Game Builder Book) the game.cs is called from the main, while the player.cs is called from the game.cs.


Is this irrelevant? I cant think the authors would have screwed that up.


Cheers
#5
06/16/2009 (10:40 am)
ps. just to clarify the main.cs (shooter) does not call ALL scripts, just main ones...
game
player
enemy




All behaviors are called from their respective classes.
#6
06/16/2009 (12:12 pm)
The only relevant thing is that the script is executed before it is used for the first time (including before a level is loaded that uses anything from the script)
#7
06/16/2009 (2:12 pm)
thanks, I understand that,
But my current situation is...

I have called up the main.cs, game/main.cs and the game.cs in a perfectly functioning shooter tutorial and mine, what I have done in my current tutorial. Both are 2D scrollers where there is, as of now a player, enemy and game class all called.



I have looked at each, side by side, and to that extent of those three classes, the scripts are identical.



:?




So why wont mine load?







#8
06/17/2009 (10:14 am)
I have reinstalled it fresh, 174 pro, ans still it says "initialise project" function can not be found.





Que?
last time I checked, this was in the main.cs I believe and it is a simple, pre provided frame work. What gives?
#9
06/17/2009 (12:39 pm)
I have just loaded the full demo from the CD Rom provided (2D Game Builder) and it does not load either. This is very weird, but if anyone has any serious insight I would much appreciate it. thank you, to this point you all have been great.

ren
#10
06/17/2009 (4:11 pm)
Are you using large images (500 x 500+)? Without proper drivers, pcs will fail to load a game with high res graphics, and macs will run the game, but not load the images.
#11
06/17/2009 (4:33 pm)
hmm,
i will look into it in a bit. I am offline for the next couple of hours tho. I do run on a mac tho, and the problem was images not loading, it was that it would not "initialize project" as it could not find that function.


:?
#12
06/18/2009 (8:00 pm)
hi,
just to keep you all up to date, with these perceived malfunctions, I have wittled in down to it must be the code i am using, as today I was doing the PlatformerMovement Tutorial, and I added certain basic script to the player, including gravity and that was it, and I ran the game, it loaded.

What I saw was the screen. with the player, and instantly he the player, began to fall. Gravity was acting on him. That was it, I was happy and carried on. I added the rest of the tutorials script until I checked it again. At that point, it did not load.




:?
ANy thoughts, I would love to figure this out as soon as possible, so any continued thoughts are appreciated.



#13
06/18/2009 (11:59 pm)
Rennie, make sure you remove any spaces in the path name to your project folder. Torque doesn't like spaces in its command line arguments (which are used to load a project from the TGB editor).
#14
06/19/2009 (9:07 am)
ok, so extra folders you mean? or in the title name,
both are clear (no spaces I believe)




#15
06/19/2009 (9:10 am)
I am just wondering now,
but if something is declared but not defined, ay missing links, no matter how matter, would a program not run because of that?




#16
06/19/2009 (9:12 am)
just in case I will post the scripts, that may help determine the bug,



my game.cs
___

function startGame(%level)
{
exec("./player.cs");
moveMap.push();

if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
}

function isRunSurface(%normal, %maxAngle)
{
if (getWord(%normal, 1) > 0)
return 0;

%angle = mRadToDeg(mAsin(getWord(%normal, 0)));

if (mAbs(%angle) < %maxAngle)
return 1;

return 0;
}
// Set The GUI.
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);
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();
}

#17
06/19/2009 (9:13 am)
player.cs





// Player movement functions
moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");

function player::onLevelLoaded(%this, %scenegraph)
{
// Define the player global variable
$player = %this;

// Get the value of gravity from the Level Builder
%force = $player.getConstantForce();
$gravity = getWord(%force, 1);

// Player movement functions
moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");
}

function playerLeft(){
$player.moveLeft = 1;//true
}

function playerLeftStop()
{
$player.moveLeft = 0;//false
}

function playerRight()
{
$player.moveRight = 1;//true
}

function playerRightStop()
{
$player.moveRight = 0;//false
}

function playerJump()
{
//echo("nothing here yet!");
}
$player.runSpeed = 40; //speed of the player
$player.airSpeed = 16; //speed it can move when in the air
$player.jumpHeight = 10; //height it can jump
$player.maxRunSurfaceAngle = 35; //maximum steepness of a ramp that that the player can run on
$platformGroup = 2; //I'm doing this because i don't know how to get a Tile Map GraphGroup :-.
$playerGroup = $player.getGraphGroup();

function t2dSceneObject::onCollision(%srcObj, %dstObj, %srcRef,
%dstRef, %time, %normal, %contactCount, %contacts)
{

switch (%srcObj.getGraphGroup())
{
case $playerGroup:
//the source of the collision is the player
switch (%dstObj.getGraphGroup())
{
//the destiny is the plataform
case $platformGroup:
collidePlayerPlatform(%normal);
}
}
}
function collidePlayerPlatform(%normal)
{
%move = $player.moveRight - $player.moveLeft;
$player.setLinearVelocityX(%move * $player.runSpeed);
}



function collidePlayerPlatform(%normal)
{
%move = $player.moveRight - $player.moveLeft;
$runSurface = isRunSurface(%normal, $player.maxRunSurfaceAngle);
if ($runSurface > 0)
{
$player.setLinearVelocityX(%move * $player.runSpeed);
}
}



function playerJump()
{
$player.setLinearVelocityY(-10 * $player.jumpHeight);
}

function t2dSceneGraph::onUpdateScene(%this)
{
if (%this != t2dscene.getID())
return;

updatePlayer();
$runSurface = -1;
}


function updatePlayer()
{
if ($runSurface > 0)
{
if ($jump)
playerJump();
}
}



#18
06/19/2009 (9:15 am)
main.cs


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

//---------------------------------------------------------------------------------------------
// initializeProject
// Perform game initialization here.
//---------------------------------------------------------------------------------------------
function initializeProject()
{
// Load up the in game gui.
exec("~/gui/mainScreen.gui");

// Exec game scripts.
exec("./gameScripts/game.cs");

// This is where the game starts. Right now, we are just starting the first level. You will
// want to expand this to load up a splash screen followed by a main menu depending on the
// specific needs of your game. Most likely, a menu button will start the actual game, which
// is where startGame should be called from.
startGame( expandFilename($Game::DefaultScene) );
}

//---------------------------------------------------------------------------------------------
// shutdownProject
// Clean up your game objects here.
//---------------------------------------------------------------------------------------------
function shutdownProject()
{
endGame();
}

//---------------------------------------------------------------------------------------------
// setupKeybinds
// Bind keys to actions here..
//---------------------------------------------------------------------------------------------
function setupKeybinds()
{
new ActionMap(moveMap);
//moveMap.bind("keyboard", "a", "doAction", "Action Description");
}