
-----------------------------------
AntoxicatedDevil78
Thu Nov 29, 2012 11:09 am

How sense the object ?
-----------------------------------
What is it you are trying to achieve?

I am trying to create a game that senses when an object flies by.

What is the problem you are having?

I can't fine a command that would sense the colour/ object?

Describe what you have tried to solve this problem

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)



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

4.1.1

-----------------------------------
Panphobia
Thu Nov 29, 2012 2:25 pm

RE:How sense the object ?
-----------------------------------
Just check the surrounding block for changes in colour.

-----------------------------------
Tony
Thu Nov 29, 2012 3:17 pm

RE:How sense the object ?
-----------------------------------
[tdoc]Math.Distance[/tdoc]

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.

-----------------------------------
Panphobia
Thu Nov 29, 2012 7:15 pm

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

-----------------------------------
AntoxicatedDevil78
Fri Nov 30, 2012 9:59 am

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 