Game Development Community

Need some real real basic help

by Ironbelly Studios · in Torque Game Engine · 02/01/2005 (9:59 am) · 7 replies

Posted this in the public forums by mistake, guess that explains why I haven't got any answers :) So if anyone can give me a helping hand here that would be great

I am a complete newbie. I want to display Hello World on the screen. I copied the
v6 folder inside the torque sdk folder and
renamed it to Example1 then I tried to rebuild
it .All worked fine but at the end it side
main.cs could not be found. Then I made
a main.cs file using trible IDE and saved it
in the Example1 folder. I rebuild again.
This time it just shows the console window
but nothing happens. In the main.cs their
one function that prints Hello World.
This should display Hello World but nothing
happens . Am I missing somthing Please Help

#1
02/01/2005 (10:08 am)
Okay... here's a few hints to help get you started...

-) The easiest thing to do here is to work with the Example directory. Copy/paste that somewhere on your machine.

-) By default, you will be working from example/starter_fps/. In that directory is another main.cs file. open up this one and add this line to it:

exec("helloWorld.cs");


Now, create a new file in example/starter_fps called 'helloWorld.cs'. In that file, put the following code:

function helloWorld()
{
echo("Hello world!");
}



What this will do is that whenever main.cs is run in the /example/ directory, it loads up some MOD's (modifications) to the game. This is the basis of your game. By default it runs starter_fps. So in that directory is another main.cs, which is the first thing it runs when it loads a MOD. Here, we have told that main.cs file to load or 'execute' the script file of helloWorld.cs, which we have also made and added the helloWorld function to.

Now, start up the game. hit the '~' key to bring down the console, and type in:

helloWorld();

You should see "Hello World!" echo'ed to the console, and you're now one step closer to making your own game! =D

Please let me know if you have any other questions!

-Dave C.
21-6 Productions
#2
02/01/2005 (10:11 am)
Another thing I want to comment is that, in torque, the games are run almost entierly from the scripts. The engine only needs to be recompiled if you are adding new code into it, such as for shader effects, lighting effects, or you are adding a new method to one of the existing classes, adding a completly new object, and things like that.

For starting off, you can make an entierly new game without once touching the engine source. =)

I'd reccommend that, if you do want to make a game and you are VERY new to all this, then create one that uses the existing engine code, such as a first person shooter in a Tribes style (to do something like Quake 3 or Doom 3 you really need to add shader code or the Synapse lighting pack), or even a simple board-game / puzzle game.

-Dave C.
#3
02/01/2005 (11:53 am)
Dave, That is something we are definitely learning.. it is all scripting..

We are all very skilled and experienced C++ programmers on the team, so it really threw us for a bit of a loop that we couldn't use any of our skills with this engine and have to re-learn how to program again in the torque script :)

We plan on adding effects in there later, as well as a bunch of other features so hopefully we will put our c++ skills to some good use in the future..

Thanks so much for your reply
#4
02/01/2005 (12:10 pm)
@Ryan: You may actually have gone a bit too far in the breakdown between code and script. One of the most esoteric, and also most important skills Torque developers can learn is knowing how, when, and most importantly why, given a certain functionality requirement, you should do things in script, code, or even possibly external modules/applications.

Scripting is excellent for:

--rapid prototyping and development
--anything that you want "non-C++ programmers" to be able to modify and define: object/bot behaviour, gui handling, events processing, the list goes on and on
--most gameplay specific mechanics
--anything that doesn't require bleeding edge performance: TGEScript is byte code compiled for performance optimization, and the method of scripting can be incredibly fast--I know of real time oil well platforms that are monitored and operated using a byte code compiled scripting language (TCL). I also know of literally thousands of hospitals that handle data management and distribution through dozens to hundreds of dissimilar applications using TCL as well.

Code is excellent for:
--functionality that is truly "bleeding edge performance"
--implementing functionality that is needed by scripters (they can only do what you let them via console methods)
--implementing systems that provide your game mechanics functionality (which would then most likely be modified by your scripters)

You can of course do everything in code--nothing at all is stopping you. However, as I mentioned above, knowing when, and most importantly why is what you should focus on!
#5
02/02/2005 (1:39 am)
HI,
WE created a file called helloworld.cs containing the following code :

function helloworld()
{
echo("Hello World");
}

We created this file in the starter.fps folder.
Then we added this line of code :
exec("helloworld.cs");

at the first line of the main.cs file in starter.fps folder

Then we executed the torqueDemo_DEBUG.exe file in the example folder(just above the starter.fps folder). Then when the game started we brought the console window and typed helloworld();

Nothing happened. It showed function could not be found.

My question is what do i need to do if I just want to print "hello world" on the main game screen and not on the console window.

Please help.
thanx
ryan
#6
02/02/2005 (1:53 am)
Create a GuiTextCtrl in the Gui Editor and set the text to whatever value you need. You can't print directly to the main game window from script - it's not really a useful feature for most games. (How many games have you played recently that use OpenGL and have text scrolling in the main interface? :)

You can get a lot of mileage out of the GUI controls, though, and if you wanted to have a console type thing in-game, you could easily do it using some of the GUI controls in-engine.

Hope this helps!
#7
02/02/2005 (10:58 am)
@Ryan: There are a lot of docs that explain the very thing that you are trying to do. Here is a link to the Torquescript documentation:

www.garagegames.com/docs/torque/general/ch05s02.php

It explains how to do a simple Hello World, explains all of the operators and functions, etc. In addition, there is a very nice explanation of how to implement something in C++ and call it from script. Lastly, there is an explanation of how to get to the C++ documentation.

Did you miss this page? www.garagegames.com/mg/projects/torque1/ It is the Torque Home Page. The emails that we send out when you purchase Torque points it out, but your spam filter may have gotten those emails. Please note that there are a lot of tutorials, articles and links to documentation on that page.

Another useful is tem the functional reference for TorqueScript. It is refered to on the front page of the documentation section, but in case you missed it, here is the link:

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5718