Posted: Mon Mar 22, 2004 4:30 pm Post subject: Draw a circle
Draw a circle the cool way! (dot by dot )
i know its not much but check it out.
(I know, i actually LEARNED something from math class )
code:
var x2, y2:int:=100
function circleify(x:int,y:int):int
var z:int:=round((x2-x)**2+(y2-y)**2)
result round(z**0.5)
end circleify
for x:1..maxx
for y:1..maxy
if circleify (x,y) = 100 then
drawdot(x,y,7)
end if
end for
end for
where x2,y2 is the location of the centre
and circleify(x,y) =number
where number is the radius
(i know its completely useless, but meh.
Sponsor Sponsor
Cervantes
Posted: Mon Mar 22, 2004 7:23 pm Post subject: (No subject)
oh my... god......
spencer, that is.... amazing.
nono im dead serious. That's really good that you are using functions AND stuff you learned from math class. [/b]
Delos
Posted: Mon Mar 22, 2004 7:54 pm Post subject: (No subject)
Nice, nice...
Now try the same using trig. It's a bit more fun that the usual conics type of algebra.
programer007
Posted: Tue Mar 23, 2004 8:06 am Post subject: (No subject)
very nice,.... i found it worked better iof you changed the first line to = 200 not 100 but kept everything else the same... this way it dont draw out of bounds.....
VERY NICE>>.... thats beginning gr.11 work there... using functions and integrating math,,, +10 BITS!
recneps
Posted: Tue Mar 23, 2004 9:23 pm Post subject: (No subject)
Dont say trig :/ (i hate math now as it is) and thanks ;D we're almost at parabola's! I can see mario jumps on the horizon! look out ppl! Sidescroller V2 Coming soon!
recneps
Posted: Tue Mar 23, 2004 9:37 pm Post subject: (No subject)
Posted: Tue Mar 23, 2004 10:21 pm Post subject: (No subject)
ooh ooh, nice... good use of math you have learned. we're still on feasible regions, which sucks
zylum
Posted: Wed Mar 24, 2004 12:08 am Post subject: (No subject)
here's a way using lines :
code:
procedure drawCircle (centerx, centery, diam, c : int)
var x, y, oldx, oldy : real
oldx := cos (0) * diam + centerx
oldy := sin (0) * diam + centery
for i : 1 .. 360
x := cosd (i) * diam + centerx
y := sind (i) * diam + centery
drawline (round (oldx), round (oldy), round (x), round (y), c)
oldx := x
oldy := y
end for
end drawCircle
drawCircle (maxx div 2, maxy div 2, 100, 7)
here's a way to do fill oval
code:
procedure drawCircle (centerx, centery, diam, c : int)
var x, y, oldx, oldy : real
for i : 1 .. 360 * (diam div 50)
x := cosd ((i / (diam / 50))) * diam
y := sind ((i / (diam / 50))) * diam + centery
drawline (round (x) + centerx, round (y), round (-x) + centerx, round (y), c)
end for
end drawCircle
drawCircle (maxx div 2, maxy div 2, 200, 7)
-zylum
Sponsor Sponsor
recneps
Posted: Wed Mar 24, 2004 3:48 pm Post subject: (No subject)
Arg, i really gotta learn sine and cosine. All the cool programs seem to use it....
jonos
Posted: Wed Mar 24, 2004 3:52 pm Post subject: (No subject)
just wait till trig in math... thats where everything comes together.
WhatAmIDoing
Posted: Thu Mar 25, 2004 12:18 pm Post subject: (No subject)
the fill circle needs a delay of 10 or 15 on my comp other than that it's pretty good. oh and what gr.11 are you in i spent untill feb. learning loops and if statements we hust started string manipulation and my teacher don't belive in making games.
recneps
Posted: Fri Mar 26, 2004 4:04 pm Post subject: (No subject)
im in 10 and i took the initiative to teach myself some more (sadly no higher than gr 10 is offered at my school.) i had gr 10 last sem, and gr math this sem
We did parabola's today. so heres drawparabola!!!
code:
procedure drawparabola(position:int,height:int,angle:real)
var y:real:=0
%const angle := -.1
%const position := 100
%const height := 150
for x:1..200
y:=(angle*((x-position)**2))+height
drawdot(round(x),round(y),7)
end for
end drawparabola
drawparabola(100,150,-.1)
And the commented lines are the "default" ones, in case you change em and dont like it
the_short1
Posted: Fri Mar 26, 2004 6:40 pm Post subject: (No subject)
that parabola is kinda simple...
drawline at mid point to midpoint +25 to the right
then draw a line to the left... +25 and each repetition of loop lower that 25 -1 and add one to hight...
all the ones u did look nice tho... good job..
and ur cicle one lookz better then zylum.... his is not as smooth... A FIRST!
but zylums is way more complex
recneps
Posted: Fri Mar 26, 2004 7:37 pm Post subject: (No subject)
we JUST learned parabolas, itll improve with time
Hackster
Posted: Sat Mar 27, 2004 1:04 am Post subject: (No subject)
Holy shinikeys man ... one day of parabolas and you're making programs with them ... that is a very good sign!!! (Youre gunna make a great programmer!)