BBC BASIC for Windows
Programming >> Graphics and Games >> 4 way ball crack game v1
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1463700607

4 way ball crack game v1
Post by RockOve on May 19th, 2016, 11:30pm

Hi. here is my game. Anyone who know how to upload my parts to this code for demostrations purpose? (bmp files)

Code:
      install @lib$+"SPRITELIB"
      :
      if fn_initsprites(5) = 0 stop:rem five sprites is used. 0 to 4
      on close proc_exitsprites : quit
      on error on error off : proc_exitsprites : print 'report$ : end:rem dont use "run". close window, then run.
      rem loads sprites
      if fn_createspritefrombmp(0,"ball.bmp") = 0 error 0, "Cannot create sprite 0"
      if fn_createspritefrombmp(1,"brick1.bmp") = 0 error 0, "Cannot create sprite 1"
      if fn_createspritefrombmp(2,"brick1.bmp") = 0 error 0, "Cannot create sprite 2"
      if fn_createspritefrombmp(3,"brick2.bmp") = 0 error 0, "Cannot create sprite 3"
      if fn_createspritefrombmp(4,"brick2.bmp") = 0 error 0, "Cannot create sprite 4"
      :
      mode 20
      :rem background image     pos 0,0  1600 wide 1200 high
      *DISPLAY "background.bmp" 0,0,1600,1200
      :rem top n bottom track:(tubes) is "tracks"
      *DISPLAY "tubes.bmp" 250,30,1100,30:
      *DISPLAY "tubes.bmp" 250,1100,1100,30
      :rem left n right track
      *DISPLAY "tubes2.bmp" 70,0,30,1200
      *DISPLAY "tubes2.bmp" 1500,0,30,1200

      print tab(0,0);"mouse up and down. click to drop ball"
      : drop=false
      dim x%(5),y%(5)
      ball%=5
      dx%=1
      dy%=1

      off
      :rem repeat loop begins here
      repeat
        mouse mx%,my%,mb%:rem get mouse input
  
        if mb%<>0 drop=true
  
        if drop=false then
          x%(0)=mx%:rem ball
          y%(0)=my%:rem ball
          dx=(-1^rnd(10))*1:rem random +1 or -1
          dy=(-1^rnd(10))*1:rem random +1 or -1
        endif
  
        if drop=true then
          x%(0)=x%(0)+dx:rem ball is loose
          y%(0)=y%(0)+dy
        endif
  
  
        x%(1)=mx%-250:rem bottom bricks
  
        if x%(1)< 30 then x%(1)=30 :rem limits
        if x%(1)> 994 then x%(1)=994
        y%(1)=200:rem bottom bricks
        x%(2)= 1000-mx%:rem top bricks
        if x%(2)<30 then x%(2)=30:rem limits
        if x%(2)>994 then x%(2)=994:
        y%(2)=1150:rem rem top brick
  
        x%(3)= 30:rem left brics
        y%(3)=my%+250:rem left brics
        if y%(3)>1150 then y%(3)=1150:rem limits
        if y%(3)<582 then y%(3)=582:
  
        x%(4)=1380:rem right brics
        y%(4)=1150-my%+256
        if y%(4)>1150 then y%(4)=1150:rem limits
        if y%(4)<582 then y%(4)=582
  
        proc_movesprite(0,x%(0)-64,y%(0)+64,1):rem ball
        proc_movesprite(1,x%(1),y%(1),1):rem bottom brickwall, 1 is show,0 is hide
        proc_movesprite(2,x%(2),y%(2),1):rem topp brickwall
        proc_movesprite(3,x%(3),y%(3),1):rem left brickwall
        proc_movesprite(4,x%(4),y%(4),1):rem right brickwall
  
  
        rem if y%<
        if y%(0)<-38 or y%(0)>1212 or x%(0)<-38 or x%(0)>1600+38 then drop=false:rem ball out
        if y%(0)<238 and y%(0)>200 then
          rem did it hit a brickwall?
          if x%(0)>x%(1) and x%(0)<x%(1)+560 then dy=1
        endif
        :
        if y%(0)>960 and y%(0)<960+50 then
          if x%(0)>x%(2) and x%(0)<x%(2)+560 then dy=-1
        endif
        :
        if x%(0)<238 and x%(0)>200 then
          if y%(0)<y%(3) and y%(0)>y%(3)-560 then dx=1
        endif
        :
        if x%(0)>1350 and x%(0)<1350+50 then
          if y%(0)<y%(4) and y%(0)>y%(4)-560 then dx=-1
        endif
  
      until mb%=1:rem repate until right mouse button is pushed
      wait 100
      quit:rem closes output window
 

Re: 4 way ball crack game v1
Post by DDRM on May 20th, 2016, 08:21am

Hi RockOve,

One possibility would be to compile your game to a standalone executable, making sure that it includes the bitmaps, and then post that somewhere. Options have recently been discussed on Ric's strand "3D Gaming Project" - have a look there. An obvious new candidate is the new Groups.io site.

Alternatively, could you make an additional routine that can generate them on the fly?

Best wishes,

D