Computer Science Canada I need some help on turing... |
Author: | yoimzuup [ Sat Nov 13, 2004 9:51 pm ] |
Post subject: | I need some help on turing... |
Try the code below first. The problem that im having is that it wouldn't bounce back up and then back down when it touches the top, etc. Im wondering if someone could help me fix this problem. Help would be accpreciated. var change : int := 1 var row : int var column : int put "Enter the row" get row put "Enter the column" get column loop setscreen ("nocursor") locate (row, column) put "*" row := row + change delay (200) cls if row = 25 then row := row - change end if end loop |
Author: | wtd [ Sat Nov 13, 2004 11:19 pm ] | ||
Post subject: | |||
Reformatted. Please use code tags.
The asterisk starts off and descends until it gets to row 25, at which point it continues going down, but it also goes up one. The net effect is that it never goes anywhere. What you want to do is, when the asterisk gets to the bottom of the screen, alter the "change". Do the same when it gets to the top of the screen. |
Author: | yoimzuup [ Sat Nov 13, 2004 11:31 pm ] | ||
Post subject: | |||
I can make it go back up but can't make it go on forever. I want it to run forever but I don't know how. Please help me.
|
Author: | wtd [ Sun Nov 14, 2004 12:17 am ] |
Post subject: | |
You're making it too hard. Each time through your loop you clear the screen, draw the pixel, then subtract one from the row to make it go down. So to make it go up without changing that subtraction, you would just change "change", right? |
Author: | yoimzuup [ Sun Nov 14, 2004 12:48 am ] |
Post subject: | |
Sorry, Im getting really confused right now. I tried fixing it many times and I still can't get it right. I was just introduced to turing so Im a newbie. Can someone please fix the code for me? Thanks |
Author: | wtd [ Sun Nov 14, 2004 1:00 am ] |
Post subject: | |
I'm sorry. We sort of don't like to do people's homework for them. Short of that we'll do anything we can to help you, though. And don't worry about being confused, you're a new programmer. Confusion is part of the process. The key to beating confusion is knowing how to tackle problems. Plan out exactly what you need to do first. Attention to details is good. |
Author: | skier [ Sun Nov 14, 2004 12:12 pm ] | ||
Post subject: | |||
try this:
if you have any questions, post |
Author: | wtd [ Sun Nov 14, 2004 2:56 pm ] |
Post subject: | |
Skier, you're still working too hard. Think about math. Think about equations. Factor out the common bits so you don't duplicate code unnecessarily. |
Author: | Mr. Glib [ Sun Nov 14, 2004 3:01 pm ] |
Post subject: | |
wtd wrote: Think about math. Think about equations. Factor out the common bits so you don't duplicate code unnecessarily. wtd!?! Are you serious! You mean to say that programming actually involves math!?! |
Author: | wtd [ Sun Nov 14, 2004 3:04 pm ] |
Post subject: | |
Mr. Glib wrote: wtd wrote: Think about math. Think about equations. Factor out the common bits so you don't duplicate code unnecessarily. wtd!?! Are you serious! You mean to say that programming actually involves math!?! Heh. Often really simple math, and mostly just the basic "math" thought process. Look at my regex tutorials for more examples of thinking like a mathematician in action. |
Author: | yoimzuup [ Sun Nov 14, 2004 3:44 pm ] | ||
Post subject: | |||
Thanks guys, I think I understand now For the skier code, you can take of the
and it would still work |
Author: | zylum [ Sun Nov 14, 2004 7:05 pm ] | ||
Post subject: | |||
i believe this would be the easiest method:
|
Author: | wtd [ Sun Nov 14, 2004 11:36 pm ] | ||
Post subject: | |||
zylum wrote: i believe this would be the easiest method:
+10 bits. |