Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Why wont this work right??
Author Message
valor

Posted: 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.

Paul

Posted: Mon Mar 29, 2004 5:52 pm   Post subject: (No 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
sport

Posted: Mon Mar 29, 2004 6:15 pm   Post subject: (No 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)
valor

Posted: Mon Mar 29, 2004 9:30 pm   Post subject: (No 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
Paul

Posted: Mon Mar 29, 2004 10:17 pm   Post subject: (No 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...
valor

Posted: Tue Mar 30, 2004 10:09 am   Post subject: (No 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
the_short1

Posted: Tue Mar 30, 2004 3:03 pm   Post subject: (No 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\$\$~~~!!!!!
Paul

Posted: Tue Mar 30, 2004 6:49 pm   Post subject: (No 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.

the_short1

Posted: Tue Mar 30, 2004 8:47 pm   Post subject: (No 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..
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 9 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: