News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Tile based game engine for murgaLua
Author Message
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
Tile based game engine for murgaLua

Hello again,

I read the excellent document "Tile Based Games" from Tonypa this night again and asked me, if anyone has started to port this ideas to murgaLua ?
Are there pure lua-engines available ? I found "C with Lua" mixtures only.
I have already done some work for my NXT-Simulator this year, but now I'd like to
rewrite it from scratch in a better way...

My problem is currently the OO thinking with Lua Big Grin
Can anybody give me some ideas or links, how to do it with Lua ?

Thanks
Bye
Christian

08-15-2007 04:56 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #2
RE: Tile based game engine for murgaLua

Hi,

I've prepared a lot of code for the simple Mindstorms NXT Simulation (Robot Simulator)...
Is it OK to add this as an zipped archive to this thread ?
It should be a base of discussion for all my problems, exploring murgaLua-Graphics
and basic GUI-Design...

Daily I'm rengineer the wheel... but there already exists solutions

Bye
Christian

08-19-2007 09:10 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #3
RE: Tile based game engine for murgaLua

Feel free, or e-mail it to me at john@murga.org and I'll attach it.

08-20-2007 09:34 PM
Visit this user's website Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #4
RE: Tile based game engine for murgaLua

JohnMurga Wrote:
Feel free, or e-mail it to me at john@murga.org and I'll attach it.


Hi John,
my new code to too ugly and buggy...
I attach old code from may, just showing the idea of Mindstorms NXT simulation ;-(

Give me one more month and I send you the new code...

Bye
Christian



Attached File(s)
.zip File  NXTLuaSim.zip (Size: 49.61 KB / Downloads: 1)
08-21-2007 07:26 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #5
RE: Tile based game engine for murgaLua

Hi,
last night I started new map design with the following code:

Code:
--[[
    Tile object signatures for ASCII-MAP

    floor            = '_'
    wall            = '#'
    water              = 'W'
    tree               = 'T'
    light source          = 'L'
    sound source        = 'S'
    enemy              = 'E'
    door               = 'D'
    friend               = 'F'
    NXT              = 'N'

--]]

    local i,y;
    y=20;
    map={}
    for i=1,y do
        map[i]={}
    end


    map[1]= {'#','#','#','#','#','#','#','#','#','D','#','#','#','#','#','#','#','#','#','#' };

    map[2]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[3]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[4]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[5]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[6]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[7]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[8]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[9]= {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','#' };

    map[10]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[11]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[12]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[13]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[14]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[15]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[16]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[17]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[18]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[19]={'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','# '};

    map[20]={'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','# '};

-- end

Is this useful or any better ideas ?
Bye
Christian

08-21-2007 08:14 PM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #6
RE: Tile based game engine for murgaLua

It seems a little redundant. You initially set each index of map to an empty string, and then set them all over again. You could remove the 'for' loop entirely and get the same result.

You might also be able to set up the map table as a single declaration (omitting the individual "map[num]=" declarations), but I don't recall ever doing that to say for sure.

08-22-2007 02:02 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #7
RE: Tile based game engine for murgaLua

Odd thing...
I made a table with a single "map={...}" declaration, and it seems to work, but not as I expected.
Having each table entry enclosed in curly brackets apparently makes each entry a table within the map table. I don't know if this is what you wanted, but I had never thought about the possibilities of this type of setup.

Code:
map={
    {'#','#','#','#','#','#','#','#','#','D','#','#','#','#','#','#','#','#','# ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_ ','# '},
    {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','# ','# '}
}
fourth_table=map[4]
print(fourth_table[2]) -- a floor tile

This post was last modified: 08-22-2007 06:38 AM by mikshaw.

08-22-2007 06:36 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #8
RE: Tile based game engine for murgaLua

Hi Mikshaw,
your're right, but I want to access map with simple construct like:

tile=map[x][y]

That's better for human eyes Big Grin

Bye
Christian


mikshaw Wrote:
Odd thing...
I made a table with a single "map={...}" declaration, and it seems to work, but not as I expected.
Having each table entry enclosed in curly brackets apparently makes each entry a table within the map table. I don't know if this is what you wanted, but I had never thought about the possibilities of this type of setup.

Code:
map={
    {'#','#','#','#','#','#','#','#','#','D','#','#','#','#','#','#','#','#' ,'#','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','#' },
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' ,'_','# '},
    {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' ,'#','# '}
}
fourth_table=map[4]
print(fourth_table[2]) -- a floor tile

08-22-2007 08:12 PM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #9
RE: Tile based game engine for murgaLua

Quote:
tile=map[x][y]

Ahhhh. Thank you.
I was trying to figure out how to directly access the nested table, but that syntax didn't occur to me.
The closest I got was something like map[x[y]] before the bulky solution worked and I quit looking =o)

08-23-2007 12:28 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #10
RE: Tile based game engine for murgaLua

mikshaw Wrote:

Quote:
tile=map[x][y]

Ahhhh. Thank you.
I was trying to figure out how to directly access the nested table, but that syntax didn't occur to me.
The closest I got was something like map[x[y]] before the bulky solution worked and I quit looking =o)


Hi,
with this functions, it is easy to access all map arrays...
Some usefull stuff

Code:
function MapShow()
local x,y;
    for y=1,20 do
        for x=1,#map[y] do
            if (nil~=map[x][y]) then
                print("Tile="..map[x][y].." x="..x.." y="..y);
            end
        end
    end
end

function TileObject()

end

function WindowGetSize()
local x,y;
    x=1;
    while(nil~=map[x]) do x=x+1 end
    x=x-1;
    y=1;
    while(nil~=map[x][y]) do y=y+1 end
    y=y-1;
    y=y*TileSizeY;
    x=x*TileSizeX;
    
    return x,y;
end

--[[
***** MAP WINDOW *****
--]]
TileSizeX=30;
TileSizeY=30;

MapCreate(x,y);
MapShow();
x,y=WindowGetSize()
print("WindowsSize x="..x.." y="..y);


Bye
Christian

08-23-2007 03:15 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: