Computer Science Canada Why wont this work right??

 Author: valor [ Mon Mar 29, 2004 4:17 pm ] Post subject: Why wont this work right?? ok this is an update from my other line draw program. i made it so that you can choose a color and that it animates the line drawing from one point to the other. the problem is that some lines wont work and they will just make a dot on the screen or keep drawing a line non-stop off the screen. TY to anyone that helps me.

Author:  Paul [ Mon Mar 29, 2004 5:52 pm ]
Post subject:

well, this kinda works, and I emphasise on the KINDA... assuming the user doesn't make the slope go down, or no slope or draw the line from right to left... because the slope calculation isn't enough, you can fix that though, this is what I got with my limited halfway through grade 10 knowledge... oh yea, the extra put statements were just to help me test how to simplify the slope and the drawdot, was for me to test if the line was accurate.
 code: %draws a line multiple times to draw a picture% %By. Ryan Creagh                              % %                  enjoy                      % % % % % % % % % % % % % % % % % % % % % % % % % View.Set ("graphics:788;540,nobuttonbar,title:Line Draw :)") setscreen ("nocursor") setscreen ("graphics") var  x,y,x2, y2, x3, y3,col, midx, midy : int var slopex, slopey: real var small: int put "choose a color for the lines from 1-15" get col colorback (white) cls put "(type 999 to quit)enter a start and end point for the line" put "starting with the x axis,y axis, second x axis, and the second y axis" loop     locate (3, 1)     get x     if x = 999 then         exit     end if     locate (3, 4)     get y     locate (3, 7)     get x2     locate (3, 10)     get y2     if y > maxy - 25 or y2 > maxy - 25 or x < 0 or x2 < 0 or x2 > maxx or x > maxx or y < 0 or y2 < 0 then         locate (3, 15)         put "out of bounds"     else         slopex := x2 - x         slopey := y2 - y         midx := x         midy := y         if slopex= x2 and y3 >= y2         end loop     end if     locate (3, 1)     put "" end loop

Author:  sport [ Mon Mar 29, 2004 6:15 pm ]
Post subject:

I don't really undersatnd the importance of the last loop in the original program and all the complicated stuff. Can you just use

 code: drawline (x, y, x2,y2, col)

 Author: valor [ Mon Mar 29, 2004 9:30 pm ] Post subject: thanks paul bian that kinda helps me. still confused though lol. your edited version kinda works a little better but i still cant get some of the lines to work. they will still draw dots

 Author: Paul [ Mon Mar 29, 2004 10:17 pm ] Post subject: The only hard part in this program is to animate the progress of the drawing, you can do that by drawing small sections of the line at a time or use draw dot to follow the slope, I still haven't figured out a perfect way to do either... you'll have to modify it so that the negative slopes work as well...

 Author: valor [ Tue Mar 30, 2004 10:09 am ] Post subject: yeah this is hard. i tryed another why but it messed it up more lol. here is what i did to it: midx += slopex div 200 midy += slopey div 200 i replaced this with If slopex < 0 then midx -= slpoex div 200 else midx += slopex div 200 end fi if slopey < 0 then midy -= slopey div 200 else midy += slopey div 200 end if

 Author: the_short1 [ Tue Mar 30, 2004 3:03 pm ] Post subject: ^^^ yea i helped him make that code.... even i cant realy figure it out... especially since its not my program and i dont want to do the whole deal for him......... PSSST!!! he making a missle command and it kicks A\$\$~~~!!!!!

 Author: Paul [ Tue Mar 30, 2004 6:49 pm ] Post subject: well what I did in my code is find the simplest form of the slope, if it happens to be 1/1 then your lucky, it animates the drawing of the line well, if its something like 3/2 it works too... if its like 23/45 then its a little rough, like I made it so that it draws sections of lines at a time, and even so its not very accurate, I can only do that with the simplest form of the slope, cause turing doesn't allow drawing with decimal locations... I can't think of a better way to animate the line at school.

 Author: the_short1 [ Tue Mar 30, 2004 8:47 pm ] Post subject: yea.,..... animating lines aint fun...... cuz u have to use math... and i use it enough in math taht i sick of it... anyways.... i wouln't worry about it since its his first program... and rite now he is busy with his missle command which will be ten times better... hell i wanted to make a missle command... but i forgot about it.... then he told me he was making one..... now im jelous... cuz its going to be VERY good..

 :