gosub Setup do paste image PegBoard,0,0 if scancode()=0 then gosub DistanceCheck gosub PalMenu paste sprite Peg,mousex(),mousey() sync LOOP PalMenu: mOk=0 if lower$(inkey$())="z" then mOk=1:paste image Palette,(screen width()/2)-(image width(Palette)/2),(screen height()/2)-(image height(Palette)/2) if lower$(inkey$())="x" then mOk=1:paste image PalBlur,(screen width()/2)-(image width(PalBlur)/2),(screen height()/2)-(image height(PalBlur)/2) if mouseclick()=1 and mOk=1 then CurrentColor=point(mousex(),mousey()):set sprite diffuse Peg,rgbr(CurrentColor),rgbg(CurrentColor),rgbb(CurrentColor) return DistanceCheck: for p=1 to MaxPegs if abs(mousex()-HoleX(p))<5 and abs(mousey()-HoleY(p))<5 if mouseclick() then Filled(p)=CurrentColor:set sprite diffuse p,rgbr(CurrentColor),rgbg(CurrentColor),rgbb(CurrentColor) if mouseclick()=2 then Filled(p)=0 ENDIF if Filled(p)<>0 then paste sprite p,HoleX(p),HoleY(p) NEXT return Setup: set display mode 740,450,32:set window position (desktop width()/2)-370,(desktop height()/2)-225 MaxPegs=1068:Peg=1:load image "peg.png",Peg,1 dim HoleX(MaxPegs):dim HoleY(MaxPegs):dim Filled(MaxPegs) Hole=2000:load image "hole.png",Hole,1:sprite Hole,-1000,-1000,Hole:offset sprite Hole,sprite width(Hole)/2,sprite height(Hole)/2 Palette=3:load image "palette.png",Palette,1:PalBlur=4:load image "palette-blur.png",PalBlur,1 White=rgb(255,255,255):CurrentColor=White xMargin=10:yMargin=12:HoleSize=6 for y=1 to 12 inc yPos,yMargin+HoleSize XPos=HoleSize+(xMargin*.3) for x1=1 to 44 inc xPos,xMargin+HoleSize:inc HoleCount HoleX(HoleCount)=xPos:HoleY(HoleCount)=yPos paste sprite Hole,HoleX(HoleCount),HoleY(HoleCount) inc SpriteCount sprite SpriteCount,HoleX(HoleCount),HoleY(HoleCount),Peg:offset sprite SpriteCount,sprite width(SpriteCount)/2,sprite height(SpriteCount)/2: hide sprite SpriteCount next xPos=0:inc YPos,HoleSize+yMargin for x1=1 to 45 inc xPos,xMargin+HoleSize:inc HoleCount HoleX(HoleCount)=xPos:HoleY(HoleCount)=yPos paste sprite Hole,HoleX(HoleCount),HoleY(HoleCount) inc SpriteCount sprite SpriteCount,HoleX(HoleCount),HoleY(HoleCount),Peg:offset sprite SpriteCount,sprite width(SpriteCount)/2,sprite height(SpriteCount)/2: hide sprite SpriteCount next NEXT PegBoard=100:get image PegBoard,0,0,screen width(),screen height(),1 HoleCount=0 import=2001 if file exist("import.jpg") load image "import.jpg",import,1 sprite import,1,1,import:hide sprite import size sprite import,45,24 ShortLine=1 for y=1 to 24 for x=1 to 45 paste sprite import,1,1 inc HoleCount if ShortLine=1 and x=45 then dec HoleCount if ShortLine=1 and x<45 then Filled(HoleCount)=point(x,y) if ShortLine=0 then Filled(HoleCount)=point(x,y):position mouse x,y if ShortLine=0 and x=45 then ShortLine=1 else if ShortLine=1 and x=45 then ShortLine=0 sprite HoleCount,HoleX(HoleCount),HoleY(HoleCount),Peg set sprite diffuse HoleCount,rgbr(Filled(HoleCount)),rgbg(Filled(HoleCount)),rgbb(Filled(HoleCount)) NEXT NEXT ENDIF sync on return