@bplus and I had a fun conversation in messages. I shared a program example that lends to the old way in QBASIC and explains a little more of why I posted the example code for my Tile Editor project.
@bplus felt we should share these code examples and I agreed. So, here are the code examples. I hope people that don't know about this find it interesting or helpful.
----------------------
Messages
----------------------
------------------------------------
Well, I did a test and it worked.
This part is in a bi file called test.bi
Here is a test program that used the DATA statement in the .bi file and saves the graphic to a binary image file.
'$INCLUDE: 'test.bi'
'put sprite information onscreen for capture
'capture the sprite
Get (1, 1)-(5, 5), sprite%
() 'tile now captured in sprite% array
'cover the screen with the tile image
I think in my tile editor I will use both save methods. A save to Data statements for a map and a save for tiles or sprites.
Have a good day!
--------------------------------------
Hi Mike,
Finally got some time to play with your code. It works for me but took me awhile to find where sprite file went (in QB64.exe folder).
I have two more Methods to do same thing for your consideration.
First a modified .bi file, same design different colors for my own tests of screen 12 capabilities:
notice the sprite: line label, this is what I was really curious about to see if RESTORE will work in the .BI file, apparently it works fine.
Here is the bas source for redrawing sprite right from BI, over and over again using a SUB.
That is Method 1 and I admit kind of crude and inefficient. I just wanted to see if it would work.
The 2nd is the modern way to create and capture an image and use over and over as demo'd here:
_Title "Test sprite bi, press any key for 2 methods of sprite display " 'b+ 2021-05-10
'$include: 'sprite.bi'
' Method 1
'cover the screen with the tile image
drawSprite x, y
' Method 2 of sprite drawing: draw one, capture in container spriteImg handle,
' use _putimage (x, y), spriteImg, 0 ' x, y top left corner of rectangle to place image
' to put anywhere on screen we want 0 is the handle for the screen
' setup to contain sprite image
spriteImg
= _NewImage(5, 5, 12) ' container size and color pallette 12 is like Screen 12's
drawSprite 0, 0 ' use first method to draw one sprite in upper left corner
_PutImage , 0, spriteImg
, (0, 0)-(4, 4) ' capture image in a spriteImg container ' (0, 0)-(4, 4) is the source on screen rectangle that we just drew one of
_PutImage (x
, y
), spriteImg
' now place image any where on screen
' Sub for Method 1 reads bi file and draws image every time its called
Restore sprite
' <<<<<<<<<<<<<<<<<<<<<<<<<<<< here is what I wanted to test from Bi Read icolor%:
PSet (xx
+ x
, yy
+ y
), icolor%
The first screen full is drawing from BI file over and over until filled.
press any key
The second screen fills the bottom right corner screen with the image with spriteImg handle
press key again and done.
Mike with your permission I'd like to post these two codes of ours on forum so people might learn past and present ways.
What do you think?
-----------------------------------
So, that was pretty much what we discussed and I will add this last bit of code that shows how to load the sprite.bsv file.
Well, that's about it for today.
Thanks for viewing!