SPRITE 64 DRAW

Start hier uw open source projecten

SPRITE 64 DRAW

Berichtdoor bluatigro » di feb 09, 2010 2:38 pm

dit is het begin van n sprite draw programma
wie helpt uitbreiden ?
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHieght = DisplayHeight
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]
menu #m , "Color"                 _
        , "no color"  , [nocolor] , | _
        , "black"     , [black]   _
        , "red"       , [red]     _
        , "green"     , [green]   _
        , "yellow"    , [yellow]  _
        , "blue"      , [blue]    _
        , "magenta"   , [magenta] _
        , "cyan"      , [cyan]    _
        , "white"     , [white]   _
        , "pink"      , [pink]    _
        , "purple"    , [purple]  _
        , "gray"      , [gray]    _
        , "orange"    , [orange]
global black , red , green , yellow , filename$
global blue , magenta , cyan , white , nocolor
global pink , purple , gray , orange , drawcolor
black   = rgb(   0 ,   0 ,   0 )
red     = rgb( 255 ,   0 ,   0 )
green   = rgb(   0 , 255 ,   0 )
yellow  = rgb( 255 , 255 ,   0 )
blue    = rgb(   0 ,   0 , 255 )
magenta = rgb( 255 ,   0 , 255 )
cyan    = rgb(   0 , 255 , 255 )
white   = rgb( 255 , 255 , 255 )
pink    = rgb( 255 , 127 , 127 )
purple  = rgb( 127 ,   0 , 127 )
gray    = rgb( 127 ,   0 , 127 )
orange  = rgb( 255 , 127 , 127 )
nocolor = -1
open "Sprite Maker" for graphics as #m
  #m "trapclose [quit]"
  #m "when leftButtonMove [leftbutton]"
wait
[new]
  for x = 0 to 63
    for y = 0 to 63
      call pixel x , y , nocolor
    next y
  next x
  filename$ = "empty.bmp"
wait
sub pixel x , y , clr
  if clr = nocolor then
    #m "color white"
    #m "set " ; x ; " " ; y
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "color black"
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 5 ; " " ; y * 5
    #m "down"
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; 68 + x * 5 ; " " ; 4 + y * 5
  else
    r = clr and 255
    g = int( clr / 256 ) and 255
    b = int( clr / 256 ^ 2 ) and 255
    #m "color black"
    #m "up"
    #m "goto " ; x ; " " ; y
    #m "down"
    #m "set " ; x ; " " ; y
    #m "color " ; r ; " " ; g ; " " ; b
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 5 ; " " ; y * 5
    #m "down "
    #m "backcolor " ; r ; " " ; g ; " " ; b
    #m "boxfilled " ; 68 + x * 5 ; " " ; y * 5 + 4
    #m "up"
  end if
  #m "flush"
end sub
[open]
wait
[saveas]
[save]
  #m "getbmp bmp 0 0 63 127"
  #m "bmpsave bmp " ; filename$
wait
[leftbutton]
  x = int( ( MouseX - 64 ) / 5 )
  y = int( MouseY / 5 )
  call pixel x , y , drawcolor
wait
[quit]
  close #m
end
function rgb( r , g , b )
  r = r and 255
  g = g and 255
  b = b and 255
  rgb = r + g * 256 + b * 256 ^ 2
end function
[nocolor] drawcolor = nocolor : wait
[black]   drawcolor = black   : wait
[red]     drawcolor = red     : wait
[green]   drawcolor = green   : wait
[yellow]  drawcolor = yellow  : wait
[blue]    drawcolor = blue    : wait
[magenta] drawcolor = magenta : wait
[cyan]    drawcolor = cyan    : wait
[white]   drawcolor = white   : wait
[pink]    drawcolor = pink    : wait
[purple]  drawcolor = purple  : wait
[gray]    drawcolor = gray    : wait
[orange]  drawcolor = orange  : wait

de reden dat ik m 64x64 maak is simpel
dan kan je makelijker werken met and en or
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SPRITE 64 DRAW

Berichtdoor bluatigro » ma feb 15, 2010 10:23 am

update :
colordialog toegevoegt
filedialog toegevoegt

todo :
laden van sprite en op scherm zetten

Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHieght = DisplayHeight
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]   _
        ,|,"Exit"   , [quit]
menu #m ,  "Color"                _
        ,  "no color"  , [nocolor] _
        ,  "Any color" , [anycolor] _
        ,|,"black"     , [black]   _
        ,  "red"       , [red]     _
        ,  "green"     , [green]   _
        ,  "yellow"    , [yellow]  _
        ,  "blue"      , [blue]    _
        ,  "magenta"   , [magenta] _
        ,  "cyan"      , [cyan]    _
        ,  "white"     , [white]   _
        ,  "pink"      , [pink]    _
        ,  "purple"    , [purple]  _
        ,  "gray"      , [gray]    _
        ,  "orange"    , [orange]
global filename$ , lastcolor$
open "Sprite Maker" for graphics as #m
  #m "trapclose [quit]"
  #m "when leftButtonMove [leftbutton]"
wait
[new]
  #m "cls"
  for x = 0 to 63
    for y = 0 to 63
      call pixel x , y , "nocolor"
    next y
  next x
  filename$ = "empty.bmp"
wait
''==============================file
[open]
  filedialog "Load Sprite" , "*.bmp" , filename$
''todo : load sprite and put it on screen
wait
[saveas]
  filedialog "Save Sprite" , "*.bmp" , filename$
[save]
  #m "getbmp bmp 0 0 63 127"
  #m "bmpsave bmp " ; filename$
wait
[leftbutton]
  x = int( ( MouseX - 64 ) / 7 )
  y = int( MouseY / 7 )
  call pixel x , y , lastcolor$
wait
[quit]
  close #m
end
''==========================color
[nocolor] lastcolor$ = "nocolor" : wait
[anycolor]
  colordialog lastcolor$ , lasrcolor$
wait
[black]   lastcolor$ = "black" : wait
[red]     lastcolor$ = "red" : wait
[green]   lastcolor$ = "green" : wait
[yellow]  lastcolor$ = "yellow" : wait
[blue]    lastcolor$ = "blue" : wait
[magenta] lastcolor$ = "magenta" : wait
[cyan]    lastcolor$ = "cyan" : wait
[white]   lastcolor$ = "white" : wait
[pink]    lastcolor$ = "255 127 127" : wait
[purple]  lastcolor$ = "127 000 127" : wait
[gray]    lastcolor$ = "127 127 127" : wait
[orange]  lastcolor$ = "255 127 000" : wait
sub pixel x , y , clr$
  if clr$ = "nocolor" then
    #m "color white"
    #m "set " ; x ; " " ; y
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "color black"
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down"
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; 71 + x * 7 ; " " ; 6 + y * 7
  else
    #m "color black"
    #m "up"
    #m "goto " ; x ; " " ; y
    #m "down"
    #m "set " ; x ; " " ; y
    #m "color " ; lastcolor$
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down "
    #m "backcolor " ; lastcolor$
    #m "boxfilled " ; 71 + x * 7 ; " " ; y * 7 + 6
    #m "up"
  end if
  #m "flush"
end sub
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SPRITE 64 DRAW

Berichtdoor bluatigro » do feb 18, 2010 12:42 pm

update :
load + draw sprite toegevoegt
niet buiten sprite tekenen toegevoegt

todo :
juiste aanroep dll's
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHieght = DisplayHeight
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]   _
        ,|,"Exit"   , [quit]
menu #m ,  "Color"                _
        ,  "no color"  , [nocolor] _
        ,  "Any color" , [anycolor] _
        ,|,"black"     , [black]   _
        ,  "red"       , [red]     _
        ,  "green"     , [green]   _
        ,  "yellow"    , [yellow]  _
        ,  "blue"      , [blue]    _
        ,  "magenta"   , [magenta] _
        ,  "cyan"      , [cyan]    _
        ,  "white"     , [white]   _
        ,  "pink"      , [pink]    _
        ,  "purple"    , [purple]  _
        ,  "gray"      , [gray]    _
        ,  "orange"    , [orange]
global filename$ , lastcolor$
global hwind , hdc
lastcolor$ = "red"
open "Sprite Draw It" for graphics as #m
  hwind = hwnd( #m )
  calldll #User32 , _
  "GetDC" , hwind as ulong , hdc as ulong
  #m "trapclose [quit]"
  #m "when leftButtonMove [leftbutton]"
wait
''================================file
[new]
  #m "cls"
  for x = 0 to 63
    for y = 0 to 63
      call pixel x , y , "nocolor"
    next y
  next x
  filename$ = "empty.bmp"
wait
[open]
  filedialog "Load Sprite" , "*.bmp" , filename$
  loadbmp "bmp" , filename$
  #m "drawbmp bmp 0 0"
  for x = 0 to 63
    for y = 0 to 63
      if getpixel$( x , y ) = "255 255 255" then
        call setpixel x , y , "nocolor"
      else
        call setpixel x , y , getpixel$( x , y + 64 )
      end if
    next y
  next x
wait
[saveas]
  filedialog "Save Sprite" , "*.bmp" , filename$
[save]
  #m "getbmp bmp 0 0 63 127"
  #m "bmpsave bmp " ; filename$
wait
[leftbutton]
  x = int( ( MouseX - 64 ) / 7 )
  y = int( MouseY / 7 )
  call setpixel x , y , lastcolor$
wait
function getpixel$( x , y )
  CalldLL #gdi32, "GetPixel",_
        hwind as uLong, _
        x as Long, _
        y as Long, _
        clr as Long
  r = clr and 255
  g = int( clr / 256 ) and 255
  b = int( clr / 256 ^ 2 ) and 255
  getpixel$ = str$(r)+" "+str$(g)+" "+str$(b)
end function
[quit]
  calldll #user , "ReleaseDC" _
  , hwind as uloong _
  , hdc as ulong
  close #m
end
''==========================color
[nocolor] lastcolor$ = "nocolor" : wait
[anycolor]
  colordialog lastcolor$ , lasrcolor$
wait
[black]   lastcolor$ = "black" : wait
[red]     lastcolor$ = "red" : wait
[green]   lastcolor$ = "green" : wait
[yellow]  lastcolor$ = "yellow" : wait
[blue]    lastcolor$ = "blue" : wait
[magenta] lastcolor$ = "magenta" : wait
[cyan]    lastcolor$ = "cyan" : wait
[white]   lastcolor$ = "white" : wait
[pink]    lastcolor$ = "255 127 127" : wait
[purple]  lastcolor$ = "127 000 127" : wait
[gray]    lastcolor$ = "127 127 127" : wait
[orange]  lastcolor$ = "255 127 000" : wait
sub setpixel x , y , clr$
  if x < 0 then exit sub
  if x > 63 then exit sub
  if y < 0 then exit sub
  if y > 63 then exit sub
  if clr$ = "nocolor" then
    #m "color white"
    #m "set " ; x ; " " ; y
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "color black"
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down"
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; 71 + x * 7 ; " " ; 6 + y * 7
  else
    #m "color black"
    #m "up"
    #m "goto " ; x ; " " ; y
    #m "down"
    #m "set " ; x ; " " ; y
    #m "color " ; lastcolor$
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down "
    #m "backcolor " ; lastcolor$
    #m "boxfilled " ; 71 + x * 7 ; " " ; y * 7 + 6
    #m "up"
  end if
  #m "flush"
end sub
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SPRITE 64 DRAW

Berichtdoor Gordon » do feb 18, 2010 11:50 pm

Hallo bluatigro,
LB kent geen magenta kleur naam, maar wel
Code: Selecteer alles
black, blue, brown, buttonface, cyan, darkblue, darkcyan, darkgray, darkgreen, darkpink, darkred, green, lightgray, palegray, pink, red, white, yellow

Palegray and Lightgray are different names for the same color.  Buttonface is the default background color currently set on a user's system, so it will vary according to the desktop color scheme. 


Oh ja, [open] een bestaande .bmp sprite werkt niet goed.
Over de ingeladen sprite wordt overheen getekend




Code: Selecteer alles
'Drawing a 64X64 sprite
'complete with mask
'bluatigro febr 2010
'debugged Gordon

'bugs #user32
'pink magenta purple red darkred
'bmpsave
'setpixel
'[open]


WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]   _
        ,|,"Exit"   , [quit]
menu #m ,  "Color"                _
        ,  "no color"  , [nocolor] _
        ,  "Any color" , [anycolor] _
        ,|,"black"     , [black]   _
        ,  "darkred"       , [red]     _
        ,  "green"     , [green]   _
        ,  "yellow"    , [yellow]  _
        ,  "blue"      , [blue]    _
        ,  "pink"   , [magenta] _
        ,  "cyan"      , [cyan]    _
        ,  "white"     , [white]   _
        ,  "pink"      , [pink]    _
        ,  "darkpink"    , [purple]  _
        ,  "gray"      , [gray]    _
        ,  "red"    , [orange]
global filename$ , lastcolor$
global hwind , hdc
lastcolor$ = "red"
open "Sprite Draw It" for graphics as #m
  hwind = hwnd( #m )
  calldll #user32 , _
  "GetDC" , hwind as ulong , hdc as ulong
  #m "trapclose [quit]"
  #m "when leftButtonMove [leftbutton]"
wait
''================================file
[new]
  #m "cls"
  for x = 0 to 63
    for y = 0 to 63
      call setpixel x , y , "nocolor"
    next y
  next x
  filename$ = "empty.bmp"
wait
[open]
  filedialog "Load Sprite" , "*.bmp" , filename$
  if filename$ = "" then wait
  loadbmp "bmp" , filename$
  #m "drawbmp bmp 0 0"
  for x = 0 to 63
    for y = 0 to 63
      if getpixel$( x , y ) = "255 255 255" then
        call setpixel x , y , "nocolor"
      else
        call setpixel x , y , getpixel$( x , y + 64 )
      end if
    next y
  next x
wait
[saveas]
  filedialog "Save Sprite" , "*.bmp" , filename$
[save]
  #m "getbmp bmp 0 0 63 127"
  bmpsave "bmp", filename$
wait
[leftbutton]
  x = int( ( MouseX - 64 ) / 7 )
  y = int( MouseY / 7 )
  call setpixel x , y , lastcolor$
wait
function getpixel$( x , y )
  CalldLL #gdi32, "GetPixel",_
        hwind as uLong, _
        x as Long, _
        y as Long, _
        clr as Long
  r = clr and 255
  g = int( clr / 256 ) and 255
  b = int( clr / 256 ^ 2 ) and 255
  getpixel$ = str$(r)+" "+str$(g)+" "+str$(b)
end function
[quit]
  calldll #user32 , "ReleaseDC" _
  , hwind as ulong _
  , hdc as ulong
  close #m
end
''==========================color
[nocolor] lastcolor$ = "nocolor" : wait
[anycolor]
  colordialog lastcolor$ , lastcolor$
wait
[black]   lastcolor$ = "black" : wait
[red]     lastcolor$ = "red" : wait
[green]   lastcolor$ = "green" : wait
[yellow]  lastcolor$ = "yellow" : wait
[blue]    lastcolor$ = "blue" : wait
[magenta] lastcolor$ = "mangenta" : wait
[cyan]    lastcolor$ = "cyan" : wait
[white]   lastcolor$ = "white" : wait
[pink]    lastcolor$ = "255 127 127" : wait
[purple]  lastcolor$ = "127 000 127" : wait
[gray]    lastcolor$ = "127 127 127" : wait
[orange]  lastcolor$ = "255 127 000" : wait
sub setpixel x , y , clr$
  if x < 0 then exit sub
  if x > 63 then exit sub
  if y < 0 then exit sub
  if y > 63 then exit sub
  if clr$ = "nocolor" then
    #m "color white"
    #m "set " ; x ; " " ; y
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "color black"
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down"
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; 71 + x * 7 ; " " ; 6 + y * 7
  else
    #m "color black"
    #m "up"
    #m "goto " ; x ; " " ; y
    #m "down"
    #m "set " ; x ; " " ; y
    #m "color " ; lastcolor$
    #m "up"
    #m "goto " ; x ; " " ; y + 64
    #m "down"
    #m "set " ; x ; " " ; y + 64
    #m "up"
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down "
    #m "backcolor " ; lastcolor$
    #m "boxfilled " ; 71 + x * 7 ; " " ; y * 7 + 6
    #m "up"
  end if
  #m "flush"
end sub


Gordon
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Re: SPRITE 64 DRAW

Berichtdoor bluatigro » vr feb 19, 2010 11:05 am

update :
setpixel aangepast
"magenta" => "255 000 255"

uitleg :
setpixel heeft nu 2 modes
1 : plot allen groot
2 : plot ook op sprite

Code: Selecteer alles
'Drawing a 64X64 sprite
'complete with mask
'bluatigro febr 2010
'debugged Gordon

'WindowHieght > WindowHeight
'#User32 > #user32
'pink magenta purple red darkred
'bmpsave statement
'pixel() > setpixel()
'hwin > hdc in the #gdi32 call
'uloong > ulong
'[open] with filename$ "" checking


WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]   _
        ,|,"Exit"   , [quit]
menu #m ,  "Color"                 _
        ,  "no color"  , [nocolor] _
        ,  "Any color" , [anycolor]_
        ,|,"black"     , [black]   _
        ,  "yellow"    , [yellow]  _
        ,  "brown"     , [brown]  _
        ,  "red"       , [red]  _
        ,  "darkred"   , [darkred]     _
        ,  "green"     , [green]   _
        ,  "darkgreen" , [darkgreen] _
        ,  "blue"      , [blue]    _
        ,  "darkblue"  , [darkblue]    _
        ,  "magenta"   , [magenta] _
        ,  "cyan"      , [cyan]    _
        ,  "darkcyan"  , [darkcyan] _
        ,  "white"     , [white]   _
        ,  "pink"      , [pink]    _
        ,  "darkpink"  , [purple]  _
        ,  "ligthgray" , [gray]    _
        ,  "darkgray"  , [darkgray]

global filename$ , lastcolor$
global hwind , hdc
lastcolor$ = "red"
open "Sprite Draw It" for graphics as #m
  hwind = hwnd( #m )
  calldll #user32 , _
  "GetDC" , hwind as ulong , hdc as ulong
  #m "trapclose [quit]"
  #m "when leftButtonMove [leftbutton]"
wait
''================================file
[new]
  #m "cls"
  for x = 0 to 63
    for y = 0 to 63
      call setpixel x , y , "nocolor" ,not(0)
    next y
  next x
  filename$ = "empty.bmp"
wait
[open]
  filedialog "Load Sprite" , "*.bmp" , filename$
  if filename$ = "" then wait
  loadbmp "bmp" , filename$
  #m "drawbmp bmp 0 0"
  for x = 0 to 63
    for y = 0 to 63
      if getpixel$( x , y+64 ) = "0 0 0" then
        call setpixel x , y , "nocolor",0
      else
        call setpixel x , y , getpixel$( x , y + 64 ) ,(0)
      end if
    next y
  next x
wait
[saveas]
  filedialog "Save Sprite" , "*.bmp" , filename$
[save]
  #m "getbmp bmp 0 0 63 127"
  bmpsave "bmp", filename$
wait
[leftbutton]
  x = int( ( MouseX - 64 ) / 7 )
  y = int( MouseY / 7 )
  call setpixel x , y , lastcolor$ ,not(0)
wait
function getpixel$( x , y )
  CalldLL #gdi32, "GetPixel",_
        hdc as uLong, _
        x as Long, _
        y as Long, _
        clr as Long
  r = clr and 255
  g = int( clr / 256 ) and 255
  b = int( clr / 256 ^ 2 ) and 255
  getpixel$ = str$(r)+" "+str$(g)+" "+str$(b)
end function
[quit]
  calldll #user32 , "ReleaseDC" _
  , hwind as ulong _
  , hdc as ulong
  close #m
end
''==========================color
[nocolor] lastcolor$ = "nocolor" : wait
[anycolor]
  colordialog lastcolor$ , lastcolor$
wait
[black]     lastcolor$ = "black" : wait
[yellow]    lastcolor$ = "yellow" : wait
[brown]     lastcolor$ = "brown" : wait
[red]       lastcolor$ = "red" : wait
[darkred]   lastcolor$ = "darkred" : wait
[pink]      lastcolor$ = "pink" : wait
[darkpink]  lastcolor$ = "darkpink" : wait
[blue]      lastcolor$ = "blue" : wait
[darkblue]  lastcolor$ = "darkblue" : wait
[green]     lastcolor$ = "green" : wait
[darkgreen] lastcolor$ = "darkgreen" : wait
[magenta]   lastcolor$ = "255 000 255" : wait
[cyan]      lastcolor$ = "cyan" : wait
[darkcyan]  lastcolor$ = "darkcyan" : wait
[white]     lastcolor$ = "white" : wait
[purple]    lastcolor$ = "127 000 127" : wait
[gray]      lastcolor$ = "lightgray" : wait
[darkgray]  lastcolor$ = "darkgray" : wait
[orange]    lastcolor$ = "255 127 000" : wait
sub setpixel x , y , clr$ , spr
  if x < 0 then exit sub
  if x > 63 then exit sub
  if y < 0 then exit sub
  if y > 63 then exit sub
  if clr$ = "nocolor" then
    if spr then
      #m "color white"
      #m "set " ; x ; " " ; y
      #m "up"
      #m "goto " ; x ; " " ; y + 64
      #m "color black"
      #m "down"
      #m "set " ; x ; " " ; y + 64
      #m "up"
      #m "goto " ; 64 + x * 7 ; " " ; y * 7
      #m "down"
    end if
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; 71 + x * 7 ; " " ; 6 + y * 7
  else
    if spr then
      #m "color black"
      #m "up"
      #m "goto " ; x ; " " ; y
      #m "down"
      #m "set " ; x ; " " ; y
      #m "color " ; lastcolor$
      #m "up"
      #m "goto " ; x ; " " ; y + 64
      #m "down"
      #m "set " ; x ; " " ; y + 64
      #m "up"
    end if
    #m "goto " ; 64 + x * 7 ; " " ; y * 7
    #m "down "
    #m "backcolor " ; getpixel$( x , y +64 ) 'lastcolor$
    #m "boxfilled " ; 71 + x * 7 ; " " ; y * 7 + 6
    #m "up"
  end if
  #m "flush"
end sub

bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SPRITE 64 DRAW

Berichtdoor bluatigro » di feb 23, 2010 1:11 pm

update :
nu kun je op een plaats kiezen hoe groot de sprite is

dan moet je wet onhouden hoe groot elke sprite is

problem :
het prorgamma kijkt niet hoe groot
de ingeladen sprite is

Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHieght = DisplayHeight
''you may change the size of your sprites here
''but do this only 1 time
''or
''rechange it every time you have to edit
''a different sized sprite
global SprW , SprH
SprW = 63
SprH = 63
nomainwin
menu #m , "File"               _
        , "New"     , [new]    _
        , "Open"    , [open]   _
        , "Save as" , [saveas] _
        , "Save"    , [save]   _
        ,|,"Exit"   , [quit]
menu #m ,  "Color"                _
        ,  "no color"  , [nocolor] _
        ,  "Any color" , [anycolor] _
        ,|,"black"     , [black]   _
        ,  "red"       , [red]     _
        ,  "green"     , [green]   _
        ,  "yellow"    , [yellow]  _
        ,  "blue"      , [blue]    _
        ,  "magenta"   , [magenta] _
        ,  "cyan"      , [cyan]    _
        ,  "white"     , [white]   _
        ,  "pink"      , [pink]    _
        ,  "purple"    , [purple]  _
        ,  "gray"      , [gray]    _
        ,  "orange"    , [orange]
global filename$ , lastcolor$
global hwind , hdc
lastcolor$ = "red"
open "Sprite Draw It" for graphics as #m
  hwind = hwnd( #m )
  calldll #User32 , _
  "GetDC" , hwind as ulong , hdc as ulong
  #m "trapclose [quit]"
  #m "when leftButtonUp [leftbutton]"
wait
''================================file
[new]
  #m "cls"
  for x = 0 to SprW
    for y = 0 to SprH
      call pixel x , y , "nocolor" , 0
    next y
  next x
  filename$ = "empty.bmp"
wait
[open]
  filedialog "Load Sprite" , "*.bmp" , filename$
  loadbmp "bmp" , filename$
  #m "drawbmp bmp 0 0"
  for x = 0 to SprW
    for y = 0 to SprH
      if getpixel$( x , y ) =  "0 0 0" then
        call setpixel x , y , getpixel$( x , y + 64 ) , 0
      else
        call setpixel x , y , "nocolor" , 0
      end if
    next y
  next x
wait
[saveas]
  filedialog "Save Sprite" , "*.bmp" , filename$
[save]
  #m "getbmp bmp 0 0 " ; SprW ; " " ; SprH * 2 + 1
  #m "bmpsave bmp " ; filename$
wait
[leftbutton]
  x = int( ( MouseX - SprW ) / 7 )
  y = int( MouseY / 7 )
  call setpixel x , y , lastcolor$ , not( 0 )
wait
function getpixel$( x , y )
  CalldLL #gdi32, "GetPixel",_
        hwind as uLong, _
        x as Long, _
        y as Long, _
        clr as long
   r = clr and 255
  g = int( clr / 256 ) and 255
  b = int( clr / 256 ^  2 ) and 255
        getpixel$ = str$(r)+" "+str$(g)+"  "+str$(b)
end function
[quit]
  calldll "ReleaseDC" _
  , hwind as uloong _
  , hdc as ulong
  close #m
end
''==========================color
[nocolor] lastcolor$ = "nocolor" : wait
[anycolor]
  colordialog lastcolor$ , lasrcolor$
wait
[black]   lastcolor$ = "black" : wait
[red]     lastcolor$ = "red" : wait
[green]   lastcolor$ = "green" : wait
[yellow]  lastcolor$ = "yellow" : wait
[blue]    lastcolor$ = "blue" : wait
[magenta] lastcolor$ = "255 000 255" : wait
[cyan]    lastcolor$ = "cyan" : wait
[white]   lastcolor$ = "white" : wait
[pink]    lastcolor$ = "255 127 127" : wait
[purple]  lastcolor$ = "127 000 127" : wait
[gray]    lastcolor$ = "127 127 127" : wait
[orange]  lastcolor$ = "255 127 000" : wait
sub setpixel x , y , clr$ , spr
  if x < 0 then exit sub
  if x > SprW then exit sub
  if y < 0 then exit sub
  if y > SprH then exit sub
  if clr$ = "nocolor" then
    if spr then
      #m "color white"
      #m "set " ; x ; " " ; y
      #m "up"
      #m "goto " ; x ; " " ; y + SprH + 1
      #m "color black"
      #m "down"
      #m "set " ; x ; " " ; y + SprH + 1
      #m "up"
    end if
    #m "goto " ; SprW + x * 7 ; " " ; y * 7
    #m "down"
    #m "size 1"
    #m "backcolor black"
    #m "color white"
    #m "boxfilled " ; SprW + 6 + x * 7 ; " " ; 6 + y * 7
  else
    if spr then
      #m "color black"
      #m "up"
      #m "goto " ; x ; " " ; y
      #m "down"
      #m "set " ; x ; " " ; y
      #m "color " ; lastcolor$
      #m "up"
      #m "goto " ; x ; " " ; y + SprH + 1
      #m "down"
      #m "set " ; x ; " " ; y + SprH
      #m "up"
    end if
    #m "goto " ; SprW + x * 7 ; " " ; y * 7
    #m "down "
    #m "backcolor " ; lastcolor$
    #m "boxfilled " ; SprW + 6 + x * 7 ; " " ; y * 7 + 6
    #m "up"
  end if
  #m "flush"
end sub
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm


Keer terug naar OPEN SOURCE PROJECTEN

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron