BBC BASIC for Windows
Programming >> Graphics and Games >> Adding Gaming blocks (anyone for Mario?)
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1457448519

Adding Gaming blocks (anyone for Mario?)
Post by michael on Mar 8th, 2016, 1:48pm

And there is many more to come!!
I started doing stuff like this because I wanted to find a way to make professional shapes for gaming but didn't want to use paint and didn't want to use Hexagon 3D or BLENDER and modify the images since there was at the time no way to import OBJ files.
( did play with interpreting the verticies but I didn't feel like dwelling on it long)
Perhaps, seeing as how BBC has a decent library of OpenGL examples, I may go back to it.
Code:
      
REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      OFF
      GCOL 1

      PROC_ellipsering(200,100,800,800,150,100,200,200,200,2)
      PROC_ellipsering(10,20,1100,400,200,100,200,50,200,2)
      PROC_ellipsering(50,200,150,400,200,100,50,145,50,2)

      PROC_sphere(200,700,50,100,200,100,3)
      PROC_sphere(800,500,250,200,150,200,1)
      PROC_sphere(600,500,300,150,150,200,1)
      PROC_sphere(500,300,300,200,200,200,1)
      FOR COUN= 100 TO 1000 STEP 50
        COL=COL+10
        IF COL>200 THEN COL=200
        PROC_block(COUN,50,20,200-COL,200,200-COL,8)
      NEXT COUN
      (mou)
      MOUSE x,y,b
      IF b=4 THEN PROC_sphere(x,y,50,100,200,100,3)
      GOTO (mou)
      END
      DEF PROC_block(H,V,SIZE,X,C,A,DI)
      P=SIZE/2
      FOR Y=1 TO SIZE
        COLOUR 1,X,C,A
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
        P=P-1
      NEXT Y
      ENDPROC

      DEF PROC_ellipsering(CENTERH,CENTERV,H,V,SIZE,THICKNESS,X,C,A,DI)
      IF SIZE > THICKNESS THEN SIZE = THICKNESS
      OC=THICKNESS/2
      OUTCENTERH=CENTERH+OC
      OUTCENTERV=CENTERV+OC
      R=0
      SWITCH=0
      DEPTHCOUNT=SIZE/2
      FOR Y=1 TO DEPTHCOUNT
        COLOUR 1,X,C,A
        ELLIPSE H,V,OUTCENTERH-R,OUTCENTERV-R
        ELLIPSE H,V,OUTCENTERH+R,OUTCENTERV+R
        R=R+1
        (leap)
        X=X-DI
        C=C-DI
        A=A-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
      NEXT Y
      ENDPROC

      ENDPROC
      DEF PROC_sphere(H,V,SIZE,R,G,B,DI)
      r%=R
      g%=G
      b%=B
      size%=SIZE
      dimmer%=DI
      FOR x%=0 TO size%
        c%=50
        r%=r%-dimmer%
        g%=g%-dimmer%
        b%=b%-dimmer%
        IF r% <2 THEN r%=2
        IF g% <2 THEN g%=2
        IF b%<2 THEN b%=2
        IF r%<50 AND g%<50 AND b%<50 THEN GOTO (jump)
        COLOUR 1,r%,g%,b%
        CIRCLE H,V,x%
        (jump)
      NEXT x%
      ENDPROC
 

Re: Adding Gaming blocks (anyone for Mario?)
Post by DDRM on Mar 8th, 2016, 5:02pm

Hi Michael,

There is a RECTANGLE function which might be useful in your blocks...

If you are interested in drawing nice shapes for a game or something, rather than the challenge of programming the drawing them, you might want to look at the Direct3D library. It's a bit complex to begin with, but the speed and power it offers is sensational once you get to grips with it.

On a completely different level, if you are interested here's a routine I wrote to generate "jewels" for a "bejewelled" clone:
Code:
      MODE 8
      FOR x%=1 TO 7
        PROCPoly(x%+2,0,50+120*x%,100,50,50,x%,x%+8)
      NEXT x%
      END
      :
      DEFPROCPoly(n%,starta,cx%,cy%,hr%,vr%,c1%,c2%)
      REM number of sides, start angle in radians, centre x and y, horizontal and vertical radii, main and highlight colours
      LOCAL a%,dx%,dy%
      REM Draw basic shape
      GCOL c1%
      FOR a%=0 TO n%-1
        MOVE cx%,cy%
        dx%=hr%*COS(2*PI*a%/n%+starta)
        dy%=vr%*SIN(2*PI*a%/n%+starta)
        MOVE cx%+dx%,cy%+dy%
        dx%=hr%*COS(2*PI*(a%+1)/n%+starta)
        dy%=vr%*SIN(2*PI*(a%+1)/n%+starta)
        PLOT 85,cx%+dx%,cy%+dy%
      NEXT a%
      REM add radii in highlight colour
      GCOL c2%
      FOR a%=0 TO n%-1
        dx%=hr%*COS(2*PI*a%/n%+starta)
        dy%=vr%*SIN(2*PI*a%/n%+starta)
        LINE cx%,cy%,cx%+dx%,cy%+dy%
      NEXT a%
      REM Draw a front facet half the size
      hr% DIV=2
      vr% DIV=2
      FOR a%=0 TO n%-1
        MOVE cx%,cy%
        dx%=hr%*COS(2*PI*a%/n%+starta)
        dy%=vr%*SIN(2*PI*a%/n%+starta)
        MOVE cx%+dx%,cy%+dy%
        dx%=hr%*COS(2*PI*(a%+1)/n%+starta)
        dy%=vr%*SIN(2*PI*(a%+1)/n%+starta)
        PLOT 85,cx%+dx%,cy%+dy%
      NEXT a%
      ENDPROC
 

Best wishes,

D
Re: Adding Gaming blocks (anyone for Mario?)
Post by michael on Mar 8th, 2016, 5:25pm

Very nice. If you want I could modify the shapes you posted to give them some glassy looks if you are offering them to the public.
I am mostly a hobby programmer, but I plan to one day make a unique game that is ground breaking..

(that's a tough thing to do nowadays)

And the 3D world has always interested me.
The one thing with OpenGL was that I had troubles plotting my object location in the 3D world...

Modifying the Object was fairly reasonable and adding a texture was achievable... It was just the location in the world and driving through it.