BBC BASIC for Windows
Programming >> Graphics and Games >> 80s style game template.. and PSET returns.
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1468808199

80s style game template.. and PSET returns.
Post by michael on Jul 18th, 2016, 02:16am

NOTE: This program has the enhanced PROCcolor tool included.. (makes color selection super easy) ENJOY!!

Welcome to my new project. My first game since 1990. I even created PSET in a new command to allow simple creations in the maze.
If you want to make a game using these tools, feel free to do so.. I would love to try out your adventure.
Code:
      REM       width;height;charwidth,charheight,number of colors,character set
      VDU 23,22,1024;600;8,15,16,1 :REM max width is 1920 and 1440 height
      REM Turn off the text cursor _
      REM OFF
      VDU 5 : REM Treat text as graphics (transparent background)
      PROCwalls
      PROCnorth
      PROCsouth
      PROCeast
      PROCwest
      PROCpset(500,500,"green")
      PROCcolor("f","255,255,255"):PROCcolor("b","0,0,0")
      MOVE 10,200:INPUT "WHAT TO DO (type help for keywords) ? " A$
      WAIT 0
      END
      REM c$ can be colors like blue or 1 or a R,G,B color
      DEF PROCpset(x%,y%,c$)
      LOCAL h%
      PROCcolor("f",c$)
      FOR h%=0 TO 20
        LINE x%+h%,y%,x%+h%,y%+20
      NEXT
      ENDPROC
      DEF PROCwest
      PROCsbox(1420,1000,1450,500)
      DEF PROCeast
      PROCsbox(50,1000,80,500)
      ENDPROC
      DEF PROCsouth
      PROCsbox(500,350,1000,320)
      ENDPROC
      DEF PROCnorth
      PROCsbox(500,1150,1000,1120)
      ENDPROC
      DEF PROCwalls
      PROCsbox(0,1200,1500,1160)
      PROCsbox(0,300,1500,260)
      PROCsbox(0,1160,40,300)
      PROCsbox(1460,1160,1500,300)
      ENDPROC
      DEF PROCsbox(x%,y%,w%,h%)
      LOCAL ry%,sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      ry%=y%
      PROCcolor("f","255,255,255")
      REPEAT
        LINE x%,y%,w%,y%
        y%=y%+1
      UNTIL y%=h%
      y%=ry%
      PROCcolor("f","000,000,000")
      LINE x%+2,y%+2,w%-2,y%+2
      LINE w%-2,y%+2,w%-2,h%-4
      LINE w%-2,h%-4,x%+2,h%-4
      LINE x%+2,h%-4,x%+2,y%+2
      ENDPROC
      REM color "F"or"B", "color name number or R G B"
      REM this was created to manage special colors and to hold onto the original first 2 pallets (as I use them all the time)
      DEF PROCcolor(fb$,rgb$)
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magneta" OR rgb$="purple" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magnetta" OR rgb$="light purple" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      PRIVATE assemble$,br%,bg%,bb%
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
      REM X,Y,text color,message,r,g,b
      REM ************************************************************************
      DEF PROCpr(X,Y,msg$,r,g,b)
      LOCAL initialx%,fi%,reduction%,tx,ty
      initialx%=LEN(msg$)
      COLOUR 0,r,g,b
      GCOL 0
      LET tx= X+initialx%+25
      LET ty= Y:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      FOR fi%=12 TO 48
        LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
      NEXT
      COLOUR 0,0,0,0
      GCOL 0
      MOVE tx,ty
      PRINT msg$
      MOVE 0,0 REM hide that thing
      ENDPROC