agar.io-clone
agar.io-clone copied to clipboard
Zooming out and in players feature request
How add zooming in this? HELP
Could you give more details?
@abalabahaha Apperantly, he wants to have a feature to be able to zoom in and zoom out.
Even proportional to the player And if you zoom out in your browser, the canvas should not zoom out (see agar.io)
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.