Computer Science Canada How do you move a circle in turing |
Author: | Kobe24 [ Sat May 17, 2014 9:57 pm ] |
Post subject: | How do you move a circle in turing |
How do you move a circle in Turing? |
Author: | Raknarg [ Sun May 18, 2014 11:18 am ] | ||||
Post subject: | RE:How do you move a circle in turing | ||||
There's a couple different methods. Either a for loop, or a variable. Here's two examples of a circle moving back and forth: for loop:
variables:
Personally I would say the second one is the best option. |
Author: | Jesse Kazemi [ Wed May 21, 2014 6:25 pm ] |
Post subject: | Re: How do you move a circle in turing |
Kobe24 @ Sat May 17, 2014 9:57 pm wrote: How do you move a circle in Turing?
like this : % ICS2O - draw moving circle across screen View.Set ("graphics") const R := 30 const DELAY := 5 const STEP := 2 % Initially setting the x, y values to place a ball in the top left corner % of the screen var x : int := 0 + R var y : int := maxy - R var col := 13 % this is the colour pink const BGD := white loop loop exit when x > maxx - R % off the right side of the screen % cls % clears the screen Draw.FillOval(x-STEP, y, R,R, BGD) % reduces flicker rather than cls % draw oval with centre at x,y and x,y radius = R and colour = col Draw.FillOval (x, y, R, R, col) delay (DELAY) % delays for DELAY milliseconds x := x + STEP % move the ball to the right a bit end loop % col := col + 1 loop exit when x < R % off the left side of the screen cls % clears the screen % draw oval with centre at x,y and x,y radius = R and colour = col Draw.FillOval (x, y, R, R, col) delay (DELAY) % delays for DELAY milliseconds x := x - STEP % move the ball to the left a bit end loop end loop |
Author: | Raknarg [ Wed May 21, 2014 9:30 pm ] |
Post subject: | RE:How do you move a circle in turing |
Like I said though, that's not a good method if you want to animate more than one thing. |
Author: | Jesse Kazemi [ Wed Jun 18, 2014 1:22 pm ] |
Post subject: | Re: How do you move a circle in turing |
True that but it is a simpler method |
Author: | Raknarg [ Wed Jun 18, 2014 8:29 pm ] |
Post subject: | RE:How do you move a circle in turing |
It's not really that much different. |
Author: | Srlancelot39 [ Wed Jun 18, 2014 9:38 pm ] |
Post subject: | RE:How do you move a circle in turing |
I haven't done graphics in a while, but look into procedures and processes if you'd like to move more than one object at a time. Note: Processes in Turing don't mix well with graphics. I recommend using procedures and a single, very short delay. |
Author: | Raknarg [ Wed Jun 18, 2014 10:48 pm ] |
Post subject: | RE:How do you move a circle in turing |
Never use processes in Turing. |
Author: | Srlancelot39 [ Thu Jun 19, 2014 7:43 am ] |
Post subject: | Re: RE:How do you move a circle in turing |
Raknarg @ Wed Jun 18, 2014 10:48 pm wrote: Never use processes in Turing.
This. The only exception I know of is sound. Sound seems to work fine in processes. Anything else, no. A real example is my medieval RPG, "Grail Quest" (link in my signature), where I have a process for each sound effect and a process for the music. I tried drawing moving clouds using processes and it just created a flashfest...so no moving clouds lol. EDIT: I've heard that the reason for this is that Turing processes do not actually function as proper processes, but instead have their code wedged into the rest of the code as it runs and does a very bad job of it. I'm assuming that the reason why sound is okay is because it does not need to be refreshed like images do; the process just tells it to play once (because that is the nature of sound files) and it does so. EDIT2: My Grail Quest download does not include the source code, just the application...sorry :/ |
Author: | Dreadnought [ Thu Jun 19, 2014 3:49 pm ] |
Post subject: | Re: How do you move a circle in turing |
Srlancelot39 wrote: I've heard that the reason for this is that Turing processes do not actually function as proper processes, but instead have their code wedged into the rest of the code as it runs and does a very bad job of it. I'm assuming that the reason why sound is okay is because it does not need to be refreshed like images do; the process just tells it to play once (because that is the nature of sound files) and it does so.
I would tend to say that in reality it is because it is often tougher to reason about the behavior of concurrent threads/processes. When you have two processes running in parallel there are certain things you can no longer assume. Most of the time people use processes in Turing when they are not necessary and often without understanding what they are. The reason sound is fine is because your process is not the one playing the sound, Turing (or maybe just good old Windows) does all the work for you. |
Author: | Srlancelot39 [ Thu Jun 19, 2014 5:30 pm ] |
Post subject: | Re: How do you move a circle in turing |
Dreadnought @ Thu Jun 19, 2014 3:49 pm wrote: The reason sound is fine is because your process is not the one playing the sound, Turing (or maybe just good old Windows) does all the work for you.
That's very sound reasoning, haha Seriously though, that makes sense - thanks! |
Author: | Lucas.M [ Sat Apr 18, 2020 6:16 pm ] |
Post subject: | Re: How do you move a circle in turing |
This works, but my circle keeps flickering when it moves. Any suggestions on how i stop it? I did GUI.Refresh and the View.Set commands but I assume you already know it doesn't work. |