Here is a little update - not flash but workable
// Project: spritemodellor
// Created: 2018-12-13
// show all errors
//SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "spritemodellor" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetErrormode(0)
//SetErrorMode(1)
global background_memblock, red, green, blue, palette,mouse, maxframes=0
global functiontab1,functiontab2,functiontab3,functiontab4
global initialsizex=32
global initialsizey=32
global buttons as integer[10]
type _animationframes
spritesizex
spritesizey
spr
image
memblock
endtype
global sprites as _animationframes[32]
title = CreateText("AGK - Sprite Modeller and Animation System")
SetTextSize(title,24)
SetTextAngle(title,270)
sizetextx = CreateText(str(initialsizex))
sizetexty = CreateText(str(initialsizey))
SetTextSize(sizetextx,32)
SetTextSize(sizetexty,32)
createfunctionselector()
createpalleteandmouse()
setupspritedata()
addbuttons(1,screenwidth-250,80,60,"New",255,255,0)
addbuttons(2,screenwidth-190,80,60,"Open",255,255,0)
addbuttons(3,screenwidth-130,80,60,"Save",255,255,0)
addbuttons(4,screenwidth-70,80,60,"Apply",255,255,0)
addbuttons(5,screenwidth-250,140,60,"Prev",255,255,0)
addbuttons(6,screenwidth-190,140,60,"Next",255,255,0)
addbuttons(7,screenwidth-130,140,60,"Copy",255,255,0)
addbuttons(9,screenwidth-250,200,60,"Clear",255,255,0)
addbuttons(17,screenwidth-190,200,60,"Undo",255,255,0)
addbuttons(11,screenwidth-250,260,60,"Rotate",0,255,0)
addbuttons(12,screenwidth-190,260,60,"Merge",0,255,0)
addbuttons(13,screenwidth-130,260,60,"Circle",0,255,0)
addbuttons(14,screenwidth-70,260,60,"Line",0,255,0)
addbuttons(15,screenwidth-250,320,60,"Shift",0,255,0)
addbuttons(10,screenwidth-190,320,60,"Fill",0,255,0)
addbuttons(18,screenwidth-130,320,60,"Sqaure",0,255,0)
addbuttons(8,screenwidth-250,380,60,"Play",0,255,255)
addbuttons(19,screenwidth-190,380,60,"Stop",0,255,255)
addbuttons(20,screenwidth-250,440,30,"-",0,255,255)
addbuttons(21,screenwidth-180,440,30,"+",0,255,255)
addbuttons(22,screenwidth-130,440,30,"-",0,255,255)
addbuttons(23,screenwidth-60,440,30,"+",0,255,255)
animationframestep#=timer()
currentsprite=0 : maxframes=1
animationframe=0
player=-1
movepanel=1
size=initialsizex/2
functionspanely=131
SetSpriteVisible(palette,1)
SetRawMousePosition(screenwidth/2,screenheight/2)
do
SetSpritePosition(mouse, getpointerx(), getpointery())
SetSpritePosition(palette,screenwidth-300,screenheight-300)
SetSpritePosition(functiontab1,screenwidth-300,10)
SetTextPosition(sizetextx,screenwidth-230,420)
SetTextPosition(sizetexty,screenwidth-110,420)
// color selector
if GetSpriteCollision(mouse,palette) and GetSpriteVisible(palette)=1
getpixelcolor(getpointerx(),getpointery())
if GetRawMouseLeftState()
selectcolor = MakeColor(activecolorred,activecolorgreen,activecolorblue)
selectcolorred = red
selectcolorgreen = green
selectcolorblue = blue
endif
activecolorred = red
activecolorgreen=green
activecolorblue = blue
colorselected = MakeColor(activecolorred,activecolorgreen,activecolorblue)
// DrawBox(0,0,150,150,MakeColor(activecolorred,activecolorgreen,activecolorblue),0,MakeColor(activecolorred,activecolorgreen,activecolorblue),0,1)
coltime#=0
radius=100
for a#=90 to 270 step .01
xxx#=100 * sin(a#)
yyy#=100 * cos(a#)
nc = colorlerp(MakeColor(activecolorred,activecolorgreen,activecolorblue),MakeColor(0,0,0),(coltime#/100.0))
DrawLine(screenwidth-150,screenheight-150,screenwidth-150-xxx#,screenheight-150-yyy#,nc,nc)
inc coltime#,0.0055555
next
endif
DrawEllipse(screenwidth-280,screenheight-280,15,15,colorselected,colorselected,1)
DrawEllipse(screenwidth-20,screenheight-280,15,15,selectcolor,selectcolor,1)
// draw large grids for srite
originx=screenwidth/3 - (initialsizex * size)/2
originy=screenheight/2 - (initialsizey * size)/2
spritenumber=0
for x=0 to sprites[spritenumber].spritesizex
for y=0 to sprites[spritenumber].spritesizey
ax=originx + (x * size)
ay=originy + (y * size)
// dataforsprite[x,y]= MakeColor(selectcolorred,selectcolorgreen,selectcolorblue)
c= MakeColor(255,255,255)
// c = MakeColor(GetColorRed(dataforsprite[x,y]),GetColorGreen(dataforsprite[x,y]),GetColorBlue(dataforsprite[x,y]))
DrawBox( ax ,ay , ax+size,ay+size,c,c,c,c,0)
SetSpritePosition(dataforsprite[x,y], ax, ay)
SetSpriteSize(dataforsprite[x,y],size,size)
if GetSpriteCollision(mouse,dataforsprite[x,y])
if GetRawMouseLeftState()
// if getpointerx()>ax and getpointery()>ay
// perform the functions
// Flood Fill
if fill=1
// what is the colour at this location
currentcolorred = GetSpriteColorRed(dataforsprite[x,y])
currentcolorgreen = GetSpriteColorGreen(dataforsprite[x,y])
currentcolorblue = GetSpriteColorBlue(dataforsprite[x,y])
floodfill (x,y,selectcolorred,selectcolorgreen,selectcolorblue,currentcolorred,currentcolorgreen,currentcolorblue)
// turn it off now we finihed
fill=0
SetVirtualButtonColor(10,0,255,0)
else
// Draw a line
if line=1
oldx#=getpointerx()
oldy#=getpointery()
line=2
endif
if line=2
distancex# = getpointerx() - oldx#
distancey# = getpointery() - oldy#
if abs(distancex#)>=abs(distancey#)
stp# = abs(distancex#)
else
stp# = abs(distancey#)
endif
distancex# = distancex#/stp#
distancey# = distancey#/stp#
xx#=oldx#
yy#=oldy#
col = MakeColor(selectcolorred,selectcolorgreen,selectcolorblue)
// clear the tmp color data before we use it
for xx=0 to sprites[spritenumber].spritesizex
for yy=0 to sprites[spritenumber].spritesizey
tmpcolordata[xx,yy]=0
next
next
for i=1 to stp#
drawBox((xx#),(yy#),((xx#)+size),((yy#)+size),col,col,col,col,1)
posx=floor(xx#-originx)/size
posy=floor(yy#-originy)/size
tmpcolordata[posx,posy]=col
inc xx#,distancex#
inc yy#,distancey#
next
else
// Draw a circle
if circle=1
oldx=getpointerx()
oldy=getpointery()
oldpointx=x
oldpointy=y
circle=2
endif
if circle=2
distancex = getpointerx() - oldx
distancey = getpointery() - oldy
col = MakeColor(selectcolorred,selectcolorgreen,selectcolorblue)
DrawEllipse(oldx,oldy,distancex,distancey,col,col,0)
else
// free hand
line=0:circle=0:fill=0
SetSpriteColor(dataforsprite[x,y],selectcolorred,selectcolorgreen,selectcolorblue,255)
endif
endif
endif
endif
// endif
// if line is selected and just released it, then reset it so can create another line
if GetRawMouseLeftReleased() and line=2
line=1
// grab the data from the tmpcolordata and set the sprite with that info
for xx=0 to sprites[spritenumber].spritesizex
for yy=0 to sprites[spritenumber].spritesizey
if tmpcolordata[xx,yy]<>0
SetSpriteColor(dataforsprite[xx,yy],GetColorRed(tmpcolordata[xx,yy]),GetColorGreen(tmpcolordata[xx,yy]),GetColorBlue(tmpcolordata[xx,yy]),255)
tmpcolordata[xx,yy]=0
endif
next
next
endif
if GetRawMouseLeftReleased() and circle=2
circle=1
for yy=-distancey to distancey
for xx=-distancex to distancex
if(xx*xx+yy*yy<=(distancex/5))
if (oldpointx+xx>=0 and oldpointy+yy>=0 and oldpointx+xx<=32 and oldpointy+yy<=32)
SetSpriteColor(dataforsprite[oldpointx+xx,oldpointy+yy],selectcolorred,selectcolorgreen,selectcolorblue,255)
endif
endif
next
next
endif
if GetRawMouseRightState()
SetSpriteColor(dataforsprite[x,y],0,0,0,255)
endif
endif
next
next
// draw the smaller version of the sprite and the animation frames
originx=650
originy=10
spritenumber=0
for x=0 to sprites[spritenumber].spritesizex
for y=0 to sprites[spritenumber].spritesizey
cr = GetSpriteColorRed(dataforsprite[x,y])
cg = GetSpriteColorGreen(dataforsprite[x,y])
cb = GetSpriteColorBlue(dataforsprite[x,y])
c = MakeColor(cr,cg,cb)
ax =originx + x
ay = originy + y
DrawBox(ax ,ay, ax+1,ay+1,c,c,c,c,1)
next
next
// draw the sprites animation steps along the top
originx=650
originy=10
spritenumber=0
for y=0 to 300
if spritenumber<sprites.length
ay= originy+(y * (sprites[spritenumber].spritesizex))
ax= 650
SetSpritePosition(sprites[spritenumber].spr,ax,ay)
// draw box around the currentsprite, so we know which one we working with
if spritenumber=currentsprite then DrawBox(ax,ay,ax+sprites[spritenumber].spritesizex,ay+sprites[spritenumber].spritesizey,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),0)
endif
inc spritenumber
next
// new sheet
if GetVirtualButtonPressed(1)=1
for spritenumber=0 to sprites.length
DeleteSprite(sprites[spritenumber].spr)
DeleteMemblock(sprites[spritenumber].memblock)
DeleteImage(sprites[spritenumber].image)
next
setupspritedata()
currentsprite=0
endif
// open sheet
if GetVirtualButtonPressed(2)=1
openspritesheet("test.png",32,32)
endif
// save sheet
if GetVirtualButtonPressed(3)=1
savespritesheet()
endif
// apply
if GetVirtualButtonPressed(4)=1
applyimage(currentsprite)
endif
// Goto previous frame
if GetVirtualButtonPressed(5)=1
dec currentsprite
endif
// GO TO NEXT FRAME
if GetVirtualButtonPressed(6)=1
applyimage(currentsprite)
inc maxframes
inc currentsprite
endif
// COPY
if GetVirtualButtonPressed(7)=1
inc maxframes
inc currentsprite
applyimage(currentsprite)
endif
if GetVirtualButtonPressed(8)=1
player=-player
if player=1
DeleteSprite(animation)
animation=CreateSprite(0)
for a=1 to maxframes-1
AddSpriteAnimationFrame(animation,sprites[a].image)
next
PlaySprite(animation)
else
stopsprite(animation)
endif
SetSpritePosition(animation,700,100)
endif
if GetVirtualButtonPressed(9) = 1
spritenumber=0
for x=0 to sprites[spritenumber].spritesizex
for y=0 to sprites[spritenumber].spritesizey
SetSpriteColor(dataforsprite[x,y],0,0,0,255)
next
next
endif
// Fill
if GetVirtualButtonPressed(10)=1
if fill=0
fill=1
SetVirtualButtonColor(10,0,100,0)
SetVirtualButtonColor(13,0,255,0) : circle=0
else
fill=0
SetVirtualButtonColor(10,0,255,0)
endif
endif
// Circle
if GetVirtualButtonPressed(13)=1
if circle=0
circle=1
SetVirtualButtonColor(10,0,255,0)
SetVirtualButtonColor(13,0,100,0)
else
circle=0
SetVirtualButtonColor(13,0,255,0)
endif
endif
// Line
if GetVirtualButtonPressed(14)=1
if line=0
line=1
SetVirtualButtonColor(10,0,255,0)
SetVirtualButtonColor(13,0,255,0)
SetVirtualButtonColor(14,0,100,0)
else
line=0
SetVirtualButtonColor(14,0,255,0)
endif
endif
if GetVirtualButtonPressed(20) // -
dec initialsizex
setupspritedata()
endif
if GetVirtualButtonPressed(21) // +
inc initialsizex
setupspritedata()
endif
if GetVirtualButtonPressed(22) // -
dec initialsizey
setupspritedata()
endif
if GetVirtualButtonPressed(23) // +
inc initialsizey
setupspritedata()
endif
SetTextString(sizetextx,str(initialsizex))
SetTextString(sizetexty,str(initialsizey))
if GetRawKeyPressed(187) then dec size
if GetRawKeyPressed(189) then inc size
if size>18 then size=18
if size<8 then size=8
if GetRawKeyPressed(27) then end
SetTextPosition(title,10,screenheight/2 + GetTextTotalWidth(title)/2)
Render2DBack()
Sync()
loop
function createfunctionselector()
frametext = CreateText("Controls")
SetTextSize(frametext,20)
SetTextColor(frametext,255,255,255,255)
col=MakeColor(130,82,1)
swap()
SetTextPosition(frametext,35,5)
for x=0 to 350
for y=30 to screenheight
DrawLine(x,y,x,y,MakeColor(130,82,1),MakeColor(130,82,1))
next
next
DrawBox(15,0,150,30,col,col,col,col,1)
for i=0 to 15
DrawLine(i,30,i+15,0,col,col)
DrawLine(135+i,0,135+i+15,30,col,col)
next
Render2DFront()
render()
functiontab1 = createsprite(getimage(0,0,350,screenheight-300))
DeleteText(frametext)
endfunction
function floodfill ( x,y, nred,ngreen,nblue, ored,ogreen,oblue)
if x<0 or x>32 or y<0 or y>32
exitfunction
endif
cred = GetSpriteColorRed(dataforsprite[x,y])
cgreen = GetSpriteColorGreen(dataforsprite[x,y])
cblue = GetSpriteColorBlue(dataforsprite[x,y])
if cred = ored and cgreen = ogreen and cblue = oblue
SetSpriteColor(dataforsprite[x,y],nred,ngreen,nblue,255)
floodfill (x+1,y,nred,ngreen,nblue,ored,ogreen,oblue)
floodfill (x,y+1,nred,ngreen,nblue,ored,ogreen,oblue)
floodfill (x-1,y,nred,ngreen,nblue,ored,ogreen,oblue)
floodfill (x,y-1,nred,ngreen,nblue,ored,ogreen,oblue)
endif
endfunction
function dispose()
spritenumber=0
for x=0 to initialsizex
for y=0 to initialsizey
if spritenumber<sprites.length
if GetSpriteExists(sprites[spritenumber].spr)=1 then DeleteSprite(sprites[spritenumber].spr)
if GetImageExists(sprites[spritenumber].image)=1 then DeleteImage(sprites[spritenumber].image)
if GetMemblockExists(sprites[spritenumber].memblock)=1 then DeleteMemblock(sprites[spritenumber].memblock)
endif
inc spritenumber
next
next
endfunction
function setupspritedata()
dim dataforsprite [initialsizex, initialsizey]
dim tmpcolordata [initialsizex, initialsizey] // used when drawing lines etc
dispose()
spr = CreateSprite(0)
for spritenumber=0 to sprites.length
sprites[spritenumber].spr = CloneSprite(spr)
sprites[spritenumber].spritesizex = initialsizex
sprites[spritenumber].spritesizey = initialsizey
setspritecolor(sprites[spritenumber].spr,0,0,0,255)
SetSpriteSize(sprites[spritenumber].spr,initialsizex,initialsizey)
SetSpriteColor(sprites[spritenumber].spr,255,255,255,255)
SetSpriteVisible(sprites[spritenumber].spr,0)
next
for x=0 to initialsizex
for y=0 to initialsizey
dataforsprite[x,y] = CloneSprite(spr)
SetSpriteSize(dataforsprite[x,y],initialsizex,initialsizey)
SetSpriteColor(dataforsprite[x,y],0,0,0,255)
inc spritenumber
next
next
endfunction
function createpalleteandmouse()
//create palette
swap()
// color wheel as 6 areas to interopolate colours with so each segment is 60 degress - 360/6 = 60 and the
// interopolattion requires to go between 0.00 and 1.00 so the difference here is 100/60 = 0.016 in time steps
DrawBox(0,0,screenwidth,screenheight,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
radius=150
coltime#=0
for a#=0 to 60 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(255,0,0),MakeColor(255,255,0),coltime#/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=60 to 120 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(255,255,0),MakeColor(0,255,0),(coltime#)/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=120 to 180 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(0,255,0),MakeColor(0,255,255),(coltime#)/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=180 to 240 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(0,255,255),MakeColor(0,0,255),(coltime#)/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=240 to 300 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(0,0,255),MakeColor(255,0,255),(coltime#)/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=300 to 360 step .01
x#=radius * sin(a#)
y#=radius * cos(a#)
nc = colorlerp(MakeColor(255,0,255),MakeColor(255,0,0),(coltime#)/100.0)
DrawLine(radius,radius,radius-x#,radius-y#,nc,nc)
inc coltime#,0.016
next
coltime#=0
for a#=0 to 360 step .01
x#=100 * sin(a#)
y#=100 * cos(a#)
nc = colorlerp(MakeColor(255,255,255),MakeColor(0,0,0),(coltime#/100.0))
DrawLine(radius,radius,radius+x#,radius+y#,nc,nc)
inc coltime#,0.002777
next
// DrawEllipse(radius,radius,radius-30,radius-30,MakeColor(0,0,0),MakeColor(0,0,0),1)
render()
palette = CreateSprite(GetImage(0,0,radius*2,radius*2))
background_memblock = CreateMemblockFromImage(palette)
SetSpriteVisible(palette,0)
mouse= CreateSprite(getimage(0,0,0,0))
SetSpriteSize(mouse,1,1)
SetSpriteVisible(mouse,0)
endfunction
function colorlerp(col1,col2,time#)
ar=GetColorRed(col1)
ag=GetColorGreen(col1)
ab=GetColorBlue (col1)
br=GetColorRed(col2)
bg=GetColorGreen(col2)
bb=GetColorBlue(col2)
nr = ar + (br - ar) * time#
ng = ag + (bg - ag) * time#
nb = ab + (bb - ab) * time#
newcol = MakeColor(nr,ng,nb)
endfunction newcol
function applyimage(currentsprite)
sprites[currentsprite].image = getimage(0,0,sprites[currentsprite].spritesizex+1,sprites[currentsprite].spritesizey+1)
sprites[currentsprite].memblock = CreateMemblockFromImage (sprites[currentsprite].image)
background_imgwidth = GetMemblockInt(sprites[currentsprite].memblock, 0)
background_imgheight = GetMemblockInt(sprites[currentsprite].memblock, 4)
background_size = GetMemblockSize(sprites[currentsprite].memblock)
for xx=0 to sprites[currentsprite].spritesizex
for yy=0 to sprites[currentsprite].spritesizey
offset = 12 + (((Yy * background_imgwidth) + Xx) * 4)
cr = GetSpriteColorRed(dataforsprite[xx,yy])
cg = GetSpriteColorGreen(dataforsprite[xx,yy])
cb = GetSpriteColorBlue(dataforsprite[xx,yy])
SetMemblockByte(sprites[currentsprite].memblock, offset, cr)
SetMemblockByte(sprites[currentsprite].memblock, offset+1, cg)
setMemblockByte(sprites[currentsprite].memblock, offset+2, cb)
setMemblockByte(sprites[currentsprite].memblock, offset+3, 254) // 254 is air, can move in it
next
next
sprites[currentsprite].image = CreateImageFromMemblock(sprites[currentsprite].memblock)
SetSpriteImage(sprites[currentsprite].spr,sprites[currentsprite].image)
SetSpriteVisible(sprites[currentsprite].spr,1)
endfunction
// Get a pixel color - which will provide what the color is on the loaded image it is at any
// given location
// a lemming can move on a completely blank area
function getpixelcolor( X, Y)
if (x>getspritex(palette) and y>GetSpriteY(palette) and x<getspritex(palette)+GetSpriteWidth(palette) and y<GetSpriteY(palette)+GetSpriteHeight(palette))
offset = 12 + ((((Y-getspritey(palette)) * GetSpriteWidth(palette)) + (X-getspritex(palette))) * 4)
if offset>0
red=GetMemblockByte(background_memblock, offset)
green=GetMemblockByte(background_memblock, offset+1)
blue=GetMemblockByte(background_memblock, offset+2)
endif
endif
endfunction
function addbuttons(id,x,y,size,name$,colorred,colorgreen,colorblue)
AddVirtualButton(id,x,y,size)
SetVirtualButtonAlpha(id,255)
SetVirtualButtonColor(id,colorred,colorgreen,colorblue)
SetVirtualButtonText(id,name$)
SetVirtualButtonVisible(id,1)
//GetVirtualButtonExists
//GetVirtualButtonPressed
//GetVirtualButtonReleased
//GetVirtualButtonState
//SetButtonScreenPosition
//SetVirtualButtonActive
//SetVirtualButtonImageDown
//SetVirtualButtonImageUp
//SetVirtualButtonPosition
// SetVirtualButtonSize(
endfunction
function savespritesheet()
// lets build an image based on the size
sync()
spritenumber=0
for y=0 to 8
for x=0 to 8
if spritenumber<maxframes
SetSpritePosition(sprites[spritenumber].spr,x*Initialsizex,y*Initialsizey)
endif
inc spritenumber
next
next
sync()
render()
img = getimage(0,0,8 * Initialsizex,8*Initialsizey)
SaveImage(img,"test.png")
endfunction
function openspritesheet(sheet$, sizex,sizey)
/* img = CreateSprite(LoadImage(sheet$))
sprites[currentsprite].image = getimage(0,0,sprites[currentsprite].spritesizex+1,sprites[currentsprite].spritesizey+1)
sprites[currentsprite].memblock = CreateMemblockFromImage (sprites[currentsprite].image)
background_imgwidth = GetMemblockInt(sprites[currentsprite].memblock, 0)
background_imgheight = GetMemblockInt(sprites[currentsprite].memblock, 4)
for xx=0 to sprites[currentsprite].spritesizex
for yy=0 to sprites[currentsprite].spritesizey
offset = 12 + (((Yy * background_imgwidth) + Xx) * 4)
cr = GetSpriteColorRed(dataforsprite[xx,yy])
cg = GetSpriteColorGreen(dataforsprite[xx,yy])
cb = GetSpriteColorBlue(dataforsprite[xx,yy])
SetMemblockByte(sprites[currentsprite].memblock, offset, cr)
SetMemblockByte(sprites[currentsprite].memblock, offset+1, cg)
setMemblockByte(sprites[currentsprite].memblock, offset+2, cb)
setMemblockByte(sprites[currentsprite].memblock, offset+3, 254) // 254 is air, can move in it
next
next
*/
endfunction
// Function to create a texture
//
// Inputs - Sizex - size of the texture to create - width
// Sizey - size of the texture to create - height
// Color - is the main color of the image
// Denisity - is a the depth of the texture - the lower the value, the more detail. higher value = no detail
//
// Returns the image for the resulting texture
//
// EG. CreateTexture ( 100, 100, makecolor(0,0,255), 100)
// This could create a DEEP water effect texture?
function createtexture(sizex# as float, sizey# as float, color, density as integer)
swap()
drawbox(0,0,sizex#, sizey#, color, color,color,color, 1)
render()
img = getimage(0,0,sizex#, sizey#)
memblockid = CreateMemblockFromImage (img)
imgwidth = GetMemblockInt(memblockid, 0)
imgheight = GetMemblockInt(memblockid, 4)
size=GetMemblockSize(memblockid)
for offset=12 to size-4 step 4
r=GetMemblockByte(memblockid, offset)
g=GetMemblockByte(memblockid, offset+1)
b=GetMemblockByte(memblockid, offset+2)
a=GetMemblockByte(memblockid, offset+3)
strength=random(1,density)
SetMemblockByte (memblockid, offset, r-strength)
SetMemblockByte (memblockid, offset+1, g-strength)
SetMemblockByte (memblockid, offset+2, b-strength )
SetMemblockByte (memblockid, offset+3, a-strength)
next
deleteimage (img)
img = CreateImageFromMemblock(memblockid)
DeleteMemblock(memblockid)
endfunction img
Press the + and - keys to zoom incase things get in the way of your sprite line
Shall keep cracking on with it