Skip to main content

News

Topic: Resizing a map via scripting? (Read 6211 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Resizing a map via scripting?
Would it be possible to resize the width/height current map in-game, short of manually modifying the file and reloading?
I have an idea for a game that requires the map to be able to grow, and it wouldn't work (as well) if I just went with a very large map instead.

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Resizing a map via scripting?
Reply #1
It's not really the map itself that has sizes, but the individual layers. You can use SetLayerWidth(layer_num, width) and SetLayerHeight(layer_num, height) for that.

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Resizing a map via scripting?
Reply #2
You almost need your own solution. Unfortunately Sphere doesn't allow you to stitch maps together. It'd be a neat feature to see someday.

If you do use DaVinces advice, prepare to write game logic to set the tiles for the newly grown layers, because I'm pretty sure it'd just be filled with the tile at index 0. So you're almost the way there to creating tiles for a custom map engine, expect now you have the power of other features of sphere's map engine.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Resizing a map via scripting?
Reply #3
Hm, it appears minisphere doesn't implement the resizing functions!  Were those Sphere 1.6?  I admit I didn't take a very close look at what was new in 1.6 during initial development.  Those would likely be pretty easy to add, it's surprising I never thought of it.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Resizing a map via scripting?
Reply #4

Hm, it appears minisphere doesn't implement the resizing functions!  Were those Sphere 1.6?  I admit I didn't take a very close look at what was new in 1.6 during initial development.  Those would likely be pretty easy to add, it's surprising I never thought of it.


Memory tells me they were not known publicly. I think they might have been in the code base. Though, I'm not sure if the functions worked or if they had bugs and was the reason why nobody knew of them.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Re: Resizing a map via scripting?
Reply #5

If you do use DaVinces advice, prepare to write game logic to set the tiles for the newly grown layers, because I'm pretty sure it'd just be filled with the tile at index 0. So you're almost the way there to creating tiles for a custom map engine, expect now you have the power of other features of sphere's map engine.

With what I plan to do, that actually wouldn't be a problem, since it will be generating things via a template as it goes anyway.


And if it means using Sphere 1.5 until it's implemented in minisphere, I'll do that.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Resizing a map via scripting?
Reply #6
I just implemented the layer-resizing functions in minisphere:


It required more new code than I originally anticipated, because I had to add logic to keep zones and triggers in-bounds, recalculate the map size, etc.  Overall it was relatively painless though, just had to spend some time working out the glitches. :)  As a convenience, I also added SetLayerSize(), to set both dimensions at once.  The change will be in minisphere 3.0.1.

Figures this didn't come up before today, I could have snuck it into 3.0.0 at the last second. ;)
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Resizing a map via scripting?
Reply #7
Well it's good to know that a game idea I came up with on a whim (sort of) got minisphere some new code.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Resizing a map via scripting?
Reply #8
Just doing my job.  :D
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Resizing a map via scripting?
Reply #9
I also remember SetLayerSize() not being a thing, and was surprised to see it in the function list when I double checked. Guess it was a 1.6 thing. It really ought to exist, anyway, so it's good that it does. And now in minisphere too. :P

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Resizing a map via scripting?
Reply #10
Yep, it's in 3.0.1.

I'm actually planning on eventually making a new JS-based object-oriented map engine as part of miniRT, so I'll keep some of Radnen's ideas in mind re: map stitching and such.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub