BBC BASIC for Windows
« Adding Gaming blocks (anyone for Mario?) »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:58pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Adding Gaming blocks (anyone for Mario?)  (Read 333 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy Adding Gaming blocks (anyone for Mario?)
« Thread started 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
 
« Last Edit: Mar 8th, 2016, 2:12pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
cheesy Re: Adding Gaming blocks (anyone for Mario?)
« Reply #1 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
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy Re: Adding Gaming blocks (anyone for Mario?)
« Reply #2 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.
User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls