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

Username:   Password: 
 RegisterRegister   
 how to make objects move on turing depending on the input
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bigpotato




PostPosted: Mon Apr 07, 2014 9:34 pm   Post subject: how to make objects move on turing depending on the input

What is it you are trying to achieve?
i have to make a object move on turing depends the the letters i type in, for example if i type u or U the objects would move up by 20 pixels, and if i type d, or D the object would move down by 20 pixels, the same goes for r,R,l, and L. the input has to be a single string, if the user typed any of the 8 valid directions in the string, the object would move in that direction, if the input is invalid, then the objects don't move. the movment is done one after another , which means if there were 2 valid directions in the string, the object would move in the first direction, and from there it will move to the next


What is the problem you are having?
i dont know how to do what i described.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Mon Apr 07, 2014 10:27 pm   Post subject: RE:how to make objects move on turing depending on the input

Can you:

1. Get input from the user and determine what kind of input they gave (U, D, L, R, etc)?
2. Represent the position of an object with coordinates (x, y)?
3. Represent those coordinates in variables?
4. Draw the object based on those coordinates, no matter what value they have?
5. Change the coordinates and redraw the object, over and over again?

You should be able to do all of those things pretty easily. If you put them together correctly, you'll be able to move an object around by typing.
bigpotato




PostPosted: Mon Apr 07, 2014 11:07 pm   Post subject: RE:how to make objects move on turing depending on the input

I know how to get the input from the user, but say they entered a string "RTVUGD", how can I make the program ignore the invalid characters and perform the valid directions one after another.
Tony




PostPosted: Mon Apr 07, 2014 11:17 pm   Post subject: Re: how to make objects move on turing depending on the input

bigpotato @ Mon Apr 07, 2014 9:34 pm wrote:
i dont know how to do what i described.

Then describe it in more detail. In enough detail to show that you really understand what it is that you want to do.

A good technique is to simplify the problem down to some very basic case (e.g. "input is a single character"), and then build up the solution from there.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bigpotato




PostPosted: Tue Apr 08, 2014 10:22 am   Post subject: Re: RE:how to make objects move on turing depending on the input

bigpotato @ Mon Apr 07, 2014 11:07 pm wrote:
I know how to get the input from the user, but say they entered a string "RTVUGD", how can I make the program ignore the invalid characters and perform the valid directions one after another.
Tony




PostPosted: Tue Apr 08, 2014 12:12 pm   Post subject: RE:how to make objects move on turing depending on the input

Quote:

how can I ... ignore ...

Can you just not tell your program to do actions in those cases?

Perhaps you are trying to ask something else. Providing a bit of relevant example code with your questions would be helpful.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bigpotato




PostPosted: Tue Apr 08, 2014 8:16 pm   Post subject: RE:how to make objects move on turing depending on the input

Ok so this is what i have right now for moving the object, the only question i have now is how can i make the object move slowly to the direction instead of jumping straight there.

for i:1..length(c)
if c(i) = 'u' or c(i) = 'U' then
y := y + 20
delay(1000)
elsif c(i) = 'd' or c(i) = 'D' then
y := y - 20
delay(1000)
elsif c(i) = 'l' or c(i) = 'L' then
x := x - 20
delay(1000)
elsif c(i) = 'r' or c(i) = 'R' then
x := x + 20
delay(1000)
else
delay(1000)
end if
Tony




PostPosted: Tue Apr 08, 2014 11:00 pm   Post subject: RE:how to make objects move on turing depending on the input

code:

y := y + 20
delay(1000)

hint:
code:

y := y + 10
delay(500)
y := y + 10
delay(500)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
bigpotato




PostPosted: Wed Apr 09, 2014 7:20 am   Post subject: RE:how to make objects move on turing depending on the input

ok thank you
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: