Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Game template — Gideros Forum

Game template

errtuerrtu Member
edited April 2012 in Building a team?
How do add levels to game template? Sorry, real newbie here.
Tagged:

Comments

  • ar2rsawseenar2rsawseen Maintainer
    You have a packs.json file, where all packs or game modes are defined and each one has a "level" property, which defines how many levels are there in this pack.
  • errtuerrtu Member
    First of all thanks.

    That part i get, but how do a link them to the levels i create. It alwais opens level file, how do a link to others files? Like level_1_1, level_1_2?
  • errtuerrtu Member
    Got it.
    It was so easy. Thanks...
  • @ar2rsawseen

    How do I add level info directly into the packs.json? For every level I have a different spawn table, which I save directly on a .lua table file like this:
    self.levelSpawnData = {
    	{ {1,2000}, {1,1000}, {2,0}, {1,1000} },
    	{ {2,1000}, {2,1000}, {2,2000}, {2,2000} },
            { {2,1000}, {1,1000}, {2,2000}, {2,0} }
    }
    Each line is a level and each row is a different enemy with a spawn time in milliseconds. I think it would be better to put that in packs.json, but I don't know how it's syntax works.

    {"packs":[
    {"name":"Intro pack","levels":6},
    {"name":"First pack","levels":20},
    {"name":"Second pack","levels":20},
    {"name":"Third pack","levels":12}
    ]}

    What I want to do is: on "levels" instead of specifying how many levels there are, put the levelSpawnData table there. Please help me out.
  • somezombiegmsomezombiegm Member
    edited May 2014
    I managed to make it work with something like this:
    {"packs":[
    {"name":"Intro pack","levels":[
    {"level":[
    {"type":1,"time":2000},{"type":1,"time":1000},{"type":2,"time":0},{"type":1,"time":1000}
    ]},
    {"level":[
    {"type":2,"time":2000},{"type":2,"time":1000},{"type":1,"time":0},{"type":1,"time":1000}
    ]},
    {"level":[
    {"type":1,"time":2000},{"type":2,"time":1000},{"type":1,"time":0},{"type":1,"time":1000}
    ]}
    ]},
    {"name":"First pack","levels":[
    {"level":[
    {"type":2,"time":2000},{"type":1,"time":1000},{"type":2,"time":0},{"type":1,"time":1000}
    ]},
    {"level":[
    {"type":1,"time":2000},{"type":2,"time":1000},{"type":1,"time":0},{"type":1,"time":1000}
    ]},
    {"level":[
    {"type":2,"time":2000},{"type":2,"time":1000},{"type":1,"time":0},{"type":1,"time":1000}
    ]}
    ]},
    {"name":"Second pack","levels":[
    {"level":[
    {"type":1,"time":2000},{"type":1,"time":1000},{"type":2,"time":0},{"type":1,"time":1000}
    ]}
    ]},
    {"name":"Third pack","levels":[
    {"level":[
    {"type":1,"time":2000},{"type":2,"time":1000},{"type":2,"time":0},{"type":1,"time":1000}
    ]}
    ]}
    ]}
    Each pack has several levels, each level has several enemies, each enemy has "type" and "time". I tested it and it works. The only problem could be when I put 50 or more enemies on each level.
  • Hi @somezombiegm


    {"packs":[
    {"name":"Intro pack","levels":6},
    {"name":"First pack","levels":20},
    {"name":"Second pack","levels":20},
    {"name":"Third pack","levels":12}
    ]}

    Defined above you could use an editor worlds, as Tilemap, for deploying everything that will contain the level easier.
    Here is official source, for loaded worlds, you've created with Tilemap
    https://github.com/gideros/Isometric-Tilemap
  • Hey @HubertRonald

    At first I didn't think Tilemap would be necessary. Because my character doesn't walk through a stage, but there are many enemies appearing constantly. I'm gonna check that link, thanks!
  • HubertRonaldHubertRonald Member
    edited May 2014
    Hi @somezombiegm

    It all depends on what you want to do, for example for my app, Paint pong I do not use the tilemap as you.

    Well I think you can also take advantage of the tilemap to create small puzzle
  • I've decided not to go with tilemap, cause it's just for the enemy spawn info. I'm gonna store the values on tables.

    Likes: HubertRonald

    +1 -1 (+1 / -0 )Share on Facebook
  • I've decided not to go with tilemap, cause it's just for the enemy spawn info. I'm gonna store the values on tables.
    Good choice ;)
  • @HubertRonald I'm having a lot of enemies and a lot of options for them, and my tables for them are getting to big. I want to use a tilemap but I don't want to use the packs.json option cause what I want is to design the levels easily. Something like these:
    000000000000000020000000000000
    000101001000100000000000000000
    000000000000000020000000000000
    000002002000003000000000000000
    000000000000000000000000000000
    000000000000001110000000000000
    000000000000001000000000000000
    The 0 are empty spaces and the other numbers are different enemies. How is that done? do I have to save that into a .txt file? Is that a good option for an android game? Should I save it on another file type?
  • HubertRonaldHubertRonald Member
    edited June 2014
    Hi @somezombiegm
    For your case, I would do the following
    -- name file: 
    -- Stage4of36.lua   for example
     
    -- after inside your file (Stage4of36.lua)
    return {
    000000000000000020000000000000
    000101001000100000000000000000
    000000000000000020000000000000
    000002002000003000000000000000
    000000000000000000000000000000
    000000000000001110000000000000
    000000000000001000000000000000
    }
    -- with commas numbers
    in your engine game you would have than load for example "Game/Stages/Stage4of36.lua"
    engineGame = Core.class(Sprite)
     
    function engineGame:init()
    --[[
    It dependent of where you've your file in your project
    (numbers 4 (world) and 36 (level)
    (you could have only levels in your game)
    you should implement them with
     data.save and a global variable like "sets" in your code
     but you'll have that define each file stage1fo1.lua, stage1fo1.lua,...)
    ]]
     self.infoLevel = loadfile(table.concat{"Game/Stages/Stage",4,"of",36,".lua"})() 
    --*
    --*
     
     self:deployFoes()
     
    --*
    --*
    end
    To implement the enemies my suggestion is that you you elaborate a master class that contains all its properties:
    foes = Core.Class(Sprite)
     
    function foes:init(index)
    --*
    --*
    end
     
    --other functions
    So all you could summarize it as follows
    function engineGame:deployFoes()
     self.foesGame={}
     for i=1, #self.infoLevel do
      if self.infoLevel[i]~=0 then -- I suppose than 1,2 and 3 are enemies
        self.foesGame[#self.foesGame+1] = foes.new(self.infoLevel[i])
        --[[
        if you had implemented a camera class otherwise
         self:addChild(self.foesGame[#self.foesGame])
        ]]
        self.camera:addChild(self.foesGame[#self.foesGame]) 
    end
    But as I said you, all depends on what you want to do, this is only a possible solution, there may be other.
    I want to use a tilemap but I don't want to use the packs.json option cause what I want is to design the levels easily.
    This is not necessarily true, you can use tilemap without than you use packs.json, as I mentioned, it all depends on what you want to implement and most importantly how you feel comfortable, as long as this doesn't affect performance of your code. ;)
  • @HubertRonald Thanks for the response. Something like that is what I'm looking for, I will work on it as soon as I can and come back if I get stuck or something LOL.
  • @HubertRonald I don't know how loadfile works, but I put the level info on a new file like you said and called it waveTest.lua and got this error message:
    waveTest.lua:3: '}' expected (to close '{' at line 1) near '000101001000100000000000000000'
  • petecpetec Member
    The message is telling you that you opened a curly bracket in line 1 but not closed it.
  • Yeah, it can be fixed by separating each line with a comma. But I wanted to know what HubertRonald was recommending me to do.
  • many thanks, it's useful for me!
    betdownload.com - the websites for introducing and evaluating software, providing tips for software, computer, mobile, internet, etc.
Sign In or Register to comment.