BBC BASIC for Windows
« Getpic / Pastepic / movepic (kinda sprite like) »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:19pm



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: Getpic / Pastepic / movepic (kinda sprite like)  (Read 380 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
lamp Getpic / Pastepic / movepic (kinda sprite like)
« Thread started on: Aug 13th, 2016, 9:51pm »

getpic defines the image start point and assigns it a number (so we can manage many images
movepic moves the image using the number and destination
pastepic copies and pastes a copy of the image. But in this case the old and new images overlay, so it just moves


By the way, sprites are better. But if you aren't worried about overlays then this might work for some applications.

This is an experiment.
This looks promising alternative to sprites (kinda like the 80s GET and PUT image and paste commands )

Its a work in progress and any ideas will help me improve it.

Code:
      REM ha ha ha !!! silly me!! If num is not defined then it just cant work
      N%=0
      N%=20
      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
      OFF
      VDU 5
      DIM X(20),Y(20),H(20),V(20)
      PROCcolor("f","yellow")
      CIRCLE 100,100,50
      a=0:b=0:c=0:d=0:c=150:d=150:e=0:f=0:e=500:f=500
      REM RECTANGLE a,b,c,d TO e,f
      PROCgetpic(0,0,0,150,150)
      PROCmovepic(0,500,50)
      FOR X=10 TO 1000 STEP 5
        PROCpastepic(0,X,600)
        WAIT 1
      NEXT X
      FOR X=600 TO 1 STEP-1
        PROCpastepic(0,1000,X)
        WAIT 1
      NEXT X
      WAIT 1
      END
      REM getpic sorta functions like GET from the 80s but in this case it just assigns capture area information
      REM each getpic only needs to be called once, but you can reassign
      REM num refers to the variable arrays that will carry each image's capture point (it ranges from 0- 20)
      REM I guess h,v are the height and width of the image.
      DEFPROCgetpic(num%,xx,yy,hh,vv)
      N%=num%
      X(N%)=xx
      Y(N%)=yy
      H(N%)=hh
      V(N%)=vv
      ENDPROC
      REM Hmmm
      REM now that the image coordinates are stored, we can move it and redefine the borders
      DEFPROCpastepic(num%,nx,ny)
      LOCAL tx%,ty%,th%,tv%
      N%=num%
      tx%=X(N%)
      ty%=Y(N%)
      th%=H(N%)
      tv%=V(N%)
      RECTANGLE tx%,ty%,th%,tv% TO nx,ny
      X(N%)=nx
      Y(N%)=ny
      ENDPROC
      REM seems to work the same?
      DEFPROCmovepic(num,nx,ny)
      LOCAL tx%,ty%
      tx%=X(N%)
      ty%=Y(N%)
      RECTANGLE SWAP tx%,ty%,H(num),V(num) TO nx,ny
      X(N%)=nx
      Y(N%)=ny
      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$="magenta" 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 magenta" 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



 
« Last Edit: Aug 13th, 2016, 10:05pm by michael » 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