Computer Science Canada My First Turing Animation --> Open to all criticism and tips, thanks! (: |
Author: | TheParadox [ Sun Sep 27, 2015 2:31 pm ] |
Post subject: | My First Turing Animation --> Open to all criticism and tips, thanks! (: |
Hey Everyone! Just made this little animation, and wanted some advice as to what I can add to it. Criticism/advice would be great as well, thanks! I'll copy paste the full code hear, and attach the ".t" file to this post. setscreen("graphics: 1980;1080,offscreenonly") var font1 : int := Font.New ("Comicsans:50:bold,italic") var chars : array char of boolean var x,y,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,x9,y9: int x:=950 y:=618 x1:=800 y1:=618 x2:=650 y2:=618 x3:=500 y3:=618 x4:=530 y4:=625 x5:=430 y5:=625 x6:=400 y6:=700 x7:=500 y7:=700 x8:=480 y8:=590 loop Input.KeyDown (chars) if chars (KEY_LEFT_ARROW) then x:=x-5 x1:=x1-5 x2:=x2-5 x3:=x3-5 x4:=x4-5 x5:=x5-5 x6:=x6-5 x7:=x7-5 x8:=x8-5 end if if chars (KEY_RIGHT_ARROW) then x:=x+5 x1:=x1+5 x2:=x2+5 x3:=x3+5 x4:=x4+5 x5:=x5+5 x6:=x6+5 x7:=x7+5 x8:=x8+5 end if if chars (KEY_UP_ARROW) then y:=y+5 y1:=y1+5 y2:=y2+5 y3:=y3+5 y4:=y4+5 y5:=y5+5 y6:=y6+5 y7:=y7+5 y8:=y8+5 end if if chars (KEY_DOWN_ARROW) then y:=y-5 y1:=y1-5 y2:=y2-5 y3:=y3-5 y4:=y4-5 y5:=y5-5 y6:=y6-5 y7:=y7-5 y8:=y8-5 end if Draw.FillBox(0,0,maxx,maxy,brightblue) Font.Draw("Caterpillar Game",100,1000,font1,brightgreen) Draw.FillOval(x,y,100,100,green) Draw.FillOval(x1,y1,100,100,brightgreen) Draw.FillOval(x2,y2,100,100,green) Draw.FillOval(x3,y3,100,100,brightgreen) Draw.FillOval(x4,y4,10,10,black) Draw.FillOval(x5,y5,10,10,black) Draw.Arc(x6,y6,50,50,0,100,black) Draw.Arc(x7,y7,50,50,0,100,black) Draw.Arc(x8,y8,60,25,180,360,black) View.Update delay(5) cls end loop |
Author: | Insectoid [ Sun Sep 27, 2015 4:16 pm ] |
Post subject: | RE:My First Turing Animation --> Open to all criticism and tips, thanks! (: |
You can eliminate a ton of lines by using only one variable for X and one for Y and changing all of x1, y1, x2, y2, etc. to offsets instead. Offsets are coordinates relative to a point (x, y) instead of absolute coordinates. For example, x1, instead of 800, becomes -150 (because 950-800=150). You can now change all of your ovals to use (x + x1) instead of just x1. What does this do for you? Well, x1 never needs to change, so you can remove it from all your keyboard control if statements. If you do this for all the x's and y's (except x and y itself, since they're the reference coordinates), your code will be at least 32 lines shorter, and your if statements will only be 2 lines each (one for x, one for y). This reduces the risk for bugs due to typos and makes the code much, much more readable. |
Author: | TheBoyWhoTried [ Fri Dec 04, 2015 9:42 am ] |
Post subject: | Re: My First Turing Animation --> Open to all criticism and tips, thanks! (: |
Hey Insectoid, Could you give me a small example of an animation using that? I understand the concept is to have a constant apply to the the values to eliminate repetition, I just don't know how to actually do it (writing it in the editor window). Thanks! |