How to make red dots move constantly all at the same time
Author |
Message |
Stephenlol
|
Posted: Sun Jan 17, 2010 6:39 pm Post subject: How to make red dots move constantly all at the same time |
|
|
What is it you are trying to achieve?
I am trying to make a game that is almost exactly like this game. http://www.addictinggames.com/theworldshardestgame.html (very similar to the 2nd level) Except without requiring to get the yellow circles.
I want it so that you are a moving circle or square and if you touch the automatically moving red dots you go back to the beginning. If you reach the blue area, you win.
What is the problem you are having?
I cannot get the moving red dots to move all at the same time (I tried and it goes one by one). I want the red moving dots to move up and down (in a loop) all at the same time in a 1-2-1-2 pattern. Much like the 2nd level of the game I linked. That means when the 1st red dot touches the top, the bottom will reach the bottom, and the same for the rest.
Describe what you have tried to solve this problem
I tried procedures and fork, but neither worked. I`m pretty sure you are supposed to use procedures to do it, but I think I did it wrong. I know this is really simple, I am bad at Turing and I have to do this project.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
4.1
Thanks in advance.
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Stephen's Game.t |
Filesize: |
94.59 KB |
Downloaded: |
113 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Turing_Gamer
![](http://compsci.ca/v3/uploads/user_avatars/8617055374bcc8b48c6d4f.png)
|
Posted: Sun Jan 17, 2010 7:59 pm Post subject: Re: How to make red dots move constantly all at the same time |
|
|
I havn't opened the file, but i can show you a quick demo for constant movement.
Turing: | % BALL BOUNCER (0 gravity)
var x := 1
var y := 1
var xdir := 2
var ydir := 2
loop
cls
x := x + xdir
y := y + ydir
Draw.FillOval (x, y, 1, 1, red)
if x <= maxx or x >= 0 then
xdir := xdir * 1
end if
if y <= maxy or y >= 0 then
ydir := ydir * 1
end if
end loop |
|
|
|
|
|
![](images/spacer.gif) |
Stephenlol
|
Posted: Sun Jan 17, 2010 8:05 pm Post subject: Re: How to make red dots move constantly all at the same time |
|
|
if possible, can you use simpler code, cause my teacher may know that I "cheated".
My teacher said that I have to use procedures, but the way I did it, it did not work.
Oh, and I also need the dots moving all at the same along with the controllable dot.
|
|
|
|
|
![](images/spacer.gif) |
Euphoracle
![](http://compsci.ca/v3/uploads/user_avatars/11170373664bf5f25f636f1.png)
|
Posted: Sun Jan 17, 2010 9:22 pm Post subject: RE:How to make red dots move constantly all at the same time |
|
|
The idea is you don't copy it, you write it yourself. Kudos to your teacher for actually checking.
|
|
|
|
|
![](images/spacer.gif) |
Zasalamel
![](http://compsci.ca/v3/uploads/user_avatars/19672261044b2e9d570a198.jpg)
|
Posted: Sun Jan 31, 2010 7:46 pm Post subject: RE:How to make red dots move constantly all at the same time |
|
|
if your using a for statement and your dots or whatever are drawn one by one then put the loop around the for not inside of it.
|
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Sun Jan 31, 2010 8:39 pm Post subject: RE:How to make red dots move constantly all at the same time |
|
|
This is off-topic, but I really don't like it when teachers make a check list and tell you to do what's on there (e.g. You must use procedures, for loops, and if statements). I believe you should just be able to get to the goal anyway you think of, and the teacher should mark you on how efficient it is and if it was done in a correct manner (e.g. proper comments, good layout, etc). At least this way, everything is marked based on skill rather than just completing a check list.
|
|
|
|
|
![](images/spacer.gif) |
DtY
![](http://compsci.ca/v3/uploads/user_avatars/8576159234be48b7a8b0e8.png)
|
Posted: Sun Jan 31, 2010 10:08 pm Post subject: Re: RE:How to make red dots move constantly all at the same time |
|
|
andrew. @ Sun Jan 31, 2010 8:39 pm wrote: This is off-topic, but I really don't like it when teachers make a check list and tell you to do what's on there (e.g. You must use procedures, for loops, and if statements). I believe you should just be able to get to the goal anyway you think of, and the teacher should mark you on how efficient it is and if it was done in a correct manner (e.g. proper comments, good layout, etc). At least this way, everything is marked based on skill rather than just completing a check list. While I generally agree with this, making a requirement on a program to use procedures (imo) is like an English assignment requiring you to use verbs.
|
|
|
|
|
![](images/spacer.gif) |
Turing_Gamer
![](http://compsci.ca/v3/uploads/user_avatars/8617055374bcc8b48c6d4f.png)
|
Posted: Mon Feb 01, 2010 8:42 am Post subject: Re: How to make red dots move constantly all at the same time |
|
|
Do you have to use procedures for your program?
If so, then the first code could be placed in the main loop and if you want, have a picture-printing procedure played after (fork/no-fork)
That way you are using procedures but not for the variable-changing codes
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TerranceN
|
Posted: Mon Feb 01, 2010 3:52 pm Post subject: RE:How to make red dots move constantly all at the same time |
|
|
@andrew.:
I agree that you should be able to do it your own way, but...
@DtY:
I think procedures should be mandatory for any project over 50 lines of code, because I always see people with hundreds of lines of code, who ask me to figure out whats wrong, and I have to search through their code trying to find the part that they need help with (I am guilty of this too). But you also have to remember...
@Turing_Gamer:
The point of "using procedures" is not just to put one in there and call it a day, thats superficial. The point is to understand why procedures are useful and where to use them, to make your code better.
|
|
|
|
|
![](images/spacer.gif) |
Turing_Gamer
![](http://compsci.ca/v3/uploads/user_avatars/8617055374bcc8b48c6d4f.png)
|
Posted: Tue Feb 02, 2010 8:35 am Post subject: Re: How to make red dots move constantly all at the same time |
|
|
Understood...
@Stephenlol: Try and find a tutorial on procedures on the 'Turing Tutorials' forum, there should be a couple. But I recommend for creating programs, not to use procedures cause it messes up the program. Use them only when you make a program that has either multiple options, levels, players w/ controls, etc.
And the procedures require alot of problem solving, in case the program won't work (and it will most likely work).
|
|
|
|
|
![](images/spacer.gif) |
|
|