@Brazos
There are a few things I think may be going on here.
You are using sync on: backdrop on when you are only working in 2d. I'm guesing you are using that because it automatically clears the screen as you go. However, it may be the cause of flickering on other computers.
There is a file that lives in the same directory as DB.exe. It is called Setup.ini . If you open the file, there is a setting labeled
blitflipmode. For most modern computers this setting should be
blitflipmode=1
This helps to control how the screen is redrawn between 2d and 3d, and since you are invoking 3d with the
backdrop on command, others are seeing the flickering of the redraw when their blitflipmode=1 . It is likely that you either do not have a Setup.ini file or your blitflipmode=0 in which case you aren't seeing the flickering.
If you were distributing an executable, you would also want to distribute a copy of the setup.ini with the settings you have so that that your app behaves the same on a different computer. This mainly affects how the drawing is done between 2d and 3d and agin, because you are using backdrop on, you are invoking 3d.
Check out this link:
Getting Started with DBC
and read through the attachment of how to optimize DBC, which includes a section on the Setup.ini .
I set the blitflipmode=0 and the flashing stopped, except for the drawing cursor; but normally I have it set to 1.
As far as drawing on a background bitmap, I modified your program slightly. I remmed out the backdrop on and used a cls in the mainloop. I also added a line at the end of your Setup subroutine and added a line to the bottom of your main loop.
By creating the bitmap in the setup, the current drawing surface is set to that bitmap unless I change the surface with SET CURRENT BITMAP . In the main loop, I just copy from the background bitmap to bitmap 0 : Copy bitmap 1,0 . Because I eliminated backdrop on , I can run the app without flickering regardless of my setup.ini settings.
gosub set_up
Do
rem added by latch
cls
xp=mousex():yp=mousey():mc=mouseclick()
gosub get_info
paste image canvas_area,0,0
paste image top_image,0,5
paste image sprite_area, 533,373
stretch sprite 1,sprx,spry
sprite 1,586-(sprite width(1)/2),426-(sprite height(1)/2),sprite_pic
rem sets modes and changes what happens on the screen
if mc=1 and mode$<>"onlyx" and mode$<>"onlyy" then mode$="draw"
if mc=2 then mode$="select"
if mc=4 then mode$="eraser"
if inkey$()="d" then mode$="draw"
if inkey$()="f" and ke=0 then ke=1:flip sprite 1
if inkey$()="g" and ke=0 then ke=1:mode2$=mode$:mode$="guide"
if inkey$()="m" and ke=0 then ke=1:mirror sprite 1
if inkey$()="x" then mode$="onlyx":newyp=yp
if inkey$()="y" then mode$="onlyy":newxp=xp
if controlkey()=1 and mode$="select" then selx=15:sely=15
if controlkey()=1 and mode$="eraser" then erax=10:eray=10
if controlkey()=1 and mode$="draw" then sprx=100:spry=100
if inkey$()="p" and ke=0
ke=1
paste image clear_screen,0,57
endif
if inkey$()="q" and ke=0
ke=1
gosub new_top_image
endif
rem save image
if inkey$()="s" and ke=0
ke=1
gosub save_pic
endif
rem selecter control
rem fast control
if mode$="select"
if leftkey()=1 then dec selx,1
if rightkey()=1 then inc selx,1
if downkey()=1 then dec sely,1
if upkey()=1 then inc sely,1
endif
rem slow control
if mode$="select"
if inkey$()="1" and ke=0 then ke=1:dec selx,1
if inkey$()="4" and ke=0 then ke=1:inc selx,1
if inkey$()="2" and ke=0 then ke=1:dec sely,1
if inkey$()="5" and ke=0 then ke=1:inc sely,1
endif
rem sprite size control
rem fast control
if mode$="draw" or mode$="onlyx" or mode$="onlyy"
if leftkey()=1 then dec sprx,1
if rightkey()=1 then inc sprx,1
if downkey()=1 then dec spry,1
if upkey()=1 then inc spry,1
endif
rem slow control
if mode$="draw" or mode$="onlyx" or mode$="onlyy"
if inkey$()="1" and ke=0 then ke=1:dec sprx,1
if inkey$()="4" and ke=0 then ke=1:inc sprx,1
if inkey$()="2" and ke=0 then ke=1:dec spry,1
if inkey$()="5" and ke=0 then ke=1:inc spry,1
endif
rem eraser size control
rem fast control
if mode$="eraser"
if leftkey()=1 then dec erax,1
if rightkey()=1 then inc erax,1
if downkey()=1 then dec eray,1
if upkey()=1 then inc eray,1
endif
rem slow control
if mode$="eraser"
if inkey$()="1" and ke=0 then ke=1:dec erax,1
if inkey$()="4" and ke=0 then ke=1:inc erax,1
if inkey$()="2" and ke=0 then ke=1:dec eray,1
if inkey$()="5" and ke=0 then ke=1:inc eray,1
endif
rem check sizes
if selx<1 then selx=1
if selx>50 then selx=50
if sely<1 then sely=1
if sely>50 then sely=50
if erax<1 then erax=1
if erax>50 then erax=50
if eray<1 then eray=1
if eray>50 then eray=50
if sprx<10 then sprx=10
if sprx>100 then sprx=100
if spry<10 then spry=10
if spry>100 then spry=100
rem image selecter ghost
if mode$="select"
sprx=100:spry=100
get image whole_screen,0,0,639,370
ink rgb(200,200,200),0
line xp-selx,yp-sely,xp+selx,yp-sely
line xp+selx,yp-sely,xp+selx,yp+sely
line xp+selx,yp+sely,xp-selx,yp+sely
line xp-selx,yp+sely,xp-selx,yp-sely
sync
paste image whole_screen,0,0
endif
rem image selecter gets image inside of white square
if mc=2 and xp>(selx) and yp>sely and xp<639 and yp<450 and mode$="select"
get image whole_screen,0,0,639,479
ink rgb(200,200,200),0
line xp-selx,yp-sely,xp+selx,yp-sely
line xp+selx,yp-sely,xp+selx,yp+sely
line xp+selx,yp+sely,xp-selx,yp+sely
line xp-selx,yp+sely,xp-selx,yp-sely
paste image whole_screen,0,0
gosub get_info
sync
if xp+selx<640 and xp-selx>-1 and yp+sely<480 and yp-sely>-1
get image sprite_pic,xp-(selx+1),yp-(sely+1),xp+(selx-1),yp+(sely-1)
endif
endif
rem puts ghost image of sprite at mouse position
if mode$="draw" or mode$="onlyx" or mode$="onlyy"
get image whole_screen,0,0,639,370
paste sprite 1,xp-(sprite width(1)/2),yp-(sprite height(1)/2)
sync
paste image whole_screen,0,0
endif
rem paste sprite with leftclick
if mc=1 and xp>0 and yp>57 and xp<639 and yp<450 and mode$="draw"
paste sprite 1,xp-(sprite width(1)/2),yp-(sprite height(1)/2)
endif
rem paste sprite horizonially with leftclick
if mc=1 and xp>0 and yp>57 and xp<639 and yp<450 and mode$="onlyx"
paste sprite 1,xp-(sprite width(1)/2),newyp-(sprite height(1)/2)
endif
rem paste sprite vertically with leftclick
if mc=1 and xp>0 and yp>57 and xp<639 and yp<450 and mode$="onlyy"
paste sprite 1,newxp-(sprite width(1)/2),yp-(sprite height(1)/2)
endif
rem ghost eraser
if mode$="eraser"
get image whole_screen,0,0,639,370
ink rgb(100,255,100),0
box xp-erax,yp-eray,xp+erax,yp+eray
sync
paste image whole_screen,0,0
endif
rem erases with middleclick
if mc=4 and xp>erax-1 and yp>eray-1 and xp<(639-erax) and yp<(550-eray) and mode$="eraser"
ink rgb(200,200,200),0
box xp-erax,yp-eray,xp+erax,yp+eray
get image whole_screen,0,0,639,479
paste image whole_screen,0,0
gosub get_info
sync
ink 0,0
box xp-erax,yp-eray,xp+erax,yp+eray
endif
rem when the letter 'g' is pressed it brings up the guide
if mode$="guide"
get image whole_screen,0,0,639,479
repeat
paste image whole_screen,0,0
paste image draw_guide,0,0
sync
until spacekey()=1
mode$=mode2$
paste image whole_screen,0,0
endif
rem controls mouse clicks and keys pressed
if mc=0 and mke=1 then mke=0
if inkey$()="" and ke=1 then ke=0
rem gets an image of the canvas area
get image canvas_area,0,0,639,370
rem added by latch
copy bitmap 1,0
sync
loop
end
set_up:
randomize timer()
cls 0
sync on
`backdrop on
`color backdrop 0
rem added by latch
create bitmap 1,screen width(),screen height()
rem images
draw_guide=7
ink rgb(150,150,250),0
text 0,0,"Left click will paste the sprite to canvas."
text 0,12,"Middle click will erase areas of the drawing from the screen."
text 0,24,"Right click will select a new sprite from anywhere on the screen."
text 0,36,"Right/left/up/down keys will change the size of the sprite, the selection or the eraser."
text 0,48,"The letter 'd' will draw the sprite to the screen."
text 0,60,"The letter 'f' will flip the sprite."
text 0,72,"The letter 'm' will mirror the sprite."
text 0,84,"The letter 'p' will clear the drawing area."
text 0,96,"The letter 'q' will make a new image at the top of the screen."
text 0,108,"The letter 'x' will draw only horizonally from the cursor position at the time the 'x' is pressed."
text 0,120,"The letter 'y' will draw only vertically from the cursor position at the time the 'y' is pressed."
text 0,132,"The letter 'g' will bring up the draw instructions (or guide)."
text 0,144,"The controlkey will resize the selection, the sprite or the eraser back to original size."
text 0,156,"The image at the top is to be used by the select tool to select various colors."
text 0,168,"If you do not find the color you are looking for then press the letter 'q' to change the top image."
text 0,180,"Select the dots for smaller drawing and the boxes for larger drawing."
text 0,192,"The letter 's' saves the image to your computer."
text 0,216,"Press spacekey to return to drawing."
get image draw_guide,0,0,639,250
cls 0
rem naming the images
canvas_area=1
sprite_pic=2
whole_screen=3
sprite_area=4
top_image=5
clear_screen=6
rem making and getting images
get image canvas_area,0,0,639,370
get image clear_screen,0,57,639,370
gosub new_top_image
sprite 1,0,0,sprite_pic
set sprite 1,0,1
ink rgb(255,255,255),0
box 533,373,638,478
ink 0,0
box 534,374,637,477
get image sprite_area,533,373,639,479
cls 0
rem varibles
selx=15:sely=15:sprx=100:spry=100:erax=10:eray=10:mode$="draw"
return
get_info:
ink rgb(150,150,250),0
text 0,416,"mousex= "+str$(xp)+" mousey= "+str$(yp)
text 0,428,"select x= "+str$(selx)+" select y= "+str$(sely)
text 0,440,"sprite x= "+str$(sprx)+" sprite y= "+str$(spry)
text 0,452,"eraser x= "+str$(erax)+" eraser y= "+str$(eray)
text 230,416,"mode= "+mode$
text 230,428,"left click=draw"
text 230,440,"middle click=eraser"
text 230,452,"right click=select"
text 230,464,"Press the letter "g" for full instructions."
return
new_top_image:
ink 0,0
box 0,0,639,57
x=63
for t=1 to 100
ink rgb(rnd(255),rnd(255),rnd(255)),0
dot rnd(49)+2,rnd(49)
if t=1 then ink rgb(255,255,255),0
if t<20 then box x,0,x+25,25
if t<20 then dot x+12,40
x=x+30
next t
get image sprite_pic,2,0,50,52
get image top_image,0,0,639,52
ink 0,0
box 0,0,639,57
return
save_pic:
rem saves the artist's creation
get image whole_screen,0,0,639,479
get image 200,0,57,639,370
`sync off:backdrop off
cls 0
repeat
a$=inkey$()
until a$=""
ink rgb(200,200,200),0
namepic:
set cursor 0,12
input "Please type a name for your picture and press enter: ",F$
if file exist(F$+".bmp")=0
save image F$+".bmp",200
else
if file exist(F$+".bmp")=1
cls 0
set text font "system"
text 0,0,F$+".bmp already exists. Do you want to replace it with this picture?"
set cursor 0,12
input "Type n to rename this picture or y to replace picture under this name and press enter. ";choice$
if choice$="n"
cls 0
goto namepic
else
if choice$="y"
if file exist(F$+".bmp")=1
delete file F$+".bmp"
save image F$+".bmp",200
endif
endif
endif
endif
endif
`sync on:backdrop on
paste image whole_screen,0,0
sync
return
Enjoy your day.