SPC (X,Y)
by rennie moffat · in Torque Game Builder · 08/04/2009 (7:58 am) · 24 replies
Hi I am doing some position type coding and have come across "SPC" repeatedly.
An example would be....
(x, SPC y)
It seems to sit in between the X and Y. I am just trying to figure out what this is.
An example would be....
(x, SPC y)
It seems to sit in between the X and Y. I am just trying to figure out what this is.
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.
#3
08/04/2009 (8:58 am)
thanks, it is a "concatenation with space", Defined as a series of events along a line so to speak, so it is the recognition of the software of an objects movement along a line essentially.
#4
Actually, it's just a way of inserting a space into a string, and has nothing to do with movement of an object.
The echos will look like:
this word
thisword
With the difference being that SPC joins the two strings with a space inserted between them, while @ joins the two strings without inserting anything.
In the case of %x SPC %y, most coordinates in script are passed as strings that are space-separated ("x y z" or "10 45 3.2" for example).
08/04/2009 (7:41 pm)
Quote:so it is the recognition of the software of an objects movement along a line essentially
Actually, it's just a way of inserting a space into a string, and has nothing to do with movement of an object.
%x = "this"; %y = "word"; %spaced = %x SPC %y; %notspaced = %x @ %y; echo(%spaced); echo(%notspaced);
The echos will look like:
this word
thisword
With the difference being that SPC joins the two strings with a space inserted between them, while @ joins the two strings without inserting anything.
In the case of %x SPC %y, most coordinates in script are passed as strings that are space-separated ("x y z" or "10 45 3.2" for example).
#5
09/28/2009 (12:33 pm)
what about when we are dealing with numbers as opposed to words? I am expecting a mathematical action, but what, if any? add, subtract...?
#6
5 SPC 6 == "5 6"
09/28/2009 (9:15 pm)
Has Ted said, it's a "concatenation with space" operator. the output will always be a string.5 SPC 6 == "5 6"
#7
getword(Xequation 0) SPC getWord( Yequation 1)
So in essence I could have
3+5 4-7
8 (-3)
Correct?
09/28/2009 (9:46 pm)
Ok so if I needed to do an addition, I would do something like getword(Xequation 0) SPC getWord( Yequation 1)
So in essence I could have
3+5 4-7
8 (-3)
Correct?
#8
SPC is a SPACE concatenation string operator. Its just synthetical sugar for doing
"5" @ " " @ "6" == "5 6"
"5" SPC "6" == "5 6"
It has nothing to do with any math operations what so ever.
%newVal = getWord(Xequation, 0) - getWord( Yequation, 1); // <-- subtraction
09/29/2009 (1:36 pm)
Incorrect, SPC is a SPACE concatenation string operator. Its just synthetical sugar for doing
"5" @ " " @ "6" == "5 6"
"5" SPC "6" == "5 6"
It has nothing to do with any math operations what so ever.
%newVal = getWord(Xequation, 0) - getWord( Yequation, 1); // <-- subtraction
#9
One thing reaurding getWord()
if I getWord(%this.thing, 0)
Does that set %this.thing to whatever 0 is?
So say in my case I want to set worldLimits. As such I have a moving camera which will set the limits of the player. In other words, X is constantly moving positively up.
I need to use this command
%this.getCurrentCameraPosition(%this.getWord(CPX, 0) SPC (%this.getWord(CPY, 1));
getCurrentCameraPosition calls back a vetor (x, y), I want x (which is constantly changing) to be represented by the variable unknown CPX. As I have written it, do you think this is wise?
09/29/2009 (3:27 pm)
Thanks,One thing reaurding getWord()
if I getWord(%this.thing, 0)
Does that set %this.thing to whatever 0 is?
So say in my case I want to set worldLimits. As such I have a moving camera which will set the limits of the player. In other words, X is constantly moving positively up.
I need to use this command
%this.getCurrentCameraPosition(%this.getWord(CPX, 0) SPC (%this.getWord(CPY, 1));
getCurrentCameraPosition calls back a vetor (x, y), I want x (which is constantly changing) to be represented by the variable unknown CPX. As I have written it, do you think this is wise?
#10
www.garagegames.com/community/forums/viewthread/98953
I think people have been very patient, but at this point it looks like you are trolling or being willfully ignorant. Please, with all your mind, try to understand what you've already been told before posting.
09/29/2009 (3:51 pm)
Really?www.garagegames.com/community/forums/viewthread/98953
I think people have been very patient, but at this point it looks like you are trolling or being willfully ignorant. Please, with all your mind, try to understand what you've already been told before posting.
#11
I have looked, I don't think a board should be about complaining. If you do not like my questions please do not answer. I do appreciate your help tho. I am learning. I posted this code, as I wrote it, somewhat freestyle. If you think for one second I am being lazy or stupid, please refrain.
I am simply still getting the in and outs, my specific question was wether I can create a variable, place it with in the bracket comma 0, 1, 2, 3 what have you.
Essentially wondering if this makes sense. I wasn't expecting a lecture.
I appreciate your link. I looked at it, but it does not answer something I want to know, and that is, can I create my own variable, something that isnt a Torque script standard/base code, i.e., worldPos, currentTile etc.
09/29/2009 (5:33 pm)
yes really, I have looked, I don't think a board should be about complaining. If you do not like my questions please do not answer. I do appreciate your help tho. I am learning. I posted this code, as I wrote it, somewhat freestyle. If you think for one second I am being lazy or stupid, please refrain.
I am simply still getting the in and outs, my specific question was wether I can create a variable, place it with in the bracket comma 0, 1, 2, 3 what have you.
Essentially wondering if this makes sense. I wasn't expecting a lecture.
I appreciate your link. I looked at it, but it does not answer something I want to know, and that is, can I create my own variable, something that isnt a Torque script standard/base code, i.e., worldPos, currentTile etc.
#12
To quote:
What would you expect this to do? Would it magically find a string out there, take the "0" of it, and put it into the variable "%this.thing"?
You clearly wasted other people's time by not even trying to understand what getWord does.
I've been following your posts for several days. All put together, I know what you're trying to do, and I know how to do it. It's no more than 6 or 7 lines of code.
Tell me what the following lines of code do (Research! You have the source code!), and I'll willingly help you. Assume that the object "XYZ" is a t2dStaticSprite.
I won't be back until tomorrow, so don't take my silence as disapproval. I want to help the community, but I want my help to not go to waste.
09/29/2009 (6:07 pm)
Whenever you say "this is what I expect", it makes me cringe. (And you say it a lot.) Programming a computer isn't about what you expect. It's about learning the language and putting the pieces together logically.To quote:
Quote:
if I getWord(%this.thing, 0)
Does that set %this.thing to whatever 0 is?
What would you expect this to do? Would it magically find a string out there, take the "0" of it, and put it into the variable "%this.thing"?
You clearly wasted other people's time by not even trying to understand what getWord does.
I've been following your posts for several days. All put together, I know what you're trying to do, and I know how to do it. It's no more than 6 or 7 lines of code.
Tell me what the following lines of code do (Research! You have the source code!), and I'll willingly help you. Assume that the object "XYZ" is a t2dStaticSprite.
// The most difficult... save it for later. XYZ.enableUpdateCallback(); %area = sceneWindow2D.getCurrentCameraArea(); %position = XYZ.getPosition(); // Assume the following lines happen all at once. // What would each value equal? %posX = getWord( "25 49", 0 ); %posY = getWord( "25 49", 1 ); %posXL = getWord( "25 35 1025 1035", 0 ); %posXR = getWord( "25 35 1025 1035", 2 ); %newPosition = %posXL SPC %posY;
I won't be back until tomorrow, so don't take my silence as disapproval. I want to help the community, but I want my help to not go to waste.
#13
Obviously programming is a very finicky thing, and one can only "expect" the right answer if the information is correct.
yes I understand what getWord does, fully, what I do not is can I, if you read my question properly, is, can I, does it compute, does it make sense, to put something like getWord(%this.myOwnMadeUpVariable, 0)
Where when 0 is called somewhere else myOwnMadeUpVAriable is say an equation from another statement. The reason I am thinking of it like this is because my biggest task is to get a worldLimit set up for my player where the X (left and right, middle too if you want) is constantly changing, becasue the camera is moving.
So I want to call my variable equation at some points, which will be my left for one equation and my right for another. Thats why I am wondering if I plug in..
getWord(%myOwnSpecialEquation, 0)
if 0 will call myOwnSpecialVariable which was made up elsewhere in my work.
As per your code, and help thank you. Belive me, neither is going to waste. I have gathered everyting you have taught me and I do belive you have been one of the more helpful to me on the board, so no worries there as I would like it to continue.
My only question regarding your code is,
%posX = getWord("25 49", 0)
where, perhaps I am confused or missing something, but my biggest concern is having this, these as a variable, something that is constantly moving up.
You see what I mean?
09/29/2009 (6:35 pm)
well I apologize if when I say I expect, but when I say that I mean more closely perhaps, this is what I want to happen. Obviously programming is a very finicky thing, and one can only "expect" the right answer if the information is correct.
yes I understand what getWord does, fully, what I do not is can I, if you read my question properly, is, can I, does it compute, does it make sense, to put something like getWord(%this.myOwnMadeUpVariable, 0)
Where when 0 is called somewhere else myOwnMadeUpVAriable is say an equation from another statement. The reason I am thinking of it like this is because my biggest task is to get a worldLimit set up for my player where the X (left and right, middle too if you want) is constantly changing, becasue the camera is moving.
So I want to call my variable equation at some points, which will be my left for one equation and my right for another. Thats why I am wondering if I plug in..
getWord(%myOwnSpecialEquation, 0)
if 0 will call myOwnSpecialVariable which was made up elsewhere in my work.
As per your code, and help thank you. Belive me, neither is going to waste. I have gathered everyting you have taught me and I do belive you have been one of the more helpful to me on the board, so no worries there as I would like it to continue.
My only question regarding your code is,
%posX = getWord("25 49", 0)
where, perhaps I am confused or missing something, but my biggest concern is having this, these as a variable, something that is constantly moving up.
You see what I mean?
#14
Don't take this as a negative or disrespect. But, you are going to need to brush up on your general programming skills a bit more before you really start to tackle game development. You have some concepts down, but I'm not getting the impression that you have enough of the programming toolkit learned.
You said you understand what getWord does, but then you go on about equations and 0 being called somewhere else. Maybe its just a language barrier.
getWord is a method, and it does only one thing. Given two parameters - the first being a string of data separated by spaces, and the second being a word index it will return the word at that index.
If the first parameter you pass to getWord is "the quick brown fox" and the second parameter is 2, the method would return "brown". the index is zero based, so "the" is the 0th index, and "brown" is the 2nd index.
The reason you see it used heavily in TGB is because vectors are often represented in script as a string of two *words* (I use words loosely as its just a number really), and getWord() is an easy method to use to access the different elements of the vector.
%X = getWord(%vector, 0) will set %X to the first number of a vector, and %Y = getWord(%vector, 1) will set %Y to the second number of that same vector. Assuming the vector was stored like the following: "5 10".
Software engineering is not a finicky thing at all. Its a very structured science blended with an artistic touch.
09/30/2009 (1:40 am)
Rennie, Don't take this as a negative or disrespect. But, you are going to need to brush up on your general programming skills a bit more before you really start to tackle game development. You have some concepts down, but I'm not getting the impression that you have enough of the programming toolkit learned.
You said you understand what getWord does, but then you go on about equations and 0 being called somewhere else. Maybe its just a language barrier.
getWord is a method, and it does only one thing. Given two parameters - the first being a string of data separated by spaces, and the second being a word index it will return the word at that index.
If the first parameter you pass to getWord is "the quick brown fox" and the second parameter is 2, the method would return "brown". the index is zero based, so "the" is the 0th index, and "brown" is the 2nd index.
The reason you see it used heavily in TGB is because vectors are often represented in script as a string of two *words* (I use words loosely as its just a number really), and getWord() is an easy method to use to access the different elements of the vector.
%X = getWord(%vector, 0) will set %X to the first number of a vector, and %Y = getWord(%vector, 1) will set %Y to the second number of that same vector. Assuming the vector was stored like the following: "5 10".
Software engineering is not a finicky thing at all. Its a very structured science blended with an artistic touch.
#15
For now, forget about trying to force what you expect into the code you've seen. Just answer my request above to show you have a foundation. I'll add on that foundation. I promise.
Force yourself to dig through TDN, the documentation that came with TGB, and through the source code itself. I'll admit that the first line is the hardest, so go ahead and work on the easier lines.
Good luck!
09/30/2009 (4:54 am)
Like I mentioned, I've read all of your recent posts and I know what you are trying to accomplish.For now, forget about trying to force what you expect into the code you've seen. Just answer my request above to show you have a foundation. I'll add on that foundation. I promise.
Force yourself to dig through TDN, the documentation that came with TGB, and through the source code itself. I'll admit that the first line is the hardest, so go ahead and work on the easier lines.
Good luck!
#16
but do you see what I am trying to do? obviously. In my mind, I understand getWord(%vector, 0) will call the first vector, but again, I want it to call whatever the vector might be. I am just concerned because in my case, the x vector is constantly changing. Thats why I thought an equation might work. So it calls %equation, which is 0, the first "left, end" as such, 1 will be the right end of the camera view.
I will defn continue reading up, and I understand it is my duty to read up but pointers guidance even code, especially if it is easy for you will help me understand and carry on. Yes, I am a total newb. I have only been programming for a year, a few months of AS, a few months of Xcode and a few months of Torque. So forgive me for being ignorant, its just I have an idea I want to get going ASAP. It is actually almost there. I only have to figure out the world limit code, player animation and a few other things. I have given myself 3-6 months to get this out onto the iPhone. I would like to see that happen. I will continue.
Thanks
09/30/2009 (11:40 am)
ok thanks guys. but do you see what I am trying to do? obviously. In my mind, I understand getWord(%vector, 0) will call the first vector, but again, I want it to call whatever the vector might be. I am just concerned because in my case, the x vector is constantly changing. Thats why I thought an equation might work. So it calls %equation, which is 0, the first "left, end" as such, 1 will be the right end of the camera view.
I will defn continue reading up, and I understand it is my duty to read up but pointers guidance even code, especially if it is easy for you will help me understand and carry on. Yes, I am a total newb. I have only been programming for a year, a few months of AS, a few months of Xcode and a few months of Torque. So forgive me for being ignorant, its just I have an idea I want to get going ASAP. It is actually almost there. I only have to figure out the world limit code, player animation and a few other things. I have given myself 3-6 months to get this out onto the iPhone. I would like to see that happen. I will continue.
Thanks
#17
just looking at your code,
perhaps you can help me to better understand what you have written.
Thanks,
please take these as a serious students questions.
Much appreciated.
09/30/2009 (11:51 am)
William, just looking at your code,
perhaps you can help me to better understand what you have written.
XYZ = anything, a sprite, %this essentially? %area = sceneWindow2D.getCurrentCameraArea(); ///this is brilliant. I never would have thought of this, simply getting the sceneWindow2D in a string (am I correct in calling this a string?) and simply telling it to get the current camera area. But I notice later, in what you wrote, there is no call for %area, as such it seems to me this line of code, as is, is irrelevant. Please fill me in. %position = XYZ.getPosition(); ///simple, but again, why is it not called again (%position), it seems like it would have to be, to really mean anything. // Assume the following lines happen all at once. // What would each value equal? %posX = getWord( "25 49", 0 ); %posY = getWord( "25 49", 1 ); ///this one is tricky to me since posX has 2 values 25 49. why does it not only have one value? %posXL = getWord( "25 35 1025 1035", 0 ); %posXR = getWord( "25 35 1025 1035", 2 ); ///Again, a little confused, Why does posXL have 4 values? Again, I would think it only needs one. Also, shouldn't posXL be 2 and XR be 3?
Thanks,
please take these as a serious students questions.
Much appreciated.
#18
you might consider getting a book such as The Game Programmer's Guide To Torque, and following through the examples in there. It could give you a grasp on some of the fundamentals of torquescript here.
09/30/2009 (2:32 pm)
rennie,you might consider getting a book such as The Game Programmer's Guide To Torque, and following through the examples in there. It could give you a grasp on some of the fundamentals of torquescript here.
#19
The sentence above the code (in post #12) states "Assume that the object 'XYZ' is a t2dStaticSprite".
You are right that "sceneWindow2D.getCurrentCameraArea()" will return a string, but what does it return? You can't give me a real answer, but a sample of what it might return would be sufficient.
And "XYZ.getPosition()" is very simple, but what does it return? Same here... describe what it returns and a sample of that.
09/30/2009 (4:08 pm)
Each line is independent of each other. I'm not trying to outline any code for you here. Just what would %area, %position, %posX, %posY, %poxXL, %posXR, and %newPosition be after each call?The sentence above the code (in post #12) states "Assume that the object 'XYZ' is a t2dStaticSprite".
You are right that "sceneWindow2D.getCurrentCameraArea()" will return a string, but what does it return? You can't give me a real answer, but a sample of what it might return would be sufficient.
And "XYZ.getPosition()" is very simple, but what does it return? Same here... describe what it returns and a sample of that.
#20
so are you saying, the code as you wrote it, may appear to the compiler? as in, it may see these lines? See, what is confusing me a bit is the fact many numbers are being called for an X position.
well,
to answer part 2.
in getCurrentCameraArea() it returns 4 points, the top left xy and bottom right xy of the currentCameraArea
so it may return ( -30 45, 30 -45),
again tho, notation, commas are questionable here. but it does return 4 points.
Also, part 3
it does return a point as well, usually the center point of the sprite itself.
See these thing I do get, I am no fool (not saying you are saying that), just when it comes to plug it all in, I am lacking there.
09/30/2009 (4:41 pm)
I understand that, so are you saying, the code as you wrote it, may appear to the compiler? as in, it may see these lines? See, what is confusing me a bit is the fact many numbers are being called for an X position.
well,
to answer part 2.
in getCurrentCameraArea() it returns 4 points, the top left xy and bottom right xy of the currentCameraArea
so it may return ( -30 45, 30 -45),
again tho, notation, commas are questionable here. but it does return 4 points.
Also, part 3
it does return a point as well, usually the center point of the sprite itself.
See these thing I do get, I am no fool (not saying you are saying that), just when it comes to plug it all in, I am lacking there.
Torque Owner rennie moffat
Renman3000