agar.io-clone icon indicating copy to clipboard operation
agar.io-clone copied to clipboard

Zooming out and in players feature request

Open slowas opened this issue 8 years ago • 4 comments

How add zooming in this? HELP

slowas avatar May 31 '16 13:05 slowas

Could you give more details?

abalabahaha avatar Jun 03 '16 19:06 abalabahaha

@abalabahaha Apperantly, he wants to have a feature to be able to zoom in and zoom out.

Nikitaw99 avatar Jun 04 '16 08:06 Nikitaw99

Even proportional to the player And if you zoom out in your browser, the canvas should not zoom out (see agar.io)

AlexDicy avatar Oct 04 '16 05:10 AlexDicy

Here a copy paste of my reply in 2 other similar 'issues' regarding this :

You basically just need to put a graph.setTransform(x, 0, 0, x, 0, 0); inside the app.js file in the gameloop function and just after graph.fillRect(0, 0, global.screenWidth * zoomfactor , global.screenHeight * zoomfactor );

Note the zoom factor variable (actually it should be called dezoom factor). Then you just apply the zoom factor after global.screenWidth/height and global.gameWidth/height to the position of every entities that is drawn .

also here (to get all the data from the server : socket.emit('windowResized', { screenWidth: global.screenWidth* coef_zoom, screenHeight: global.screenHeight* coef_zoom });

careful though because of the game architecture, sending many visible entities uses a lot of bandwith and you ll need to optimize the amount of data sent (there is a lot of optimization possible) , unless of course you make a predictive client side.

geopi avatar Mar 20 '17 01:03 geopi