Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Ayumi, PeWi, Quad, VoroneTZ), 513 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zoom in/out with mikey #397063
03/14/12 00:03
03/14/12 00:03
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Hey guy, asking for some help please?

I'm trying to convert/use this code:
Code:
starter wheel_zoom()
{
while (1)
{
if (mickey.z > 1)
{
camera.arc += 10 * time; // play with "10"
}
if (mickey.z < -1)
{
camera.arc -= 10 * time; // play with "10"
}
camera.arc = min (max (camera.arc, 10), 120); // limit camera.arc to 10..120
wait (1);
}
}


But I get an error for the min undeclared identifier, so I took that line of code out(camera.arc = min (max (camera.arc, 10), 120);). Now when I zoom it to its max zoom camera.arc resets automatically and scope_pan also resets to hide position.
How do I fix this?
Here is my converted or just a code that I'm working with light-C:
Code:
while (camera.arc > 10) // zoom in until camera.arc is smaller than or equal with 10
{
if (mickey.z > 1)					
{		
camera.arc += 10 * time_step; // 10 gives the zoom-in speed
}
if (mickey.z < -1)
{
camera.arc -= 10 * time_step;
}
camera.arc = min (max (camera.arc, 10), 120);
wait (1);
}
// the maximum zoom-in factor has been achieved here
camera.pan += (5 - random(10)) * 0.01 * time_step; // time to add fatigue to the mix
camera.tilt += (5 - random(10)) * 0.01 * time_step; // the pan and tilt angles of the camera will change a bit, as if the player was tired, the wind was blowing, etc
}




Honesty will get you far, were dishonesty will get you only so far in life.

Re: Zoom in/out with mikey [Re: Siwler] #397065
03/14/12 01:23
03/14/12 01:23
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
min and max were renamed to minv and and maxv. You can either stick to the original code and just replace the renamed funtions or instead use
Code:
camera.arc = clamp(camera.arc,10,120);


where it originally was
Code:
camera.arc = min (max (camera.arc, 10), 120);





Always learn from history, to be sure you make the same mistakes again...
Re: Zoom in/out with mikey [Re: Uhrwerk] #397066
03/14/12 01:38
03/14/12 01:38
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Thank you, minv and maxv fixed the error but when zoomed in to the maximum zoom, it zooms out all by it self. I don't want it to zoom out unless otherwise.

Do you know how to fix that?


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Zoom in/out with mikey [Re: Siwler] #397081
03/14/12 10:26
03/14/12 10:26
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Please try the code below, maybe this might help.

Code:
#include <default.c>

#define PRAGMA_PATH "%EXE_DIR%\samples"

FONT* A20b = "Arial#20b";

function main()
{
	level_load("small.hmp");
	vec_set(camera.x,vector(-300,0,20));

	ent_create(CUBE_MDL, vector(0,0,0), NULL);
	
	PANEL *pInfo = pan_create(NULL,0);
	
	pan_setdigits(pInfo,0,1,5,"FOV = %f", A20b, 1, camera.arc);
	pan_setcolor(pInfo,1,1,COLOR_GREEN);
	pInfo.pos_x = 5; pInfo.pos_y = 110;
	set(pInfo, OUTLINE|SHOW);
	
	def_debug();
	camera.arc = 65;
	
	while (1)
	{
		while (camera.arc > 10)
		{
			camera.arc = clamp((camera.arc += 10 * mickey.z * time_step/16), 10, 120);
			wait (1);
		}
		while (camera.arc < 11)
		{
			vec_add(camera.pan, vector((5 - random(10)) * 0.01 * time_step, (5 - random(10)) * 0.01 * time_step, 0));
			camera.arc = clamp((camera.arc += 10 * mickey.z * time_step/16), 10, 120);
			wait (1);
		}
		wait(1);
	}
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Zoom in/out with mikey [Re: rojart] #397084
03/14/12 13:04
03/14/12 13:04
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
don't use time_step when using mickey!
mickey contains the real mouse values (dx, dy, dz or mouse wheel data)
also mickey.z is 120 times larger than excepted, so a single tick on the mouse wheel will set mickey.z to 120, not to 1
better code:
Code:
function start_mouse_zoom()
{
	while(1)
	{
		// Arc from 10 to 120, mickey.z zo zoom
		// Change + to - if it's the wrong direction
		// The camera.arc will do 4° steps, so you get some faster zoom than with mickey.z / 120
		camera.arc = clamp(camera.arc - mickey.z / 30,10,120);
		wait(1);
	}
}




Visit my site: www.masterq32.de
Re: Zoom in/out with mikey [Re: rojart] #397128
03/14/12 20:46
03/14/12 20:46
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Originally Posted By: rojart
Please try the code below, maybe this might help.

Code:
#include <default.c>

#define PRAGMA_PATH "%EXE_DIR%\samples"

FONT* A20b = "Arial#20b";

function main()
{
	level_load("small.hmp");
	vec_set(camera.x,vector(-300,0,20));

	ent_create(CUBE_MDL, vector(0,0,0), NULL);
	
	PANEL *pInfo = pan_create(NULL,0);
	
	pan_setdigits(pInfo,0,1,5,"FOV = %f", A20b, 1, camera.arc);
	pan_setcolor(pInfo,1,1,COLOR_GREEN);
	pInfo.pos_x = 5; pInfo.pos_y = 110;
	set(pInfo, OUTLINE|SHOW);
	
	def_debug();
	camera.arc = 65;
	
	while (1)
	{
		while (camera.arc > 10)
		{
			camera.arc = clamp((camera.arc += 10 * mickey.z * time_step/16), 10, 120);
			wait (1);
		}
		while (camera.arc < 11)
		{
			vec_add(camera.pan, vector((5 - random(10)) * 0.01 * time_step, (5 - random(10)) * 0.01 * time_step, 0));
			camera.arc = clamp((camera.arc += 10 * mickey.z * time_step/16), 10, 120);
			wait (1);
		}
		wait(1);
	}
}



I like your code example a lot. Gamestusio should include your example code in gamestudio example folder, very nice zoom in and out example.


Honesty will get you far, were dishonesty will get you only so far in life.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1