|
Pages: [1] 2
|
 |
|
Author
|
Topic: Power ASCII Lib.. (Read 4254 times)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rattrapmax6
__/--\__
    
Posts: 2577

|
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: 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:
|
|
|
|
|
Logged
|
Kevin ( x.t.r.GRAPHICS) 
|
|
|
Dr_Davenstein
Na_th_an
    
Posts: 2044
|
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.  EDIT: Here it is.  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
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|
|
|
|
Pages: [1] 2
|
|
|
|
|