Sprite Placement By $row / $column
by Arland (Barry) Woodham · in Torque Game Builder · 04/15/2005 (7:48 pm) · 4 replies
Ok lets see if I can make this understandable. I am trying to setup a gameboard and place pieces and as such I want to place them via a grid. For example here is the code for three pieces as it stands currently. The two // lines were added because [.code] doesn't seem to like empty lines.
So anyone have some ideas? It is probably something simple I am overlooking so here's hoping.
// --------------------------------------------------------------------
// Create Musketeers.
// --------------------------------------------------------------------
function CreateMusketeer()
{
$Musketeer = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$Musketeer.setPosition("0 0");
$Musketeer.setSize( "10 10");
$Musketeer.setImageMap( musketeerImageMap );
$Musketeer.isSelectable = true;
//
$Musketeer = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$Musketeer.setPosition("20 -20");
$Musketeer.setSize( "10 10");
$Musketeer.setImageMap( musketeerImageMap );
$Musketeer.isSelectable = true;
//
$Musketeer = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$Musketeer.setPosition("-20 20");
$Musketeer.setSize( "10 10");
$Musketeer.setImageMap( musketeerImageMap );
$Musketeer.isSelectable = true;
}As you can see the three pieces will share the same properties and as such I want to put the creation into a for loop only changing this line.$Musketeer.setPosition("20 -20");What I have attempted is to declare two variables that are $row and $column and then try to use them in place of ("20 -20") above. Now I know the variables are holding the values by way of using the echo command however the code below doesn't seem to work as expected.$Musketeer.setPosition($row $column);The sprite is created but instead of being at the intended position it is at the origin.
So anyone have some ideas? It is probably something simple I am overlooking so here's hoping.
About the author
#2
Thanks that works great. May I ask what excatly does the SPC do?
***EDIT*** Duh I see it now SPC is space makes perfect sense now.
04/15/2005 (8:04 pm)
Wow so quick this community is Great!Thanks that works great. May I ask what excatly does the SPC do?
***EDIT*** Duh I see it now SPC is space makes perfect sense now.
#3
$row = 20;
$column = 20;
if you were to
There are a few other string manipulators, although they escape me at the moment. :-/
edit: Heh, looks like you figured it out. :)
04/15/2005 (8:12 pm)
SPC simply appends whatever it is between, with a space separating them, so:$row = 20;
$column = 20;
if you were to
echo($row SPC $column);the console would show
Quote:20 20
There are a few other string manipulators, although they escape me at the moment. :-/
edit: Heh, looks like you figured it out. :)
#4
**Does Happy Dance**
So here's a pic to show what I did with it.
What I am doing is to recreate a boardgame, that we studied in my concept development class several quarters ago. I figured it would be a good choice for the same reasons we used it in class.
1. Simple rules
2. Asymetrical gameplay
3. Possible to expand upon original design
So I am working on recreating the original version to help me learn t2d and will probably add basic ai for both sides. After that I may add the enhancements that we made upon it in class but well just have to see. Unfortunately I don't have as much time to mess with t2d as I want.
04/15/2005 (8:52 pm)
Well I now compressed about 4 pages of code, just copy pasting mostly, into about 2/3 of a page.**Does Happy Dance**
So here's a pic to show what I did with it.
What I am doing is to recreate a boardgame, that we studied in my concept development class several quarters ago. I figured it would be a good choice for the same reasons we used it in class.1. Simple rules
2. Asymetrical gameplay
3. Possible to expand upon original design
So I am working on recreating the original version to help me learn t2d and will probably add basic ai for both sides. After that I may add the enhancements that we made upon it in class but well just have to see. Unfortunately I don't have as much time to mess with t2d as I want.
Torque Owner Teck Lee Tan
should be