Author Topic: Mappy Code  (Read 4564 times)

MrTAToad

  • Guest
Mappy Code
« on: 2010-Apr-15 »
This is the source code to my Mappy routine.

And a test program :

Code: GLBasic [Select]
LOCAL mapX%,mapY%,result%

LIMITFPS -1

result%=Mappy_LoadFile("Level01.FMP",0)
DEBUG "Layer Names : "+Mappy_GetLayerNames$()+"\n"
DEBUG "Map Width : "+Mappy_GetMapWidth()+"\n"
DEBUG "Map Height : "+Mappy_GetMapHeight()+"\n"
DEBUG "Map Depth : "+Mappy_GetMapDepth()+"\n"
DEBUG "Map Author : "+Mappy_GetAuthor$()+"\n"
DEBUG "Mappy Version : "+Mappy_Version()+"\n"
SELECT Mappy_GetMapFormat()
        CASE    0
                                DEBUG "FMP 0.5\n"
        CASE    1
                                DEBUG "FMP 1.0\n"
        CASE    2
                                DEBUG "FMP 1.0 RLE\n"
ENDSELECT
IF Mappy_IsLSB()
        DEBUG "Data is in LSB format\n"
ELSE
        DEBUG "Data is not in LSB format\n"
ENDIF

DEBUG "Add new layer : "+Mappy_AddLayer(1)+"\n"
DEBUG "Number of layers : "+Mappy_GetNumberOfLayers()+"\n"
DEBUG "Delete a layer : "+Mappy_DeleteLayer(1)+"\n"
DEBUG "Number of layers : "+Mappy_GetNumberOfLayers()+"\n"
DEBUG "Map Block Width : "+Mappy_GetBlockWidth()+"\n"
DEBUG "Map Block Height : "+Mappy_GetBlockHeight()+"\n"
DEBUG "Number Of Blocks : "+Mappy_GetNumberOfBlocks()+"\n"

//loadMappyGraphics()
mapX%=0
mapY%=0

WHILE TRUE
        DrawMap(mapX%,mapY%,0,0,640,480)
//      DrawMap(mapX%,mapY%,320,0,319,239)
//      DrawMap(mapX%,mapY%,0,240,319,239)
//      DrawMap(mapX%,mapY%,320,240,319,239)

        PRINT "Result : "+result%,0,0
        PRINT "Collision : "+Mappy_Collision(29*16,36*16,29*16,37*16),0,16

        IF KEY(203)
                IF mapX%>0 THEN DEC mapX%
        ELSE
                IF KEY(205)
                        INC mapX%
                ENDIF
        ENDIF

        IF KEY(200)
                IF mapY%>0 THEN DEC mapY%
        ELSE
                IF KEY(208)
                        INC mapY%
                ENDIF
        ENDIF

        SHOWSCREEN

        DEBUG "JJ\n"
        Mappy_UpdateAnimations()
WEND

END

FUNCTION loadMappyGraphics%:
LOCAL l%
LOCAL name$
LOCAL num$

        SETTRANSPARENCY 0
        FOR l%=1 TO Mappy_GetNumberOfBlocks()-1
                num$="000000"+l%
                name$="Media/MappyGraphics/G"+MID$(num$,LEN(num$)-6,6)+".png"
                IF DOESFILEEXIST(name$)=FALSE
                        DEBUG "Not found : "+name$+"\n"
                        RETURN FALSE
                ELSE
                        LOADSPRITE name$,l%
                ENDIF
        NEXT

        RETURN TRUE
ENDFUNCTION
 

[attachment deleted by admin]

Offline Quentin

  • Prof. Inline
  • *****
  • Posts: 915
    • View Profile
Re: Mappy Code
« Reply #1 on: 2010-Apr-15 »
Wow! This looks like great work :)

Do you have an example map to play with?

MrTAToad

  • Guest
Re: Mappy Code
« Reply #2 on: 2010-Apr-16 »
These should work fine.

Isometric maps wont work (at least not until a map drawing system is done), because its not an area that I have knowledge about.

[attachment deleted by admin]

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
Re: Mappy Code
« Reply #3 on: 2010-Apr-16 »
Great, I'll be sure to check this out and get back to you on it....

And I tried to give it a shot, but said "mapdefs.h: no such file or directory" then followed by a crazy compiler fit, but I figured that was because of the missing header file.
 
« Last Edit: 2010-Apr-16 by Scott_AW »
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

MrTAToad

  • Guest
Re: Mappy Code
« Reply #4 on: 2010-Apr-16 »
The mapdefs.h file is included in the other post.  It goes in the same place as the project file.

I've included my project file now :)

[attachment deleted by admin]

Offline AlienMenace

  • Mr. Polyvector
  • ***
  • Posts: 149
    • View Profile
Re: Mappy Code
« Reply #5 on: 2011-Apr-15 »
I receive this error:

"TestMappy.gbas"(44) error : wrong number of aguments : "DrawMap" called with 6 args. Required: 9 to 13

on this line:

DrawMap(mapX%,mapY%,0,0,640,480)
Apps published: 3

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Mappy Code
« Reply #6 on: 2011-Apr-15 »
Code: GLBasic [Select]
FUNCTION DrawMap: scroll_x%, scroll_y%, sx%, sy%, width%, height%, pIndex%, pX%, pY%, fromLayer%=0, toLayer%=-1, wrap_x% = FALSE, wrap_y% = FALSE
 

You have to set the parameters without a default value:

scroll_x%,
scroll_y%,
sx%,
sy%,
width%,
height%,
pIndex%,
pX%,
pY%
.

cheers

MrTAToad

  • Guest
Re: Mappy Code
« Reply #7 on: 2011-Nov-09 »
Updated mappy code

[attachment deleted by admin]
« Last Edit: 2011-Nov-09 by MrTAToad »