----------------------------------- Kobe24 Sat May 17, 2014 9:57 pm How do you move a circle in turing ----------------------------------- How do you move a circle in Turing? ----------------------------------- Raknarg Sun May 18, 2014 11:18 am 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: loop for x : 1 .. 150 Draw.FillOval(x, 200, 10, 10, 12) delay(5) cls end for for decreasing x : 150 .. 1 Draw.FillOval(x, 200, 10, 10, 12) delay(5) cls end for end loop variables: var x : int := 0 var direction : int := 1 loop x += direction %this means add value of direction to x if x = 150 then direction := -1 end if Draw.FillOval(x, 200, 10, 10, 12) delay(5) cls end loop Personally I would say the second one is the best option. ----------------------------------- Jesse Kazemi Wed May 21, 2014 6:25 pm Re: How do you move a circle in turing ----------------------------------- 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 :D ----------------------------------- Raknarg Wed May 21, 2014 9:30 pm 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. ----------------------------------- Jesse Kazemi Wed Jun 18, 2014 1:22 pm Re: How do you move a circle in turing ----------------------------------- True that but it is a simpler method ----------------------------------- Raknarg Wed Jun 18, 2014 8:29 pm RE:How do you move a circle in turing ----------------------------------- It's not really that much different. ----------------------------------- Srlancelot39 Wed Jun 18, 2014 9:38 pm 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. ----------------------------------- Raknarg Wed Jun 18, 2014 10:48 pm RE:How do you move a circle in turing ----------------------------------- Never use processes in Turing. ----------------------------------- Srlancelot39 Thu Jun 19, 2014 7:43 am Re: RE:How do you move a circle in turing ----------------------------------- 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 :/ ----------------------------------- Dreadnought Thu Jun 19, 2014 3:49 pm Re: How do you move a circle in turing ----------------------------------- 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. ----------------------------------- Srlancelot39 Thu Jun 19, 2014 5:30 pm Re: How do you move a circle in turing ----------------------------------- 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 :P Seriously though, that makes sense - thanks! ----------------------------------- Lucas.M Sat Apr 18, 2020 6:16 pm 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.