drawing oval problem
Author |
Message |
sosno
|
Posted: Tue Mar 09, 2004 8:10 pm Post subject: drawing oval problem |
|
|
im trying to draw an oval that moves across the screen on a parabola i just cant figure out how to do it because it wants int but my equation involves real
code: | var x1, y1 : int
x1 := -50
y1 := 0
colorback (199)
cls
loop
y1 := -1x1**2 %im am trying for it to be -0.1x1**2 (** is instead of exponent)
drawfilloval (x1, y1, 30, 30, 14)
delay (50)
cls
x1 := x1 + 1
exit when y1 = 479
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Paul
|
Posted: Tue Mar 09, 2004 8:14 pm Post subject: (No subject) |
|
|
though it still doesn't go parabola
code: |
y1 := (-1)*(1**2) %im am trying for it to be -0.1x1**2 (** is instead of exponent)
|
I put the brackets cause its my habit |
|
|
|
|
|
sosno
|
Posted: Tue Mar 09, 2004 8:19 pm Post subject: differtn thing |
|
|
look in comment i would like it to be
y := -0.1*x**2 |
|
|
|
|
|
AsianSensation
|
Posted: Tue Mar 09, 2004 8:20 pm Post subject: (No subject) |
|
|
when you draw to the screen, use round.
x:= something
y:= something
drawfilloval (round (x), round (y), ...) |
|
|
|
|
|
sosno
|
Posted: Tue Mar 09, 2004 8:24 pm Post subject: (No subject) |
|
|
sorry can u elaborate on that.
AsianSensation wrote: when you draw to the screen, use round.
x:= something
y:= something
drawfilloval (round (x), round (y), ...) |
|
|
|
|
|
jonos
|
Posted: Tue Mar 09, 2004 8:24 pm Post subject: (No subject) |
|
|
well, in turing you can't use decimals as coordinates so for each coordinate you will have to do round().
just do what he said and it should work. like i said before, turing won't let you use decimal numbers for coordinates, so if you round them to the nearest whole number (which round() does), then it will plot them for you. |
|
|
|
|
|
Paul
|
Posted: Tue Mar 09, 2004 8:24 pm Post subject: (No subject) |
|
|
Oh, that was confusing, you cant put a decimal into a int variable, so when you multiplied by -0.1, you turned it into decimal. |
|
|
|
|
|
AsianSensation
|
Posted: Tue Mar 09, 2004 8:27 pm Post subject: (No subject) |
|
|
Paul Bian wrote: Oh, that was confusing, you cant put a decimal into a int variable, so when you multiplied by -0.1, you turned it into decimal.
turing would not let you draw something with real numbers as it's parameter. So doing this:
drawfilloval (0.564, -3.56 ....) will not work.
so to solve this, you round off the value for your coordinates first, so the above becomes:
drawfilloval (round (0.564), round(-3.56) ....), which is the samething as doing: drawfilloval (1, -4 ....), and you can draw on to the screen like that. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
sosno
|
Posted: Tue Mar 09, 2004 8:27 pm Post subject: (No subject) |
|
|
i realise i cant use decimals so can someone tell me for a beginner how to get around this. |
|
|
|
|
|
sosno
|
Posted: Tue Mar 09, 2004 8:29 pm Post subject: (No subject) |
|
|
but u cant round .1 it will be 0 and it wont work,
you can tround parabolas neways |
|
|
|
|
|
jonos
|
Posted: Tue Mar 09, 2004 8:29 pm Post subject: (No subject) |
|
|
thats as easy as we can make it.
round(0.1) will round 0.1 to 0
round(0.5) will round 0.5 to 1
round(1000.25) will round 1000.25 to 1000
thats really simplest it can be. |
|
|
|
|
|
AsianSensation
|
Posted: Tue Mar 09, 2004 8:31 pm Post subject: (No subject) |
|
|
sosno wrote: but u cant round .1 it will be 0 and it wont work,
you can tround parabolas neways
what do you mean you cant round? you mean your assignment specify that you can't use the round function? or that you feel by rounding it, you are making the oval following an inaccurate path?
Because, without rounding, you really can't draw to the screen, turing is limited like that. |
|
|
|
|
|
sosno
|
Posted: Tue Mar 09, 2004 8:38 pm Post subject: (No subject) |
|
|
no my asssingment doenst specify i just want that circle to move a nice path along the screen and it hought the parabola would be a nice way to do that ne alternatives
this is only the start of what im trying to achieve im working on a moon where one circle blcoks out the other
incase you were wonderig if i just recently psoested somethign about a moon that was not compatable with the version of turing i run @ school i use mac turing 4.x (not sure exactly which one) |
|
|
|
|
|
jonos
|
Posted: Tue Mar 09, 2004 8:41 pm Post subject: (No subject) |
|
|
well, thats the only way you can do it unless you use trig which only a few people really know very well. look in turing submissions for arcs, circles, or something like that and youl can just take code from there and work with that. |
|
|
|
|
|
|
|