[SOLVED] Zoom out more the bigger you are?


(John Andersson) #1

I’ve decided to add some size altering upgrades in the game, but the problem is that the camera isn’t changing depending on the size your character is. So if I upgrade my character enough, he becomes really big, but the camera is showing too little of the level. Since he becomes really big, the player should see more of the level. I tried playing with FP.screen.scale to no success.

So, in short; How do you zoom in and out with the camera in mind?


(Zachary Lewis) #2

I’d change the scale of the enemies and world.


(John Andersson) #3

There are a lot of enemies and different objects in the world, it seems like I would have to do a lot of programming with that approach.

Isn’t there just a normal zoom function?


(Zachary Lewis) #4

No. The camera doesn’t work like a 3D camera would, where you can “back away” from the screen.


(John Andersson) #5

How long would it take to remake the camera? Because adding a trivial function as a zoom seems like it should be part of the flashpunk camera.


(Jacob Albano) #6

“Trivial” is a word you probably shouldn’t use unless you’ve checked the source yourself. A lot of functionality depends on the camera size being constant, like backdrop tiling and canvas rendering.


(Zachary Lewis) #7

Imagine the screen is a TV, and you’re watching the show. If you use FP.screen.scale, it’s like moving closer to the television. The image you’re watching gets larger, but the number of people on the screen doesn’t change. To fit lots of people on the screen, the people have to get much smaller, like in an overhead shot.


(Mike Evmm) #8

Actually this seems to be a common problem; why not make a “global scale” that would be *=-ed to every entity if zoom <1? That would prevent needing to have every entity extend a custom entity class.


(Martí Angelats i Ribera) #9

I guess it could be done by reducing the scale of the screen and making the screen bigger at the same time. This will make you have more pixels in the screen so it’s not what FP is based.

FP.resize(originalWidth*k, originalHeight*k);
FP.screen.scale = 1/k;

You’ll also have to move the camera point correctly and I think there was problems with a single black frame when resizing.


The other option is to rewrite the Screen to make a custom option. Then use the draw to render the prerendered world (to soom out you’ll make the size of it larger). This will make the entire library slower so if someone is interested, i might code it, but i don’t think it should be a general thing for the entire library.


(Zachary Lewis) #10

I made a thing.


(Mike Evmm) #12

So, if I got things right, you @Copying 's suggested approach instead of scaling down everything?


(Martí Angelats i Ribera) #13

No. He did it the right way (scalling everything)


(John Andersson) #14

Okay that’s pretty awesome :slight_smile: Thanks