Author Topic: Mario&China  (Read 1906 times)

Peter

  • Guest
Mario&China
« on: November 21, 2012, 06:13:47 PM »
Hi,

a little tile test.
Code: [Select]
function SetTile(id,x,y,w,h,xframe,yframe)
   drawimage(w*xframe,h*yframe,w,h,x,y,id)
end

function Sprite(id,x,y,w,h,fx)
   drawimage(w*fx,0,w,h,x,y,id)
end

function ImageText(id,tx,ty,txt,width,height)
  local sx,rx
   for sx=1, len(txt) do
     rx = asc(mid(txt,sx,1))
     if rx >=32 and rx <=127 then
        rx = rx -32
        Sprite(id,tx,ty,width,height,rx)
        tx=tx + width
     end
   end
end

screen(640,480,0,"Mario&Mario")
setframetimer(60)
backcolor(10,200,200)
colorkey(0,0,0)

fo=loadimage("mario/zfont.bmp")
m1=loadimage("mario/mariochina.png")
m2=loadimage("mario/pipi.png")
m3=loadimage("mario/hexer_left.png")
m4=loadimage("mario/hexer_right.png")
m5=loadimage("mario/bowgirl.png")
m6=loadimage("mario/boyboy.png")

local zx1=0;hx=0;hy=0;vz=0;hz=0;bx=0;by=0;bz=0;d=1;rx=64;fx=0;rz=0
mm=fliphorizontal(m5)

repeat
key= getkey()
cls()
SetTile(m1, 64,64,64,64,zx1,0)
SetTile(m1,128,64,64,64,zx1,1)
SetTile(m1,192,64,64,64,zx1,2)
SetTile(m1,256,64,64,64,zx1,3)
SetTile(m1,320,64,64,64,zx1,4)
SetTile(m1,384,64,64,64,zx1,5)
SetTile(m1,448,64,64,64,zx1,6)
SetTile(m1,512,64,64,64,zx1,7)

SetTile(m2, 64,128,50,85,zx1,0)
SetTile(m2,128,128,50,85,zx1,1)
SetTile(m2,192,128,50,85,zx1,2)
SetTile(m2,256,128,50,85,zx1,3)

SetTile(m3,64,220,64,64,hx,hy)
SetTile(m4,128,220,64,64,hx,hy)

SetTile(m5,256,230,64,64,bx,by)
SetTile(mm,402,230,64,64,bx,by)

if d==1 then
   SetTile(m6,rx,400,64,64,fx,1)
   rx = rx +1
   if rx >= 560 then
      d=2
   end
end
if d==2 then
   SetTile(m6,rx,400,64,64,fx,3)
   rx = rx -1
   if rx <= 64 then
      d=1
   end
end

rz = rz + .1
if rz >= 2.5 then
   rz=0
   fx=fx +1
   if fx ==4 then
      fx=0
   end
end

vz = vz + .1
if vz >=1 then
   vz =0
   zx1= zx1 +1
   if zx1==4 then
      zx1=0
   end
end

hz = hz + .1
if hz >=1 then
   hz=0
   hx = hx+1
   if hx==4 then
      hx=0
      hy = hy +1
      if hy==7 then
         hy=0
      end
   end
end

bz = bz + .1
if bz >=2 then
   bz=0
   bx = bx+1
   if bx==4 then
      bx=0
      by = by +1
      if by==10 then
         by=0
      end
   end
end

ImageText(fo,132, 16,"MARIO CHINA",32,32)
ImageText(fo,260,310,"BOW GIRLS",32,32)
ImageText(fo,44, 310,"HEXER",32,32)
ImageText(fo,320,164,"PIPI SOCK",32,32)
sync()
until key == 27
closewindow()