prosperon/scripts/camera2d.jso

21 lines
674 B
Plaintext
Raw Normal View History

this.phys = physics.kinematic;
2024-04-03 17:17:32 -05:00
this.dir_view2world = function(dir) { return dir.scale(this.zoom); };
2024-04-03 00:44:08 -05:00
this.view2world = function(pos) {
pos = pos.scale([window.rendersize.x/window.size.x, window.rendersize.y/window.size.y]);
pos = pos.sub(window.rendersize.scale(0.5));
pos = pos.scale(this.zoom);
pos = pos.add(this.pos);
return pos;
};
this.world2view = function(pos) {
pos = pos.sub(this.pos);
pos = pos.scale(1.0/this.zoom);
2024-04-03 17:17:32 -05:00
pos = pos.add(window.rendersize.scale(0.5));
2024-04-03 00:44:08 -05:00
return pos;
};
2024-04-03 17:17:32 -05:00
this.screenright = function() { return this.view2world(window.size).x; }
2024-04-01 08:13:57 -05:00
this.screenleft = function() { return this.pos.x - (window.rendersize.x/2); }
2024-03-01 11:45:06 -06:00
2024-03-20 16:48:03 -05:00
this.zoom = 1;