Computer Science Canada Moving Canada flag project |
Author: | Robotkubo [ Thu Feb 18, 2016 9:34 am ] |
Post subject: | Moving Canada flag project |
Hey, I've made a thread before about this and since then I've made some progress, but I still need help. My Maple leaf goes crazy, its upside down and changes width and length all the time while moving, Some of the code Is from a bouncing ball template I found, not really sure where :/ if I can remember I'll be sure to edit it in Here (Idk) My project is due really soon so if someone could please help me out! ![]() View.Set ("graphics,offscreenonly") var x, y, xChange, yChange : int := 1 const RADIUS : int := 5 Draw.Box (0, 0, maxx, maxy, black) x := maxx div 2 y := maxy div 2 loop Draw.Cls Draw.Box (0, 0, maxx, maxy, black) Draw.MapleLeaf (x, y, RADIUS, RADIUS, red) View.Update Time.Delay (5) x += xChange y += yChange if View.WhatDotColor (x, y + RADIUS) = black then yChange *= -1 elsif View.WhatDotColor (x, y - RADIUS) = black then yChange *= -1 end if if View.WhatDotColor (x + RADIUS, y) = black then xChange *= -1 elsif View.WhatDotColor (x - RADIUS, y) = black then xChange *= -1 end if end loop |
Author: | Atherial [ Thu Feb 18, 2016 2:42 pm ] | ||
Post subject: | Re: Moving Canada flag project | ||
I have found the one line that is messing up your program, I recommend you attempt to find it yourself first though! ![]() if you want the answer, continue below; however I really do recommend you try it yourself, first. Firstly, I highly recommend you make your radius bigger, as a maple leaf with each side being 5, would be quite small, but that is besides the point. So, your radius is a constant value of five, which is the size you want the maple leaf to be. When you are drawing it however, you are using "RADIUS" as both the X and Y values, Instead, add the radius to the x and y. So, heres my fixed code:
I hope that is your desired outcome! ![]() [/spoiler] Hope I helped! -Mac |
Author: | Insectoid [ Thu Feb 18, 2016 2:52 pm ] |
Post subject: | RE:Moving Canada flag project |
This is what happens when you copy code you don't understand. The code is from a bouncing BALL template. The code to draw a ball in Turing is Draw.Oval (x, y, radius, radius, color). The code to draw a maple leaf is Draw.MapleLeaf (x1, y1, x2, y2, color). Can you see where you might have gone wrong here? |
Author: | Robotkubo [ Fri Feb 19, 2016 8:21 am ] |
Post subject: | RE:Moving Canada flag project |
Yeah I see where I went wrong, thanks to both of you |