Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Power ASCII Lib..
#11
I can... lol,. but so far, my line routine is finally looking solider,. I made a code to run it 3D, it goes all the way around w/o freezing, tho.. it seems it like to shift awkwardly at places... whether its the integer set up with LOCATE, or maybe some mis-calcs, not really sure... here is mine:

Code:
SUB ASCII_LINE(X01, Y01, X02, Y02, ASCII)
    IF X02 > X01 THEN XR01 = X02 - X01
    IF X02 < X01 THEN XR01 = X01 - X02
    
    IF Y02 > Y01 THEN YR01 = Y02 - Y01
    IF Y02 < Y01 THEN YR01 = Y01 - Y02
    
    RAD! = ATN(YR01 / XR01)
    ANG! = (RAD! / 3.1415926535897932384626433832795 * 180)
    XR02! = (1 * COS(ANG! * 3.1415926535897932384626433832795 / 180))
    YR02! = (1 * SIN(ANG! * 3.1415926535897932384626433832795 / 180))
    
    Hyp01! = ((YR01)^2 + (XR01)^2)^.5
    
    X00! = X01
    Y00! = Y01
    CONT01 = 0
    DO
        CONT01 += 1
        IF (Y00! > 0 AND Y00! < MAXY01) AND (X00! > 0 AND X00! < MAXX01) THEN
            LOCATE INT(Y00!), INT(X00!): PRINT CHR$(ASCII);
        END IF

        IF (Hyp01! < CONT01) THEN EXIT DO
        
        IF Y02 > Y01 THEN Y00! += YR02!
        IF X02 > X01 THEN X00! += XR02!
        IF Y02 < Y01 THEN Y00! -= YR02!
        IF X02 < X01 THEN X00! -= XR02!
    LOOP
END SUB

I took out REMed experiment code that didn't work, and a REMed debugger.. If it doesn't work like the current lib, I might have deleted something important in the process, tho I doubt it.. :wink: ..

You'll need to set the MAXX01 and MAXY01 variables to your max X, Y text screen output, otherwise it will cut the whole line thinking its off screen.. :wink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#12
Give me a few minutes and I'll make this one for ascii. It'll take a couple of bounds checks, but it shouldn't slow it down too much. It's just a bresenham line algo... all integers. Wink

EDIT: Here it is. Wink


Code:
DECLARE SUB ASC_Line(x1, y1, x2, y2, c, Char)

Const ScreenWidth=80, ScreenHeight=60, MidX=(ScreenWidth-1)\2, MidY=(ScreenHeight-1)\2
Width ScreenWidth,ScreenHeight


Do
    Ang!=Ang!+.01
    X1=MidX+25*SIN(Ang!)
    Y1=MidY+25*COS(Ang!)
    X2=MidX-25*SIN(Ang!)
    Y2=MidY-25*COS(Ang!)
    
ASC_Line X1,Y1,X2,Y2, 14, ASC("*")
Sleep 1
CLS
Loop Until Inkey$=Chr$(27)
END


SUB ASC_Line(x1, y1, x2, y2, c, char)
     COLOR(C)
     Xdif = x2 - x1
     Ydif = y2 - y1
  
     IF Xdif < 0 THEN
         Xdif = -Xdif
     END IF
  
     IF Ydif < 0 THEN
         Ydif = -Ydif
     END IF
  
IF Xdif >= Ydif THEN
     IF x2 < x1 THEN
         SWAP x2, x1
         SWAP y2, y1
     END IF
    
     IF y2 < y1 THEN
         Xit = -1
     ELSE
         Xit = 1
     End If
    
     TempY = y1
    
     If TempY>0 And TempY<=ScreenHeight Then
        FOR TempX = x1 TO x2
            If TempX>0 And TempX<ScreenWidth Then
                Locate TempY,TempX
                Print Chr$(Char)
        
                Yit = Yit - Ydif
        
                IF Yit < 0 THEN
                    Yit = Yit + Xdif
                    TempY = TempY + Xit
                END IF
            End If    
        NEXT
     End If  
    
ELSE
      
     IF y2 < y1 THEN
         SWAP x2, x1
         SWAP y2, y1
     END IF
    
     IF x2 < x1 THEN
         Xit = -1
     ELSE
         Xit = 1
     End If
    
     TempX = x1
     If TempX>0 And TempX<= ScreenWidth Then
    
        FOR TempY = y1 TO y2
            If TempY>0 and TempY<ScreenHeight Then
                Locate TempY,TempX
                Print Chr$(Char)
        
                Yit = Yit - Xdif
      
                IF Yit < 0 THEN
                    Yit = Yit + Ydif
                    TempX = TempX + Xit
                END IF
            End If    
        NEXT
     End If
  
END IF
END SUB
Reply
#13
*bump*
Wink
Reply
#14
Nice one Dr :-)..Worked great for me when I tried it just now :-)
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#15
Sad Darn,. it makes my comp go all blue-screen-of-death.... What's up with that?
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#16
You can't be serious... :???:

Maybe it's a console problem. Try setting a SCREEN mode at the beginning or something.
Reply
#17
probably is Dr...he's on win 98...80x60 don't exist I think back then...set it to 80x50 Ratt should work then :-)
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#18
lol,.. yeah, that work!!!... Pretty cool, tho I had to put it on Ang!=Ang!+.1 to get it to move.. :lol: .. Ang!=Ang!+.01 was to slow,. anyway, thanks again Mystic, I didn't get the blue screen of death this time on 80x50...

:wink: I'll see about putting this in my lib, I'll have to change a few of the variables tho, so it work... Smile ..
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)