Is there any way to draw a map to only half of the screen? I want to make a local multiplayer splitscreen game, so both players would need different cameras. The problem with this is that one camera draws the map over the top of the other player's screen, as there is no way I can find to draw maps to only half the screen.

Interesting question, I also can't think of an easy solution.
One option would be to copy the map content into a sprite so that one could use the screen.drawSpritePart option to allow for (sort off) pixel perfect scrolling.
But there is no easy way to do that, looks like a painful subroutine.

Other option could be a feature request? screen.drawMapPart ? But would that be 'blocky' ?

One for the experts here, is there a 'hidden' option to copy a map into a sprite (offscreen?) or to only draw it partially?
Or do I just forget something obvious, LOL

P.S. I dragged this question to the Discord channel if you don't mind. Curious myself.

This is very much probably NOT what you want, but it is what I came up with on the fly.

This first example is brute force, just drawSprites for all items on each map - allows for sprite animations.


The second example is attempting what @TinkerSmith suggested, creating the map images for each side, which gives smoother scrolling, but does not (currently) support sprite animations.


microStudio lacks a function screen.setClipRect( x , y , w , h ) which would allow to do this more easily. I just filed an issue for it: https://github.com/pmgl/microstudio/issues/107

In the meantime, in addition to the solutions that have been proposed, I would suggest that one too:

  • create two offscreen image buffers (new Image( w , h )), each sized to half the screen
  • draw each player's view in its buffer
  • draw the image buffers side by side on screen

Post a reply



Validate your e-mail address to participate in the community