Category : Printer + Display Graphics
Archive   : BRKOUT.ZIP
Filename : BRKOUT.LSP

Output of file : BRKOUT.LSP contained in archive : BRKOUT.ZIP
; written by: Len Switzer
; Upper Canada Software
; 222 Monteith Ave.
; Stratford, Ont., Canada
; N5A 2P6
; Before running, you may want to adjust my screens for your display.
; Edit the drawings BRKOUT1, BRKOUT2 & BRKOUT3. Erase the entire
; display. Draw a line from 0,0 to 0,1, Zoom E, Oops, End.
; To make new screens: Start a new dwg & draw a line from 0,0 to 1,0.
; Zoom Extents. This is the view the drawing must be ended with.
; Only lines are considered by brkout.lsp. Lines with a color of
; bylayer will be erased when hit. Other lines will be bounced off of.
; This line holds the location of the BRKOUT? dwgs on your drive.
(setq DWGDIR"C:/ACAD/")

;New *error* routine.
(defun BRKERR(STR)
(if(/= STR"quit / exit abort")
(prompt(strcat"\n oops ... ERROR: "STR)))
(repeat 4(entdel(entlast)))
(if FH(setq FH(close FH)))
(if REL10(command".UCS""P"))
(SYSVAR nil nil)
;My standard system variable routine.
;Uses SYSLST to store old settings.
(if(assoc SYM SYSLST)
(if(null(cdr(assoc SYM SYSLST)))
(setq SYSLST(subst(cons SYM(getvar SYM))(cons SYM nil)SYSLST)))
(setq SYSLST(cons(cons SYM(getvar SYM))SYSLST)))
(setvar SYM MODE))
(if(and(setq MODE(assoc SYM SYSLST))(cdr MODE))
(progn(setvar SYM(cdr MODE))
(setq SYSLST(subst(cons SYM nil)MODE SYSLST)))))
(T(foreach MODE SYSLST
(if(cdr MODE)(setvar(car MODE)(cdr MODE))))
(setq SYSLST nil))))

;Release 10?
(setq REL10(ver)CNT(strlen REL10))
(while(/=(substr REL10(setq CNT(1- CNT))1)" "))
(setq REL10(>=(atof(substr REL10(1+ CNT)))10.0))
(if REL10(command".UCS""W"))

;Make VIEW of current display to determine it's dimensions.

;Initialize stuff.
(setq VIEW(tblsearch"VIEW""$BRKOUT$")
VWCTR(cdr(assoc 10 VIEW))
VWHGT(cdr(assoc 40 VIEW))
VWWTH(if REL10(cdr(assoc 41 VIEW))
(getdist"\n enter your view width \050pick both edges of your display\051: "))
PDLSZ(/ VWWTH 25) ;Paddle width.
PDLHGT(-(cadr VWCTR)(* VWHGT 0.45))
DIST(/ VWWTH 40) ;Distance traveled each loop.

;Draw, color & hide 4 lines enclosing the display.
(list(-(car VWCTR)(* VWWTH 0.5))PDLHGT)
(list(-(car VWCTR)(* VWWTH 0.5))(+(cadr VWCTR)(* VWHGT 0.5)))
(list(+(car VWCTR)(* VWWTH 0.5))(+(cadr VWCTR)(* VWHGT 0.5)))
(list(+(car VWCTR)(* VWWTH 0.5))PDLHGT)"C")
(repeat 4
(setq ENT(entget(entlast)))
(entmod(if(assoc 62 ENT)
(subst(cons 62 2)(assoc 62 ENT)ENT)
(cons(cons 62 2)ENT)))
(entdel(cdr(assoc -1 ENT)))
(ssadd(cdr(assoc -1 ENT))SS))
(repeat 4
(entdel(setq ENT(ssname SS 0)))
(redraw ENT 2)
(ssdel(ssname SS 0)SS))
(setq BOTTOM(entlast))

;Routine to draw paddle. Passed 7 for white, -1 for erase.

;Main loop for each screen.
(while(setq FH(open(strcat DWGDIR"BRKOUT"(itoa BLOCK#)".DWG")"r"))

;Initialize stuff.
(setq FH(close FH)
PDLCTR(car VWCTR) ;X coord. of paddle center.
PT2(list PDLCTR(-(cadr VWCTR)(* VWHGT 0.4)));Current head of blip.
PT3 PT2 ;Current tail of blip.
ANG(* pi 0.375) ;Current direction of blip.
PT1(polar PT2 ANG DIST) ;Potential head of blip. Gets adjusted by collisions.
SS(ssget"X"'((0 . "LINE")(62 . 256)))

;Insert screen.
(command".INSERT"(strcat"*"DWGDIR"BRKOUT"(itoa BLOCK#))
(list(-(car VWCTR)(* VWWTH 0.5))(-(cadr VWCTR)(* VWHGT 0.5)))VWHGT 0)

;BRKSS holds the ename of every erasable line.
(setq BRKSS(ssget"X"'((0 . "LINE")(62 . 256)))BLOCK#(1+ BLOCK#))
(if SS
(progn(command".SELECT"BRKSS"R"SS"")(setq BRKSS(ssget"P"))))
(grdraw PT3 PT2 -1)

;Start select command for the sole purpose of getting a pickbox.

;Main loop during play.
(while ENTLST

;If grread detects pointing device movement, erase old paddle & draw new one.
;For auto play: Replace (eq ... 5) with (setq PT(list 5 PT2))
(if(eq(car(setq PT(grread T)))5)
(setq PDLCTR(caadr PT))
(PADDLE 7)))

(if(and(setq SS(ssget"C"PT1 PT2))

;Find closest collision, if any actually happened.
(setq LST(list VWWTH nil nil)CNT -1)
(while(setq ENT(ssname SS(setq CNT(1+ CNT))))
(if(and(not(eq ENT ENTLST))
(eq(cdr(assoc 0(setq ENT(entget ENT))))"LINE")
(setq TEMP(inters PT1 PT2
(cdr(assoc 10 ENT))(cdr(assoc 11 ENT))T))
(<(setq TEMP1(distance PT2 TEMP))(car LST)))
(setq LST(list TEMP1(cdr(assoc -1 ENT))TEMP))))
(cadr LST)))

;Collision has occured.

;Erase old blip & draw new one.
(setq PT1(caddr LST))
(grdraw PT3 PT2 -1)
(grdraw PT1 PT2 -1)
(while(minusp ANG)(setq ANG(+ ANG(* pi 2))))

;Has blip hit bottom?
(if(eq(cadr LST)BOTTOM)

;Did blip miss the paddle?
(if(>(abs(- PDLCTR(caaddr LST)))PDLSZ)
(setq ENTLST nil)

;Set new ANG.
;A hit in the middle of the paddle sets ANG=incidence angle.
;A hit on either end of the paddle sets ANG=pi/8 or 7*pi/8.
;Other hits have their angle linearly adjusted by the distance from paddle center.
ANG(+(-(* pi 2)ANG)
(*(/(- PDLCTR(car PT1))PDLSZ)
(if(> ANG(* pi 1.5))(-(* pi 2)ANG)(- ANG pi)))))
(if(> ANG(/ pi 2))
(if(> ANG(* pi 0.875))(setq ANG(* pi 0.875)))
(if(< ANG(* pi 0.125))(setq ANG(* pi 0.125))))))

;Blip has hit a line. Set new ANG=incidence angle.
(setq ANG(-(*(rem(angle(cdr(assoc 10(setq ENT(entget(cadr LST)))))
(cdr(assoc 11 ENT)))pi)2)ANG)

;If line collided with has color BYLAYER, it is deleted.
(if(null(assoc 62 ENT))
(progn(entdel(cdr(assoc -1 ENT)))
(ssdel(cdr(assoc -1 ENT))BRKSS)
(if(null(ssname BRKSS 0))(setq ENTLST nil)))))))

;No collision. Draw new blip.
(progn(grdraw PT3 PT2 -1)(grdraw PT1 PT2 -1)))

;Juggle points around, loop again.
(setq PT3 PT2 PT2 PT1 PT1(polar PT2 ANG DIST)))

;End of screen. Erase paddle & blip.
(grdraw PT3 PT2 -1)

;BYLAYER lines still exist?
(if(ssname BRKSS 0)
(prompt"\n oops... You lose!\n")
(setq BLOCK# 32767)))

;Erase all lines remaining on screen, loop & insert next screen.

;End of play. Made it through all screens?
(if(null(ssname BRKSS 0))
(prompt"\nWe have a BIG winner! You get a FREE GAME!"))

;Use *error* to tidy up.

  3 Responses to “Category : Printer + Display Graphics
Archive   : BRKOUT.ZIP
Filename : BRKOUT.LSP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: