Implement smooth zoom
authorunc0rr
Thu, 10 Sep 2009 12:42:01 +0000
changeset 2372 f3e7a066c2b8
parent 2371 a20b6e26044b
child 2373 e3989519731b
Implement smooth zoom
hedgewars/CCHandlers.inc
hedgewars/uMisc.pas
hedgewars/uWorld.pas
--- a/hedgewars/CCHandlers.inc	Thu Sep 10 12:23:31 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Sep 10 12:42:01 2009 +0000
@@ -682,12 +682,12 @@
 
 procedure chZoomIn(var s: shortstring);
 begin
-if zoom < 4.0 then zoom:= zoom + 0.25;
+if ZoomValue < 3.0 then ZoomValue:= ZoomValue + 0.25;
 end;
 
 procedure chZoomOut(var s: shortstring);
 begin
-if zoom > 0.25 then zoom:= zoom - 0.25;
+if ZoomValue > 0.5 then ZoomValue:= ZoomValue - 0.25;
 end;
 
 procedure chChat(var s: shortstring);
--- a/hedgewars/uMisc.pas	Thu Sep 10 12:23:31 2009 +0000
+++ b/hedgewars/uMisc.pas	Thu Sep 10 12:42:01 2009 +0000
@@ -60,6 +60,7 @@
 	cBitsStr         : string[2] = '32';
 	cTagsMask        : byte = 7;
 	zoom             : GLfloat = 2.0;
+	ZoomValue        : GLfloat = 2.0;
 
 	cWaterLine       : LongInt = LAND_HEIGHT;
 	cVisibleWater    : LongInt = 128;
--- a/hedgewars/uWorld.pas	Thu Sep 10 12:23:31 2009 +0000
+++ b/hedgewars/uWorld.pas	Thu Sep 10 12:42:01 2009 +0000
@@ -296,6 +296,17 @@
     end;
 
 begin
+if ZoomValue < zoom then
+	begin
+	zoom:= zoom - 0.001 * Lag;
+	if zoom < ZoomValue then zoom:= ZoomValue
+	end else
+if ZoomValue > zoom then
+	begin
+	zoom:= zoom + 0.001 * Lag;
+	if zoom > ZoomValue then zoom:= ZoomValue
+	end;
+	
 // Sky
 glClear(GL_COLOR_BUFFER_BIT);
 glEnable(GL_BLEND);