Not until I downloaded the new pack did I notice I never uploaded the newest build of the editor (sorry all)
attacked is the overlays with a pink background, the disect function loads the file into a bitmap so it loses transparency.
I will get to adding in some more features with what Dave has added, this may cause the file format to change but I will leave in a "legacy" option to import levels under an older format if needed.
set display mode 800,600,32
set image colorkey 255,0,255
type bit
image as integer
xpos as integer
ypos as integer
Brick_Number as integer
endtype
type format
red as byte
blue as byte
green as byte
hits as byte
points as integer
special as integer
endtype
dim brick_data(9) as format
dim brick(-1) as bit
dim grid(25,29)
dim special$(6)
Global Grid_x
Global Grid_y
Global Brick_Number
Global CURRENT_BRICK=2
Global GRID_ON
Global Level_Number=1
for a = 0 to 9
read brick_data(a).red:read brick_data(a).blue:read brick_data(a).green
read brick_data(a).hits:read brick_data(a).special:read brick_data(a).points
makebrick(brick_data(a).red, brick_data(a).blue, brick_data(a).green,36,14,a+2)
next a
for a = 0 to 6
read special$(a)
next a
load image "editor_ui_sample.bmp",1,1
load image "brick_dlg1.png",100,1
disect("breakin_specials.png",1,15,200)
do
Draw_screen()
get_grid()
controls()
if array count(brick())>=0 then draw_bricks()
draw_brick_place()
sync
loop
function controls()
if mouseclick()=1 and gridx>=0 and grid_Y>=0 and grid_x<=28 and grid_y<25 then add_brick()
if mouseclick()=2 and gridx>=0 and grid_Y>=0 and grid_x<=28 and grid_y<25 then remove_brick()
if mouseclick()=1 and mousex()>=600 and mousex()<=638
my=mousey()
ypoint=(my-296)/24
if ypoint>=0 and ypoint<=9
if my>=296+(ypoint*24) and my<=310+ypoint*24 then CURRENT_BRICK=ypoint+2
endif
endif
if mouseclick()=1 and mousex()>=660 and mousex()<=660+text width("EDIT")
my=mousey()
ypoint=(my-298)/24
if ypoint>=0 and ypoint<=9
if my>=294+(ypoint*24) and my<=310+ypoint*24 then edit_brick(ypoint)
endif
endif
`text 700,20,"+":text 710,20,"-"
mx=mousex():my=mousey()
if mouseclick()=1 and mx>=725 and mx<=725+text width("+") and my>=125 and my<=125+Text height("+")
inc Level_Number
repeat:until mouseclick()=0
endif
if mouseclick()=1 and mx>=735 and mx<=735+text width("-") and my>=125 and my<=125+Text height("-")
dec Level_Number
if level_number<1 then level_number=1
repeat:until mouseclick()=0
endif
if mouseclick()=1 and mx>=720 and mx<=720+text width("CLEAR") and my >=150 and my<=150+text height("CLEAR")
empty array brick()
Brick_Number=0
endif
if mouseclick()=1 and mx>=625 and mx<=625+text width("LOAD") and my >=150 and my<=150+text height("LOAD")
import_level("level"+str$(level_number))
repeat:until mouseclick()=0
endif
if mouseclick()=1 and mx>=672 and mx<=672+text width("SAVE") and my >=150 and my<=150+text height("SAVE")
export_level("level"+str$(level_number))
repeat:until mouseclick()=0
endif
if mouseclick()=1 and mx>=672 and mx<=672+text width("GRID") and my >=170 and my<=170+text height("GRID")
if grid_on=0
grid_on=1
else
grid_on=0
endif
repeat:until mouseclick()=0
endif
endfunction
function Draw_Screen()
cls
paste image 1,0,0
text 625,125,"LEVEL: "+str$(level_number)
text 725,125,"+":text 735,125,"-"
text 625,150,"LOAD"
text 672,150,"SAVE"
text 672,170,"GRID"
text 720,150,"CLEAR"
if grid_on=0
ink rgb(255,255,0),0
for a = 0 to 25
line 15,184+a*16,585,184+a*16
next a
for b=0 to 30
line 15+b*19,184,15+b*19,584
next b
endif
for a = 2 to 11
paste image a,600,248+a*24,1
select brick_data(a-2).special
case 1: paste image 200,600,248+a*24,1:endcase
case 2: paste image 201,600,248+a*24,1:endcase
case 3: paste image 202,600,248+a*24,1:endcase
case 4: paste image 203,600,248+a*24,1:endcase
case 5: paste image 204,600,248+a*24,1:endcase
case 6: paste image 205,600,248+a*24,1:endcase
endselect
ink rgb(255,255,255),0
text 660,248+a*24,"EDIT"
next a
paste image current_brick,625,195,1
select brick_data(CURRENT_BRICK-2).special
case 1: paste image 200,625,195,1:endcase
case 2: paste image 201,625,195,1:endcase
case 3: paste image 202,625,195,1:endcase
case 4: paste image 203,625,195,1:endcase
case 5: paste image 204,625,195,1:endcase
case 6: paste image 205,625,195,1:endcase
endselect
text 625,215,"HITS: "+str$(brick_data(CURRENT_BRICK-2).hits)
text 625,235,"SPECIAL: "+special$(brick_data(CURRENT_BRICK-2).special)
text 625,255,"POINTS: "+str$(brick_data(CURRENT_BRICK-2).points)
text 733,550,"EXIT"
endfunction
function get_grid()
mx=mousex()
my=mousey()
Grid_X=-1:Grid_Y=-1
if mx>=15 and mx<=584 and my>=184 and my<=584
Grid_X=(mx-15)/19
Grid_Y=(my-184)/16
endif
endfunction
function draw_brick_place()
if gridx>=0 and grid_Y>=0 and grid_x<=28 and grid_y<25
sprite 1,16+grid_X*19,185+Grid_y*16,CURRENT_BRICK
set sprite alpha 1,80
show sprite 1
else
if sprite exist(1)
hide sprite 1
endif
endif
endfunction
function add_brick()
if gridx>=0 and grid_Y>=0 and grid_x<=28 and grid_y<25
if grid(grid_y,grid_x)=0 and grid(grid_y,grid_x+1)=0
array insert at bottom brick()
count=array count(brick())
brick(count).xpos=grid_x
brick(count).ypos=grid_y
brick(count).image=CURRENT_BRICK
inc Brick_Number
brick(count).Brick_NUmber=Brick_Number
grid(Grid_y,Grid_x)=Brick_Number:grid(Grid_y,Grid_X+1)=Brick_Number
endif
endif
endfunction
function remove_brick()
if gridx>=0 and grid_Y>=0 and grid_x<=28 and grid_y<25
if grid(grid_y,grid_x)>0
if array count(brick())>=0
for a = array count(brick()) to 0 step -1
which=grid(grid_y,grid_x)
if brick(a).Brick_Number=which
array delete element brick(),a
endif
next a
for a = 0 to 25
for b = 0 to 29
if grid(a,b)=which then grid(a,b)=0
next b
next a
endif
endif
endif
endfunction
function draw_bricks()
for a = 0 to array count(brick())
paste image brick(a).image,16+brick(a).xpos*19,185+brick(a).ypos*16,1
select brick_data(brick(a).image-2).special
case 1:paste image 200,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
case 2:paste image 201,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
case 3:paste image 202,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
case 4:paste image 203,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
case 5:paste image 204,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
case 6:paste image 205,16+brick(a).xpos*19,185+brick(a).ypos*16,1:endcase
endselect
next a
endfunction
function edit_brick(number as integer)
Red1=brick_data(number).red
Green1=brick_data(number).green
Blue1=brick_data(number).blue
makebrick(red1,blue1,green1,36,14,5000)
repeat
cls
draw_screen()
if array count(brick())>=0 then draw_bricks()
`ink rgb(200,200,200),0
`box 180,95,500,480
paste image 100,180,95
ink rgb(255,255,255),0
text 202,102,"EDITING BRICK "+str$(number)
paste image 5000,470,340,1
select brick_data(number).special
case 1:paste image 200,470,340,1:endcase
case 2:paste image 201,470,340,1:endcase
case 3:paste image 202,470,340,1:endcase
case 4:paste image 203,470,340,1:endcase
case 5:paste image 204,470,340,1:endcase
case 6:paste image 205,470,340,1:endcase
endselect
line 516-red1,258,516-red1,274:text 220,260,str$(red1)
line 516-blue1,278,516-blue1,294:text 220,280,str$(blue1)
line 516-green1,298,516-green1,314:text 220,300,str$(green1)
Text 200,340,"HITS: "+str$(brick_data(number).hits)
text 265,340,"+":text 275,340,"-"
text 200,370,"SPECIAL: "+special$(brick_data(number).special)
oldred=red1:oldgreen=green1:oldblue=blue1
text 200,400,"POINTS: "+str$(brick_data(number).points)
text 300,400,"+":text 310,400,"-"
if mouseclick()=1
mx=mousex():my=mousey()
if mx>=261 and mx<=261+255
if my>=258 and my<=274 then red1=516-mx
if my>=278 and my<=294 then blue1=516-mx
if my>=298 and my<=314 then green1=516-mx
endif
if mx>=265 and mx<=265+text width("+") and my>=340 and my<=340+text height("+")
inc brick_data(number).hits
repeat:until mouseclick()=0
endif
if mx>=300 and mx<=300+text width("+") and my>=400 and my<=400+text height("+")
inc brick_data(number).points,10
repeat:until mouseclick()=0
endif
if mx>=310 and mx<=310+text width("-") and my>=400 and my<=400+text height("-")
dec brick_data(number).points,10
if brick_data(number).points<0 then brick_data(number).points=0
repeat:until mouseclick()=0
endif
if mx>=275 and mx<=275+text width("-") and my>=340 and my<=340+text height("+")
dec brick_data(number).hits
if brick_data(number).hits<1 then brick_data(number).hits=1
repeat:until mouseclick()=0
endif
if mx>200 and mx<=200+text width("SPECIAL:") and my>=370 and my<=370+text height("SPECIAL:")
inc brick_data(number).special
if brick_data(number).special>6 then brick_data(number).special=0
repeat:until mouseclick()=0
endif
if mx>=203 and mx<=517 and my>=132 and my<=256
a=point(mx,my)
red1=rgbr(a)
blue1=rgbg(a)
green1=rgbb(a)
endif
endif
if oldred<>red1 or oldgreen<>green1 or oldblue<>blue1
makebrick(red1,blue1,green1,36,14,5000)
endif
sync
until mouseclick()=2
brick_data(number).red=red1
brick_data(number).green=green1
brick_data(number).blue=blue1
makebrick(red1,blue1,green1,36,14,number+2)
endfunction
function disect(filename as string,across,down,imagestart)
load bitmap filename,1
x=bitmap width(1)/across
y=bitmap height(1)/down
for a = 0 to down-1
for b = 0 to across-1
get image imagestart+a*across+b,x*b,y*a,x*b+x,y*a+y
next b:next a
delete bitmap 1
endfunction
function export_level(file$)
file$=file$+".bil"
if file exist(file$)=1 then delete file file$
open to write 1,file$
for a = 0 to 9
write byte 1,brick_data(a).red
write byte 1,brick_data(a).blue
write byte 1,brick_data(a).green
write byte 1,brick_data(a).hits
write byte 1,brick_data(a).special
write long 1,brick_data(a).points
next a
count=array count(brick())
write long 1,count
for a = 0 to count
write byte 1,brick(a).xpos
write byte 1,brick(a).ypos
write byte 1,brick(a).image
next a
close file 1
endfunction
function import_level(file$)
file$=file$+".bil"
if file exist(file$)=0 then exitfunction
empty array brick()
brick_number=1
open to read 1,file$
for a = 0 to 9
read byte 1,x
brick_data(a).red=x
read byte 1,x
brick_data(a).blue=x
read byte 1,x
brick_data(a).green=x
read byte 1,x
brick_data(a).hits=x
read byte 1,x
brick_data(a).special=x
read long 1,x
brick_data(a).points=x
makebrick(brick_data(a).red, brick_data(a).blue, brick_data(a).green,38,16,a+2)
next a
read long 1,NOB
for a = 0 to NOB
array insert at bottom brick()
count=array count(brick())
read byte 1,x
brick(count).xpos=x
read byte 1,x
brick(count).ypos=x
read byte 1,x
brick(count).image=x
brick(count).brick_number=brick_number
grid(brick(count).ypos,brick(count).xpos)=brick_number
grid(brick(count).ypos,brick(count).xpos+1)=brick_number
inc brick_number
next a
close file 1
endfunction
function makebrick(R as integer, G as integer, B as integer, xsize as integer, ysize as integer, image_number as integer)
create bitmap 1,xsize+8,ysize+8
ink rgb(255,255,255),0
box 0,0,xsize+4,ysize+4
get image 999,1,1,xsize,2,1
sprite 999,0,0,999
hide sprite 999
box 1,1,xsize,ysize,rgb(R,G,B),rgb(R/3,G/3,B/3),rgb(R,G,B),rgb(R/3,G/3,B/3)
set sprite alpha 999,222
paste sprite 999,1,1
set sprite alpha 999,182
paste sprite 999,1,2
set sprite alpha 999,142
paste sprite 999,1,3
set sprite alpha 999,102
paste sprite 999,1,4
set sprite alpha 999,62
paste sprite 999,1,5
ink rgb(22,22,22),0:line 1,1,xsize,1:line 1,1,1,ysize:line xsize,1,xsize,ysize:line 1,ysize,xsize,ysize:dot xsize,ysize
dot 2,2:dot 2,ysize-1:dot xsize-1,2:dot xsize-1,ysize-1
ink rgb(255,0,255),0:dot 1,1:dot 1,2:dot 2,1:dot xsize-1,1:dot xsize,1:dot xsize,2:dot 1,ysize-1:dot 1,ysize:dot 2,ysize:dot xsize-1,ysize:dot xsize,ysize:dot xsize,ysize-1
get image Image_number,1,1,xsize+1,ysize+1,1
delete bitmap 1
if sprite exist(999) then delete sprite 999
set current bitmap 0
endfunction
data 217,2,6,1,0,10
data 2,218,55,1,0,20
data 27,2,218,1,0,30
data 232,255,77,1,0,40
data 218,164,2,1,0,50
data 77,253,252,1,0,60
data 173,24,196,1,0,70
data 243,205,249,1,0,80
data 22,93,23,1,0,90
data 40,40,40,1,0,100
data "None","Indest.","Powerup","Powerdown","Speed Up","Speed Down","Bomb"