Author Topic: Dynamic map loading  (Read 10152 times)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Dynamic map loading
« on: 2008-02-20, 05:17:31 PM »
I'd like to let it be known that there will eventually be a custom code object to allow for dynamic map loading.  This basically means you release your game with 10 levels and then later the user can download new levels online through the game's interface.

These maps are designed in the SGDK2 IDE just like regular maps, with a bit of a different flow afterwards.  You need to (or at least should.  Not entirely certain) keep the original game's exe around (the one without any maps in it) to reference, so after you've made a new level, save the .SGDK2 file somewhere else and compile it.  Then, using a program I have tentatively named "MapExtractor" (because that's basically what it does) you will select the code file(s) created by the IDE that you want to include in the update and compile them into a DLL file.  This file can then go online and be indexed into a list, and in the original game, the list can be looked up and the new map found, downloaded, and switched to with a function similar to SwitchToMap.

The basic code object and compiler are both pretty much complete.  The only thing is that they both rely on .NET 2.0 code, so the custom code object won't work with SGDK2.0, so we must wait until SGDK2.1 is released.

Errata: (not really, since I haven't actually edited this post :))
  • At least for now, the map must rely on sprites and tiles that are defined in the original game.  No new sprite definitions or tiles or graphics of any kind can be added or updated with the new DLL.  This may change in the future.  Not sure. 
  • You can include multiple maps in a single dll, so that from a single mod, you can access multiple areas, as long as you define the starting map in the resources of the dll file.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Dynamic map loading
« Reply #1 on: 2008-02-21, 08:13:52 AM »
wow, pretty cool thing. thumbs up!
for that "problem" with "no new sprites in a downloadable map" i would suggest the following:
i would separate map files from additional sprite/graphic content. this is because the game maker may provide 10 downloadable maps, with map 3 + 4 would have new graphics/sprites. the maker could think every user would be interested in downloading all maps, and use the new sprites in maps 5 - 10.
but the user doesn't know this or isn't interested in the early maps and only wants to try map 7. 
including new sprites in every map wouldn't be a good way, increasing the file size and making problems with several imports of the same things.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Dynamic map loading
« Reply #2 on: 2008-02-21, 08:57:46 AM »
I think you misunderstand my statement.  Due to technical reasons, it is impossible to add new graphics or sprites at runtime with the current implementation of my "MapExtractor" program.

This may not necessarily be true with sprites, actually.  It may be possible to add new sprites using existing graphics.  I haven't tested that out yet.  I will have to do that when I get a chance.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Dynamic map loading
« Reply #3 on: 2008-02-21, 10:10:20 AM »
okay then. i thought it was impossible now, but you could implement this sometime.
so if i wanted to add new graphics, i would have to provide a new version of my game.exe, am i right?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Dynamic map loading
« Reply #4 on: 2008-02-21, 12:28:14 PM »
That is the way it currently looks.  The current system does not actually write or change any code to merge the new data with data already in the executable, and since tilesets are all defined in one file, the compiler can't selectively add new tilesets.  This is not the case with sprites, which is why I thought it might be possible to add new sprites.
Edward Dassmesser

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Dynamic map loading
« Reply #5 on: 2011-12-17, 03:58:25 PM »
Is this still alive durund? It seems extremely amazing, and I have been eying it for at least a year now.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Dynamic map loading
« Reply #6 on: 2011-12-17, 08:54:15 PM »
Wow -- I have no recollection of this.  I wonder if durnurd does.  In any case, I suspect this is building on top of the SaveGame and LoadGame functions operating on a single map (using IncludeInSaveUnit).  Maybe it was never released if the SaveGame and LoadGame functions were straightforward enough that MapExtractor became obsolete?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Dynamic map loading
« Reply #7 on: 2011-12-19, 08:32:59 AM »
Almost no recollection of it whatsoever.  I do remember something about it, but I couldn't tell you anything about implementation.  I may very well have the implementation laying around somewhere on my Desktop, which I haven't turned on lately.  But if I remember, I can look and see what's there.  Since we're in .NET 2.0 now, it sounds like the major hurdle has been... hurdled?

I don't know how we would address the other hurdles though.  Like I said, I haven't looked lately.
Edward Dassmesser

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Dynamic map loading
« Reply #8 on: 2011-12-23, 08:49:25 PM »
Well again, I've uploaded the Output HTML5 Feature to a local server, I plan on doing something with it, (Being overzealous in nature it's best luck-wise to not reveal these plans  ;D)

But apart from that, would the SaveGame LoadGame feature allow someone to load a COMPLETELY New Map I've made (New Reference Name, etc)?
I was actually thinking it would be more efficient to have another EXE which automatically updated the file folder of my game through an internet connection. A counter called Version and if the Versions are Different, the client refuses the hots to enter the game..

But I know my plan seems to solve the above issue, but I ask this to wonder, would it be possible for some user playing my game to create an entirely new Map with and play it with my EXE using a SaveGame? Or do SaveGames only Handle Maps "inside" (lack of a better term) the Binary?

The Standalone Map Editor isn't important, I'll cross that bridge when I reach..

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Dynamic map loading
« Reply #9 on: 2011-12-24, 06:42:07 AM »
That's a good question.  Perhaps you could make one extra map in your game called "DynamicMap", and that could serve as the placeholder for any map you would want to load dynamically.  To create the map you would just define everything that's on DynamicMap (make sure everything else in the project stays exactly the same) and call SaveGame on just that one map (using IncludeInSaveUnit).  To load it, you would call LoadGame on the same slot/file.  These functions could be used like (along with) SwitchToMap to switch to any number of maps dynamically.  I'm not sure if it would work, but it's an idea.  I'm reasonably certain you could do that if all you were changing are the tiles on the map, and you may be able to make it work even with extra dynamically added sprites (not sprites linked to static names).  I'm not so sure how well it would work if you change the map parameters like size and layers... you probably couldn't have a different number of layers or different layer names.  Hard to say.  Basically anything that you can change at runtime, though, should be able to be saved.  So if you implement your map editor as something that edits DynamicMap at runtime, you should have little difficulty saving and loading it.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Dynamic map loading
« Reply #10 on: 2011-12-24, 09:25:32 AM »
Thanks. I was actually thinking about adding pseudo plans, but using a Tile Based System for those (Like the SGDK1 If a sprite touches certain tiles)
I'm not sure how new plans work with SaveGames, so I think that's the best way to go.

I think this solves my problem though, creating a DynamicMap and allowing players to use their own tiles on said map. Heck, they could possibly download a SaveGame another player made, and use it to play that player's map.