Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[Tutorial] LOOPs and FOR loops
Author Message

Posted: 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

Aange10

Posted: 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

Posted: 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

 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.
Tony's programming blog. DWITE - a programming contest.
Aange10

Posted: 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

Posted: 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 if counter>=1000 then end if end loop
Aange10

Posted: 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

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: