Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is what I think of when I imagine math in game dev
- //It's the camera logic in one of my tests
- camZoom = Math.max(.7, Math.min(1.5, w/Math.sqrt(Math.pow(minX-maxX, 2)+Math.pow(minY-maxY, 2))/2));
- camZoomSmooth += (camZoom-camZoomSmooth)/4;
- camRotSmooth += (camRot-camRotSmooth)/10;
- camX = (minX+maxX)/2;
- camY = (minY+maxY)/2;
- camXSmooth += (camX-camXSmooth)/4;
- camYSmooth += (camY-camYSmooth)/4;
- var zoomM:Matrix = new Matrix(1, 0, 0, 1, -camXSmooth+camOffsetX, -camYSmooth+camOffsetY);
- zoomM.scale(camZoomSmooth+Math.sin(tick/50)*.2-.2, camZoomSmooth+Math.sin(tick/50)*.2-.2);
- zoomM.rotate((camRotSmooth+Math.sin(tick/45)*10)/180*Math.PI);
- zoomM.translate(w/2, h/2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement