Game Development Community

Something that would help me

by rennie moffat · in Torque Game Builder · 11/18/2009 (2:11 pm) · 31 replies

(%i = getWordCount(%this.pulseAni.animationFrames) - 1; %i >= 0; %i--)


This line of code says that %i = getWordCount of %this.pulseAni.animationFrames.

The animationFrames is a predefined set for pulseAni?

However, from here it is told to have a -1, integer I am guessing which would tell the animation to move backwards or start at frame = -1 (not sure).

%i >= 0, and %i-- say that %i can not be less than 0, however the %i-- is telling the animation to move backwards. So I am not sure why %i is >= 0.




This is my thinking when looking at this line. Please if someone can help me think through this I would much appreciate it. You guys are the best when it comes to this. 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.

Page«First 1 2 Next»
#21
11/20/2009 (1:22 pm)
Quote:
Everything okay up to this point? Okay, now we're going back to the original code:

view plainprint?
%i = getWordCount(%this.pulseAni.animationFrames) -1;

animationFrames is a method which, then it is called, returns the number of frames.
Let's assume that pulseAni is an animation with 10 frames.

%i will be assigned the number of frames of %this.pulseAni (that is equal 10 in our example), minus 1.

After that line of code, %i will be equal to 10 - 1, that is 9.


So does -1 imply whatever the "number/count" is, subtract one to get the array position?



Ps. this is great, I am going to go over the rest of this in a minute but that is my first question.

Thanks Seb.
You dah Man!!!!!





#22
11/22/2009 (12:02 pm)
@Pubily.
Thanks

@all
Thanks.



after going over this... so I do have a general question, these conditions of
- 1; %i >= 0; %i--
can and do only exist is a for statement?

also would this pattern be consistent for all getWordCount commands.
- 1; %i >= 0; %i--,
where -1 is the final amount, when reached loop ends?
where %i >=0 is the condition for %i?
%i-- is the pattern, additive subtractive for the loop to count. Tells the loop to count up or down basically. Can you with this multiply of divide? would there be any purpose to that?









#23
11/22/2009 (12:13 pm)
Quote:
The first one is the initialization.
The second one is the condition.
The third one is the iteration.


I see, thanks @Seb.
You can see you just asked this above. So I Was pretty much right.

And I have noticed that the for() statement is a pretty important player in game programming. I am sure now, it gets used frequently. As Seb has pointed out it can be used to gauge ammunition, health, damage and I am sure many other things that I cant think of right now. But thanks again, I really do feel I have a grasp on this now.


Thank you so much,
Ren




#24
11/23/2009 (4:24 am)
William is "dah man" actually.
Thank you for pointing out my error, William.
That's what I get for doing this quickly at work without checking about things I haven't checked for years ;)

Rennie, I urge you to read William's post, too as I was totally wrong on getWordCount().
#25
11/23/2009 (10:02 am)
oh, but the basic principle is right right?

I hope all that you wrote and I reviewed is not completely useless.





I doubt that is the case, it was just because of the underscore right? And yes I believe I got what William was saying about getWordCount not knowing anything about animations, just how to get,particular info, ie, the number of frames used.
#26
11/23/2009 (10:15 am)
underscore? Er... what are you taking about?
#27
11/23/2009 (10:20 am)
oh just thinking briefly,
I believe you titled it this_animation or something like that, i thought that was the problem, will have to relook. I thought maybe torque would not understand the underscore.
#28
11/23/2009 (3:15 pm)
getWordCount only returns the number of words in a string.

It can't get you any particular information. You cannot use it to access arrays.
#29
11/23/2009 (3:19 pm)
@ William
Thank you.






I imagine the exact same can be said for getWord.


#30
11/23/2009 (3:20 pm)
However wordCount is words in a string while getWord is numbers?
#31
11/23/2009 (3:32 pm)
getWord gets a single word from a string and returns it as a string.

getWord doesn't know about numbers. getWord doesn't know what's in the string. getWord doesn't care.

getWord simply gets a single word from the passed in string and returns the result as a string.
Page«First 1 2 Next»