Author Topic: OxyMap Tutorial v.oo1  (Read 2466 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
OxyMap Tutorial v.oo1
« on: October 11, 2012, 11:23:20 AM »
Hi Aurel,
 
This is a lot of easier and you are able to create your own game.
Code: [Select]
include "sw.inc"

'variables
sys xBoy,yBoy,zBoy,rBoy,xExit,yExit,zExit,aExit,xShrink,yShrink,zShrink
sys ras,pills,yPill,xPill,zPill,x,y,z,zatom

byte map1[1200]
byte map2[1200]
byte map3[1200]

'loadbitmaps
s1= LoadBmp "gfx/char.bmp",60
s2= LoadBmp "gfx/atom.bmp",16
s3= LoadBmp "gfx/boyd.bmp",16
s4= LoadBmp "gfx/boyu.bmp",16
s5= LoadBmp "gfx/boyr.bmp",16
s6= LoadBmp "gfx/boyl.bmp",16
s7= LoadBmp "gfx/exitani.bmp",16
s8= LoadBmp "gfx/pillani.bmp",16
s9= LoadBmp "gfx/boyani.bmp",16

'loadmaps
h1= OpenFile "maps/map1-1.txt"
h2= OpenFile "maps/map1-2.txt"
h3= OpenFile "maps/map1-3.txt"
    ReadByte h1,map1,1199
    ReadByte h2,map2,1199
    ReadByte h3,map3,1199
    CloseFile h1
    CloseFile h2
    CloseFile h3
    
'game routines
Sub ShowMaps()
    static float vAtom
    for y=0 to 29
      for x=0 to 39
z=y*40+x
if map1[z]=34  then DrawBmp s1,x*64,y*64,64,64,1
if map1[z]=41  then DrawBmp s1,x*64,y*64,64,64,2
if map2[z]=91  then DrawBmp s2,x*64,y*64,64,64,zatom
if map2[z]=121 then DrawBmp s7,x*64,y*64,64,64,0
      next
    next
    vAtom +=.2
    if vAtom >=1
       vAtom=0
       inc zAtom
       if zAtom=16 then zAtom=0
    end iF        
End Sub

Sub InitBoy()
    for y=0 to 29
      for x=0 to 39
        z=y*40+x
if map3[z]=111
           xBoy=x*64
           yBoy=y*64
        end if
        if map2[z]=91
           pills +=1
        end if
        if map2[z]=121
  xExit=x*64
  yExit=y*64
end if  
      next
    next
End Sub    
  
Sub CheckBoy()
    if ras >0 or rBoy=5 then exit Sub
    z=(yBoy*40+xboy)/64
    if map2[z]=121 and aExit=1
       xShrink=xBoy
       yShrink=yBoy
       map3[z]=32
       rBoy=5      
    else if map2[z]=91
       xPill=xBoy
       yPill=yBoy
       Pills -= 1
       map2[z]=32
       map3[z]=32
       rBoy=0
       PlayWav "gfx/caim.wav"
    else if Key(39) <0 and map3[z+1]=32
       map3[z]=32
       map3[z+1]=111
       rBoy=1
    else if Key(37) <0 and map3[z-1]=32
       map3[z]=32
       map3[z-1]=111
       rBoy=2
    else if Key(38) <0 and map3[z-40]=32
       map3[z]=32
       map3[z-40]=111
       rBoy=3
    else if Key(40) <0 and map3[z+40]=32
       map3[z]=32
       map3[z+40]=111
       rBoy=4
    else
       rBoy=0    
    end if      
End Sub    

Sub DrawBoy()
    static float vBoy
    if rBoy=0
       DrawBmp s3,xBoy,yBoy,64,64,15
    else if rBoy=1
       xBoy +=1
       DrawBmp s5,xBoy,yBoy,64,64,zBoy
       vBoy +=.5
       if vBoy >=1
          vBoy=0
          zBoy +=1
          if zBoy=16 then zBoy=0
       end if
       ras +=1
       if ras=64 Then ras=0
    else if rBoy=2
       xBoy -=1
       DrawBmp s6,xBoy,yBoy,64,64,zBoy
       vBoy +=.5
       if vBoy >=1
          vBoy=0
          zBoy +=1
          if zBoy=16 then zBoy=0
       end if
       ras +=1
       if ras=64 Then ras=0
    else if rBoy=3
       yBoy -=1
       DrawBmp s4,xBoy,yBoy,64,64,zBoy
       vBoy +=.5
       if vBoy >=1
          vBoy=0
          zBoy +=1
          if zBoy=16 then zBoy=0
       end if
       ras +=1
       if ras=64 Then ras=0
    else if rBoy=4
       yBoy +=1
       DrawBmp s3,xBoy,yBoy,64,64,zBoy
       vBoy +=.5
       if vBoy >=1
          vBoy=0
          zBoy +=1
          if zBoy=16 then zBoy=0
       end if
       ras +=1
       if ras=64 Then ras=0
    end if
End Sub

Sub PillsAni()
    static float vPill
    if ypill >0
       DrawBmp s8,xpill,yPill,64,64,zPill
       vPill +=.2
       if vPill >=1
          vPill=0
 zPill +=1
          if zPill=16        
             zPill=0
    yPill=0
 end if  
       end if
    end if  
End sub

Sub NoPills()
    if Pills=0
       if pills=0 and aExit=0 then PlayWav "gfx/success.wav"
       aExit=1
    end if
End Sub    

Sub ExitActiv()
    static float vExit
    if aExit=1
       DrawBmp s7,xExit,yExit,64,64,zExit
       vExit +=.2
       if vExit >=1
           vExit=0
  inc zExit
  if zExit=16 then zExit=0
       end if
    end if
End Sub

Sub BoyShrink()
    static float vShrink  
    if yShrink >0
      DrawBmp s9,xShrink,yShrink,64,64,zShrink
      vShrink +=.2
      if vShrink >=1
         vShrink=0
         zShrink +=1
         if zShrink=16 then yShrink=0
      end if      
    end if    
End Sub

'main settings
InitBoy
Window 768,708,"Map Running Around Demo"

Sub MainDraw()
    Cls(0)
    ShowMaps
    ExitActiv
    BoyShrink
    CheckBoy
    DrawBoy
    PillsAni
    NoPills
    if rBoy=5
       SetFont 34,66,FW_BOLD,""
       SetText 180,340," IS OVER NOW!",RGB(200,255,85)
    end if        
    Swap
    SetFps(120)
End Sub    
« Last Edit: January 05, 2013, 05:53:06 PM by peter »

Aurel

  • Guest
Re: OxyMap Tutorial v.oo1
« Reply #1 on: October 11, 2012, 12:29:32 PM »
Hi Peter...
That is what i want and i guess most of others who are not gamers but want
to make simple games ;)

PS.
Now arrow keys wotk properly.. :)
Grrr....i still cannot figured why not work in big example... >:(
 ;)

Peter

  • Guest
Re: OxyMap Tutorial v.oo1
« Reply #2 on: October 11, 2012, 02:15:00 PM »
Hi Aurel,

This is the solution.


« Last Edit: January 05, 2013, 05:53:29 PM by peter »

Aurel

  • Guest
Re: OxyMap Tutorial v.oo1
« Reply #3 on: October 12, 2012, 05:37:10 AM »
Sorry Peter but is not ..
after few seconds program just crush.
Example mapdemo.bas with sw.inc work
only moving is slow.
I see that main difference is in SCREEN() in easy.inc and mapdemo use
sw.inc which use WINDOW() who have message loop inside not in function
Events().
I am not sure that this cause main problem - crushing... :(

Peter

  • Guest
Re: OxyMap Tutorial v.oo1
« Reply #4 on: October 12, 2012, 06:59:13 AM »
Hi Aurel,

look for Key(-1) and remove it.

Aurel

  • Guest
Re: OxyMap Tutorial v.oo1
« Reply #5 on: October 12, 2012, 08:27:44 AM »
Uffff...ok i will try this ::)