Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] LOOPs and FOR loops
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
evildaddy911




PostPosted: Mon Oct 17, 2011 3:03 pm   Post subject: Re: [Tutorial] LOOPs and FOR loops

is there any other way to make
Turing:

for i:1..infinity
end for


other than
Turing:

var count:int
count:=0
loop
count:=count+1
%code%
end loop
Sponsor
Sponsor
Sponsor
sponsor
Aange10




PostPosted: Mon Oct 17, 2011 4:53 pm   Post subject: RE:[Tutorial] LOOPs and FOR loops

Well, I'm pretty sure infinity, even for a dynamic array is impossible (hence the maxint command). Though I could be wrong (floating points or some other mumbo jumbo I don't know a lot about.)


But to answer your question, yes. They are called flexible arrays. For an explanation, please read Arrays. Note that it has three different tutorials in the one page. (Arrays, Multi-Dementional arrays, and flexible arrays.) The posts are just separated.


Also, please check the time stamps on these topics. The last post was in 2005. Resurrecting a 6 year old topic is generally looked down upon.
Tony




PostPosted: Mon Oct 17, 2011 4:58 pm   Post subject: Re: [Tutorial] LOOPs and FOR loops

evildaddy911 @ Mon Oct 17, 2011 3:03 pm wrote:
is there any other way to make
Turing:

for i:1..infinity
end for


Sure. How about
code:

for j:2..infinity
   i := j - 1
   ...
end

For some value of "infinity". What are you _trying_ to do?

@Aange10 -- not sure where arrays came from.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Aange10




PostPosted: Mon Oct 17, 2011 5:01 pm   Post subject: Re: [Tutorial] LOOPs and FOR loops

Tony @ 17/10/2011, 3:58 pm wrote:

@Aange10 -- not sure where arrays came from.


Ahh, oops. Sorry, I though he said array, not for Cool
evildaddy911




PostPosted: Tue Oct 18, 2011 2:47 pm   Post subject: Re: [Tutorial] LOOPs and FOR loops

im trying to put a counter on my game so that every 10 seconds or so you can do a special attack, but i think ill stick to the
Turing:

var counter:int
counter:=0
loop
counter:=counter+1
<code>
if counter>=1000 then
<special attack>
end if
end loop
Aange10




PostPosted: Tue Oct 18, 2011 4:40 pm   Post subject: RE:[Tutorial] LOOPs and FOR loops

That can be done. If you need help please post in the help section.
Zren




PostPosted: Tue Oct 18, 2011 4:47 pm   Post subject: RE:[Tutorial] LOOPs and FOR loops

Don't forget to reset counter after a special attack. Otherwise it's just a wait period from the start of the game.

Also, I suggest dealing in Time, not a frame counter.

The specific term for what you're wanting is called a cooldown.

Turing:

% Time between attacks. In milliseconds.
var cooldown := 10 * 1000

% Time last attack occured
% Initialized as a negative so we can attack right at the start.
var lastAttack := -cooldown

loop
    var now := Time.Elapsed
    if now - lastAttack >= cooldown then % Check cooldown
        put "Hadoken"
        lastAttack := now
    end if
end loop


If your framerate is fixed, then it should be fine to substitute a frame count instead.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: