hah,i only had 4 hours sleep and forgot to paste the code did I? lol, anyhow I changed it to that and still just a black block to 'stamp' after (o)pening an image
here is the code this time:
// Project: Dope
// Created: 2014-09-29
// set window properties
SetWindowTitle( "Dope" )
SetDisplayAspect( 800.0 / 600.0 )
SetGlobal3DDepth(10000)
#constant KEY_BACK = 8
#constant KEY_TAB = 9
#constant KEY_ENTER = 13
#constant KEY_SHIFT = 16
#constant KEY_CONTROL = 17
#constant KEY_ESCAPE = 27
#constant KEY_SPACE = 32
#constant KEY_PAGEUP = 33
#constant KEY_PAGEDOWN = 34
#constant KEY_END = 35
#constant KEY_HOME = 36
#constant KEY_LEFT = 37
#constant KEY_UP = 38
#constant KEY_RIGHT = 39
#constant KEY_DOWN = 40
#constant KEY_INSERT = 45
#constant KEY_DELETE = 46
#constant KEY_0 = 48
#constant KEY_1 = 49
#constant KEY_2 = 50
#constant KEY_3 = 51
#constant KEY_4 = 52
#constant KEY_5 = 53
#constant KEY_6 = 54
#constant KEY_7 = 55
#constant KEY_8 = 56
#constant KEY_9 = 57
#constant KEY_A = 65
#constant KEY_B = 66
#constant KEY_C = 67
#constant KEY_D = 68
#constant KEY_E = 69
#constant KEY_F = 70
#constant KEY_G = 71
#constant KEY_H = 72
#constant KEY_I = 73
#constant KEY_J = 74
#constant KEY_K = 75
#constant KEY_L = 76
#constant KEY_M = 77
#constant KEY_N = 78
#constant KEY_O = 79
#constant KEY_P = 80
#constant KEY_Q = 81
#constant KEY_R = 82
#constant KEY_S = 83
#constant KEY_T = 84
#constant KEY_U = 85
#constant KEY_V = 86
#constant KEY_W = 87
#constant KEY_X = 88
#constant KEY_Y = 89
#constant KEY_Z = 90
#constant KEY_F1 = 112
#constant KEY_F2 = 113
#constant KEY_F3 = 114
#constant KEY_F4 = 115
#constant KEY_F5 = 116
#constant KEY_F6 = 117
#constant KEY_F7 = 118
#constant KEY_F8 = 119
#constant KEY_PERIOD = 190
#constant KEY_SLASH = 191
global gridx# = 2.0
global gridy#=2.0
global cursorsprite = 5000
global cursorimage = 2
global mode = 0
global bricknum = 0
global brickcount = 0
global bricklimit = 4999
global addx = 4
global addy = 4
global layernum = 0
global physicsmode = 0
global physicsshape = 2
global swidth = 4
global sheight = 4
global spritetype = 0
global spritegroup = 0
global quit = 0
global physicsmode$ = ""
global type$ = "Generic Object"
global level = 1
global maxscroll=400
global minscroll=0
global ohx#
global ohy#
global imagepointer = 1
global imagecounter = 0
type tobjects
xpos# as float
ypos# as float
spritenumber as integer
physicstype as integer
spriteshape as integer
sizex as integer
sizey as integer
imagenum as integer
sprgroup as integer
sprdepth as integer
spriteangle as integer
spritetype as integer
spritelayer as integer
endtype
dim object[5000] as tobjects
dim image_bank[800]
type TMouse
x1#
y1#
x2#
y2#
x3
y3
endtype
global Mouse as TMouse
dim deleted[5000]
init()
repeat
x#=getvirtualjoystickx(1)
y#=getvirtualjoysticky(1)
ohx#=getspritex(cursorsprite)
ohy#=getspritey(cursorsprite)-1
if x#<>0 or y#<>0
scrollx#=scrollx#+x#
scrolly#=scrolly#+y#
if scrollx#>maxscroll
scrollx#=maxscroll
endif
if scrollx#<minscroll
scrollx#=minscroll
endif
if scrolly#>maxscroll
scrolly#=maxscroll
endif
if scrolly#<minscroll
scrolly#=minscroll
endif
y1=y1-scrolly#
x1=x1-scrollx#
SetViewOffset( scrollx#,scrolly# )
endif
select physicsmode
case 0
physicsmode$ = "None"
endcase
case 1
physicsmode$ = "Static"
endcase
case 2
physicsmode$ = "Dynamic"
endcase
case 3
physicsmode$ = "Kinematic"
endcase
endselect
control()
input()
setspriteposition(cursorsprite,Mouse.x3,Mouse.y3)
print("Mode = "+ str(mode))
print ("Physics Mode = "+ physicsmode$)
Print( "Physics Shape = "+ str(physicsshape))
print( "Object type = " +type$)
print ("Object Group = "+ str( spritegroup))
print ("Image number = "+ str (image_bank[imagecounter]))
Sync()
until quit = 1
function input()
if getrawkeypressed(KEY_E)
inc mode
if mode>1
mode = 0
endif
endif
if getrawkeypressed(KEY_Q)
quit = 1
endif
if getrawkeypressed(KEY_D)
swidth = swidth + addx
setspritesize(cursorsprite,swidth,sheight)
endif
if getrawkeypressed(KEY_A) and swidth>4
swidth = swidth - addx
setspritesize(cursorsprite,swidth,sheight)
endif
// ********* Adjust object height **********
if GetRawKeyPressed(KEY_S)
sheight = sheight + addy
setspritesize(cursorsprite,swidth,sheight)
endif
if GetRawKeyPressed(KEY_W) and sheight>4
sheight = sheight - addy
setspritesize(cursorsprite,swidth,sheight)
endif
//*******************************************
if getrawkeypressed(KEY_M)
physicsmode = physicsmode +1
if physicsmode >3
physicsmode = 0
endif
endif
if GetRawKeyPressed(KEY_F2)
save_level(level)
endif
if GetRawKeyPressed(KEY_F1)
load_level(level)
endif
if GetRawKeyPressed(KEY_C)
clear_level()
endif
if getrawkeypressed(KEY_T) and spritetype>0
dec spritetype
select spritetype
case 0
type$="Generic Object"
endcase
case 1
type$="Baddie Object"
endcase
case 2
type$="Player Object"
endcase
case 3
type$="Bonus Object"
endcase
case 4
type$="Game Start"
endcase
case 5
type$="Game End"
endcase
endselect
endif
if getrawkeypressed(KEY_Y) and spritetype <5
inc spritetype
select spritetype
case 0
type$="Generic Object"
endcase
case 1
type$="Baddie Object"
endcase
case 2
type$="Player Object"
endcase
case 3
type$="Bonus Object"
endcase
case 4
type$="Game Start"
endcase
case 5
type$="Game End"
endcase
endselect
endif
if getrawkeypressed(KEY_PERIOD) and spritegroup>0
dec spritegroup
endif
if getrawkeypressed(KEY_SLASH) and spritegroup<10
inc spritegroup
endif
if GetRawKeyPressed(KEY_Z) and imagecounter>0
dec imagecounter
cursorimage =image_bank[imagecounter]
setspriteimage(cursorsprite,cursorimage)
setspritedepth(cursorsprite,0)
sync()
endif
if GetRawKeyPressed(KEY_X) and image_bank[imagecounter+1] <>0
inc imagecounter
cursorimage =image_bank[imagecounter]
setspriteimage(cursorsprite,cursorimage)
setspritedepth(cursorsprite,0)
sync()
endif
if getrawkeypressed(KEY_O)
choose_image()
setspriteimage(cursorsprite,image_bank[imagepointer])
cursorimage = image_bank[imagepointer]
endif
endfunction
function control()
FillMouse(gridx#,gridy#)
state=getpointerpressed()
if state = 1
select mode
case 0
for n = 1 to bricklimit
if object[n].xpos# = Mouse.x3 and object[n].ypos# = Mouse.y3 and object[n].spritenumber <>0
found=1
f=object[n].spritenumber
exit
endif
next n
if found=0 and brickcount<bricklimit
for n=1 to bricklimit
if deleted[n] >0
founddeleted=1
sprnum=n
exit
endif
next
if founddeleted =0
inc brickcount
inc bricknum
id2=bricknum
else
id2=sprnum
inc brickcount
deleted[sprnum]=0
Endif
if getspriteexists(id2) = 0
object[id2].xpos# = Mouse.x3
object[id2].ypos# = Mouse.y3
object[id2].spritenumber = id2
object[id2].imagenum = cursorimage
object[id2].sizex=swidth
object[id2].sizey=sheight
object[id2].physicstype = physicsmode
object[id2].spriteshape=physicsshape
object[id2].sprdepth =2
object[id2].spritetype = spritetype
object[id2].sprgroup=spritegroup
object[id2].spritelayer=layernum
createsprite(id2,cursorimage)
setspritesize(id2,object[id2].sizex,object[id2].sizey)
print("sprite number "+str(object[id2].spritenumber))
setspriteangle(id2,getspriteangle(cursorsprite))
object[id2].spriteangle= getspriteangle(id2)
setspriteposition(id2,object[id2].xpos#,object[id2].ypos#)
setspritedepth(id2,object[id2].sprdepth)
endif
endif
endcase
case 1
r=getspritehit(getspritex(cursorsprite),getspritey(cursorsprite))
if object[r].spritelayer = 0
if getspriteexists(r)
deletesprite(r)
object[r].xpos# = 0
object[r].ypos# = 0
object[r].spritenumber = 0
object[r].imagenum = 0
object[r].physicstype = 0
object[r].sprdepth = 1
object[r].spritelayer = 0
deleted[r]=1
dec brickcount
endif
endif
endcase
endselect
endif
endfunction
function FillMouse(gridx#,gridy#)
Mouse.x1#=getpointerx()
Mouse.y1#=getpointery()
Mouse.x2#=screentoworldx(Mouse.x1#)
Mouse.y2#=screentoworldy(Mouse.y1#)
Mouse.x3=floor(Mouse.x2#/gridx#)*gridx#
Mouse.y3=floor(Mouse.y2#/gridy#)*gridy#
endfunction
function init()
`LoadImage(1,"cursorimage.png")
`loadimage(2,"bricks.png")
`image_bank[0] = 1
`image_bank[1] = 2
`imagepointer = 2
SetClearColor(255,0,0)
ClearScreen()
imagecounter=imagepointer
createsprite(cursorsprite,cursorimage)
setspritesize(cursorsprite,swidth,sheight)
AddVirtualJoystick(1,10,88,12)
endfunction
function save_level(level)
f$=""
f$="level"
f$=f$+str(level)
f$=f$+".dat"
myfile=opentowrite(f$,0)
for n = 1 to bricklimit
writefloat(myfile,object[n].xpos#)
writefloat(myfile,object[n].ypos#)
writeinteger(myfile,object[n].spritenumber)
writeinteger(myfile,object[n].physicstype)
writeinteger(myfile,object[n].spriteshape)
writeinteger(myfile,object[n].sizex)
writeinteger(myfile,object[n].sizey)
writeinteger(myfile,object[n].imagenum)
writeinteger(myfile,object[n].sprgroup)
writeinteger(myfile,object[n].sprdepth)
writeinteger(myfile,object[n].spriteangle)
writeinteger(myfile,object[n].spritetype)
writeinteger(myfile,object[n].spritelayer)
next n
endfunction
function load_level(level)
clear_level()
f$=""
f$="level"
f$=f$+str(level)
f$=f$+".dat"
if getfileexists(f$) =0
print (" level file doesn't exist ")
sync()
sleep (3000)
found3=1
endif
if found3=0
myfile = OpenToread(f$)
for n=1 to bricklimit
xp#=readfloat(myfile)
yp#=readfloat(myfile)
sprnum=readinteger(myfile)
phytype=readinteger(myfile)
sprshape=readinteger(myfile)
sx=readinteger(myfile)
sy=readinteger(myfile)
imgnum=readinteger(myfile)
sprgroup=readinteger(myfile)
sprdepth=readinteger(myfile)
sprangle=readinteger(myfile)
sprtype=readinteger(myfile)
sprlayer=readinteger(myfile)
object[n].xpos#=xp#
object[n].ypos#=yp#
object[n].spritenumber=sprnum
object[n].physicstype=phytype
object[n].spriteshape=sprshape
object[n].sizex = sx
object[n].sizey = sy
object[n].imagenum=imgnum
object[n].sprgroup=sprgroup
object[n].sprdepth=sprdepth
object[n].spriteangle=sprangle
object[n].spritetype=sprtype
object[n].spritelayer=sprlayer
if object[n].spritenumber>0
createsprite(sprnum,imgnum)
setspritesize(sprnum,sx,sy)
setspriteposition(sprnum,xp#,yp#)
endif
next n
endif
endfunction
function clear_level()
for n=1 to bricklimit
object[n].xpos#=0
object[n].ypos#=0
object[n].spritenumber=0
object[n].physicstype=0
object[n].spriteshape=0
object[n].sizex = 0
object[n].sizey = 0
object[n].imagenum=0
object[n].sprgroup=0
object[n].sprdepth=0
object[n].spriteangle=0
object[n].spritetype=0
object[n].spritelayer=0
deletesprite(n)
next n
endfunction
function choose_image()
ok = ShowChooseImageScreen()
if ok = 1
rem now wait for the image to be chosen
while IsChoosingImage() = 1
sync()
endwhile
rem get the image but check that one was chosen
imageID = GetChosenImage()
if imageID = 0
message( "No image chosen" )
else
`message( "Image ID: " + str(imageID) )
image_bank[imagepointer] = imageID
cursorimage =imageID
setspriteimage(cursorsprite,cursorimage)
setspritedepth(cursorsprite,0)
inc imagepointer
endif
endif
endfunction
Again this can simply be pasted and ran
Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk