This is just a fun experiment in drawing off-screen and copying to on-screen. If its useful to anyone, then please use
Read the comments at the top of the code for more info on what this thing is all about (and how to use it)
rem Mysterious Pen
rem By Steve Paul Thomas
rem Demonstrates the use of copy bitmap.
rem Description:
rem A floating question mark on-screen appears to draw out curves, however
rem these curves are getting drawn to bitmap 1. After 10 seconds mystery drawing, whatever is drawn directly on
rem the bitmap 0 is blurred out and the contents of bitmap 1 is copied to bitmap 0. Revealing just what the
rem Mysterious Pen was drawing! The process repeats.
rem Press RETURN key to destroy pattern and reset it - this clears the off-screen bitmap.
rem Press SPACEBAR to wipe the screen of the pattern until the next swap occurs - then the bitmap is copied
rem from off-screen and is restored.
set display mode 640,480,16
sync on
sync rate 40
hide mouse
cls 0
rem Create bitmap 1, initially for drawing the sprites
rem Drawing operations are automatically switched to the new bitmap
create bitmap 1,640,480
cls 0
ink rgb(0,255,0),0
set text font "verdana"
set text size 14
for i = 1 to 10
numtowrite$ = str$(i)
text 0,0,numtowrite$
get image i,0,0,64,32
cls 0
next i
rem Create a pen that looks like a question mark - because the colours are randomised
set text size 22
sync
ink rgb(255,255,0),0
text 0,0,"?"
get image 11,0,0,32,32
cls 0
ink rgb(255,0,0),0
text 0,0,"SWAP!"
get image 12,0,0,128,32
cls 0
ink rgb(255,0,0),0
print "Try out the SPACEBAR AND RETURN KEYS"
get image 13,0,0,256,20
rem Bitmap 1 is now ready for swapping operations
cls rgb(50,50,100)
create bitmap 2,640,480
cls rgb(50,50,100)
rem Return drawing to the screen
set current bitmap 0
`v = 0
rem Coords
cx = 320
cy = 240
rem A variable multiplier - to allow the curves to be drawn out in interesting ways
multi = 100
rem Set the countdown to 10 seconds
countdown = 10
rem Grab the timer reading now
last_count = timer()
circlemode$ = "up"
do
cls
copy bitmap 2,0
set cursor 0,0
rem If one second (1000ms) has elapsed since the last recorded timer reading
if ((timer() - last_count) > 1000)
rem If counter is greater than zero
if countdown > 0
rem Decrement the counter and grab the current timer
dec countdown
last_count = timer()
else
rem Instead of numbers, write "SWAP!"
sprite 1,300,240,12
sync
rem Reset the countdown
countdown = 10
rem Blur the on-screen bitmap, copy the pattern that the pen was
rem drawing to the on-screen bitmap
blur bitmap 0,1
copy bitmap 1,0
rem Wait a bit
wait 1000
rem Record the current timer reading
last_count = timer()
endif
endif
gosub _spiro_drawing
rem The countdown
sprite 1,320,240,countdown
rem The mysterious pen
sprite 11,(cx+ox) -16,(cy+oy) - 16,11
rem The try keys prompt
sprite 13,175,450,13
rem Wipes the current screen until the next swap, and then the whole thing is restored
if spacekey()=1
set current bitmap 2
cls rgb(50,50,100)
set current bitmap 0
ink rgb(255,255,255),0
print "Resetting On-Screen bitmap, will restore it on next swap!"
sync
wait 1500
cls rgb(50,50,100)
endif
if returnkey()=1
set current bitmap 1
cls rgb(50,50,100)
set current bitmap 0
ink rgb(255,255,255),0
print "Resetting Off-screen bitmap"
sync
wait 1000
cls rgb(50,50,100)
endif
sync
copy bitmap 0,2
loop
rem Emergency exit
end
_spiro_drawing:
ox = cos(v) * multi
oy = sin(v) * multi
inc v
rem Draw a dot to the offscreen bitmap 1
set current bitmap 1
dot cx+ox,cy+oy
rem Return drawing to the on-screen bitmap
set current bitmap 0
randomize=timer()
adjred = rnd(20)
rem This code creates an interesting flower type effect
if multi < 200 and circlemode$ = "up"
inc multi
if multi = 200 then circlemode$ = "down"
endif
if multi > 100 and circlemode$ = "down"
dec multi
if multi = 100 then circlemode$ = "up"
endif
if (adjred = 5)
ink rgb(rnd(255),rnd(255),rnd(255)),0
endif
return
Also, constructive comments welcome
I don't Adam and believe it!