Computer Science Canada How sense the object ? |
Author: | AntoxicatedDevil78 [ Thu Nov 29, 2012 11:09 am ] | ||
Post subject: | How sense the object ? | ||
What is it you are trying to achieve? <Replace all the <> with your answers/code and remove the <>> I am trying to create a game that senses when an object flies by. What is the problem you are having? <Answer Here> I can't fine a command that would sense the colour/ object? Describe what you have tried to solve this problem <Answer Here> Searched around, went into turings help reference, didn't understand it. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here> drawbox (120,120,maxx-120,maxy-120, 1) var x,y :int x:= maxx div 2 y:= maxy div 2 loop drawfilloval (x,y ,12,12,110) drawfilloval (x,y,12,12,0) x := x +1 end loop
Please specify what version of Turing you are using <Answer Here> 4.1.1 |
Author: | Panphobia [ Thu Nov 29, 2012 2:25 pm ] |
Post subject: | RE:How sense the object ? |
Just check the surrounding block for changes in colour. |
Author: | Tony [ Thu Nov 29, 2012 3:17 pm ] |
Post subject: | RE:How sense the object ? |
Math.Distance Of course this will only give you the distance between 2 points, so you might have to figure out checking of what points will be enough to give you a good answer. |
Author: | Panphobia [ Thu Nov 29, 2012 7:15 pm ] |
Post subject: | RE:How sense the object ? |
Yes as Tony said you could do that or just do something like var distance: int distance := (x+x1)^2-(y+y1)^2 and whenever this point is moving and the closer it gets or when it passes over you do a certain thing, I think this is what Tony was trying to show you with Math.Distance |
Author: | AntoxicatedDevil78 [ Fri Nov 30, 2012 9:59 am ] |
Post subject: | Re: How sense the object ? |
That helped, but I need it to move in every direction now. drawbox (120, 120, maxx - 120, maxy - 120, 1) var x, y : int x := maxx div 2 y := maxy div 2 loop drawfilloval (x, y, 12, 12, 110) delay (10) drawfilloval (x, y, 12, 12, 0) x := x + 1 y := y + 1 if x >= (maxx - 135) then loop x := x - 1 y := y + 1 drawfilloval (x, y, 12, 12, 110) delay (10) drawfilloval (x, y, 12, 12, 0) if y >= (maxy - 135) then loop y := y - 1 x := x - 1 drawfilloval (x, y, 12, 12, 110) delay (10) drawfilloval (x, y, 12, 12, 0) exit when y <= 135 exit when x <= 135 end loop end if exit when x <= 135 end loop end if if y >= (maxy - 135) then loop y := y - 1 x := x + 1 drawfilloval (x, y, 12, 12, 110) delay (10) drawfilloval (x, y, 12, 12, 0) exit when y <= 135 if x <= (maxx - 135)then loop x := x - 1 y := y - 1 exit when y <= 135 exit when x <= 135 end loop end if end loop end if end loop Quote: |
Author: | Panphobia [ Fri Nov 30, 2012 10:36 am ] |
Post subject: | RE:How sense the object ? |
what exactly is the purpose of your program? |
Author: | AntoxicatedDevil78 [ Sat Dec 01, 2012 2:52 pm ] |
Post subject: | Re: How sense the object ? |
I'm trying to make the ball bounce, then make it bounce within the rectangle, then have it dodge an object in the rectangle |
Author: | Panphobia [ Sat Dec 01, 2012 4:41 pm ] | ||
Post subject: | Re: How sense the object ? | ||
Ok so get the x,y coords for all 4 points and do something like this,
|