
-----------------------------------
canmovie
Mon Sep 27, 2010 11:43 am

Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
What is it you are trying to achieve?
I'm trying to make turing add 5 to the x value every loop, So I don't have to  write the same line over and over again changing the x value to make my animation move horizontally.

What is the problem you are having?
I don't know how to make  Turing add 5 to x every new loop.


Describe what you have tried to solve this problem
I have no idea how to do this.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using
 :!:  :!:  :!:

-----------------------------------
yoursecretninja
Mon Sep 27, 2010 12:41 pm

Re: Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
1. Declare and initialize x prior to entering your loop to make sure that you do not reassign your starting value to the variable.

2. Inside your loop, use the += combined assignment operator. i.e. "x += 5".  This allows you to use a variable's value in an expression and assign it the result back to the variable. This is the same as "x = x + 5". So, for x = 10 : x += 5 -> x = 15.

Now x will increment by five each time your run through the loop.

P.S. I don't know Turing. This is just the logic you would use in pretty much any programming language.

-----------------------------------
Dan
Mon Sep 27, 2010 12:52 pm

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
To put what yoursecretninja stated into pesdo code (none turing code used to only express the logic):

[code]
set screen to offscreen only

x = 0

loop
   clear screen
   x = x + 10
   draw animation at X
   update screen
end loop
[/code]

Note that you should use the offscreen graphics mode turing supports and update the screen manualy at then end of the loop. 


See turing doc for View.set and View.Update: 

http://compsci.ca/holtsoft/doc/view_set.html

http://compsci.ca/holtsoft/doc/view_update.html


Also info on loops in turing:

http://compsci.ca/holtsoft/doc/loop.html

-----------------------------------
TWizard
Tue Oct 05, 2010 12:07 am

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
*deletia*

Mod Edit: Please do not post complete solutions to problems. This is against 

-----------------------------------
TheGuardian001
Tue Oct 05, 2010 4:10 am

Re: Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
Please try not to simply post complete solutions to problems. The goal is to help people accomplish the work, not do it for them.

-----------------------------------
TWizard
Sun Oct 17, 2010 12:47 pm

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
Yea but i find it so much easier. Besides if they really wanted to learn then they can look it up in f10 the guides right there i'm only using what i know didn't know it was such a crime.

-----------------------------------
TheGuardian001
Sun Oct 17, 2010 5:20 pm

Re: RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
Yea but i find it so much easier. Besides if they really wanted to learn then they can look it up in f10 the guides right there i'm only using what i know didn't know it was such a crime.
People tend to frown on Plagiarism.
Posting solutions doesn't help anybody. Nobody will learn from copy-pasting your code. The whole point of this site is that when people encounter problems they can't solve simply using the Help Files, we help them figure it out. Not by doing it for them, by helping them figure it out for themselves.

-----------------------------------
TWizard
Wed Oct 20, 2010 8:52 pm

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
I'm just offering a new way of viewing the solution, in my perspective if you have been given a solution and you are able to use it to something that applies to your work or use it to find other ways of getting around the problems then it would be a better asset.  Yes it is true that people may have to learn on there own to understand how things work im just offering another way around.  And besides it wouldn't be giving the whole answer its the answer that they can use for there problem because giving the exact answer would be to ask for his or her code then fix the problems my self.

-----------------------------------
TheGuardian001
Wed Oct 20, 2010 9:13 pm

Re: RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
And besides it wouldn't be giving the whole answer

They want to know how to draw a picture 5 pixels over every time the loop goes around.

You gave them a program that draws a picture 5 pixels over every time the loop goes around.

Doing their homework for them from scratch is just as bad, if not even worse, than fixing their program for them. If I ask you

How do I find the roots of F(x)=x^2?

The answer is not 0. The answer is set F(x) to 0, and solve for x. Tell them how to do it, don't do it for them. Looking in the back of the book to see the answer might get their homework done, but it won't help them when the test rolls around.

-----------------------------------
Prince Pwn
Sat Oct 23, 2010 2:11 am

Re: RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------

Posting solutions doesn't help anybody. Nobody will learn from copy-pasting your code.

False. I learned how to program by taking source code, modifying it, and seeing how it works. Thanks to that, I now have 2 year computer science diploma.

-----------------------------------
Insectoid
Sat Oct 23, 2010 10:11 am

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
That isn't what TheGuardian001 was implying. He meant 'Nobody will learn from handing in your code' (I assume). 

Everybody has looked at and learned from other people's source, if they try to. Too often it happens that someone will just copy & paste the code into their IDE and hand it in, which teaches nothing.

-----------------------------------
TWizard
Sat Oct 23, 2010 5:59 pm

RE:Add 10 to x every loop URGENT HELP PLEASE
-----------------------------------
Ah right this is an open source site.  I was blatly seeing why people where making a big fuss about it.  I understand And will try not to do it so much.  But thats how i think is just to learn for the awnsers given.
