Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,655 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Zoom with mouse wheel #321926
05/03/10 15:58
05/03/10 15:58
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Ok, so I think I have a (very) basic concept of how to use mickey. Here's the function I have written so far:

function zoom()
{
while(1)
{
object1.scale_x = (mickey.z*0.1*time_step);
object2.scale_y = (mickey.z*0.1*time_step);
wait(1);
}
}

A couple of things I'm not getting:

1. How do I zoom so that the smaller versions of the object don't also stay on the screen? I'm thinking it has to do with my while/wait, but I'm not sure how to correct it.

2. Once I zoom in, do I have to write a separate function to zoom out? (essentially changing * to /)?

Re: Zoom with mouse wheel [Re: Icarni] #321930
05/03/10 17:01
05/03/10 17:01
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Add a "+", mickey sends 1 and -1, depending on the direction you scroll the mouse wheel.


function zoom()
{
while(1)
{
object1.scale_x += (mickey.z*0.1*time_step);
object2.scale_y += (mickey.z*0.1*time_step);
wait(1);
}
}

Re: Zoom with mouse wheel [Re: Pappenheimer] #321940
05/03/10 18:13
05/03/10 18:13
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Ok, that makes sense to me. However I still have a problem where when I zoom in I get multiple artifacts of the original object. How do I eliminate those?

Re: Zoom with mouse wheel [Re: Icarni] #321948
05/03/10 19:25
05/03/10 19:25
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Hm, you are aware that you are not actually zooming but scaling two objects at one of their axis?

"Zooming" in the sense of filming or photographing is when you change the camera.arc by mickey.z.

In game "zooming" often refers to moving the camera nearer or farer away:


VECTOR* temp = {x=0;y=0;z=0;}
var camera_distance = 100;

function zoom()
{
while(1)
{
vec_for_angle(temp, camera.pan);//translates an angle into a direction
vec_scale(temp, camera_distance);//sets a distance to the direction
vec_add(temp, camera.x);//places the directed distance to the cameras posisiotn
camera_distance += (mickey.z*10*time_step);
if(mouse_left){camera.pan += mouse_force.x;}
wait(1);
}
}


Last edited by Pappenheimer; 05/03/10 19:35.
Re: Zoom with mouse wheel [Re: Pappenheimer] #321952
05/03/10 19:45
05/03/10 19:45
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
I tried your Zoom function and nothing happened. It may have something to do with the fact that I'm working in 2d only at this point. My initial thought was to scale everything when I need to zoom in or out, but if there is a better way I'm all for it. There is a typo in my first post which may have led to some confustion as well. It's supposed to be 1 object on the x and y axis that I'm scaling.

Re: Zoom with mouse wheel [Re: Icarni] #321955
05/03/10 20:13
05/03/10 20:13
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Scaling all objects is a valid approach. However, keep in mind you have to transform the objects positions as well.


Always learn from history, to be sure you make the same mistakes again...
Re: Zoom with mouse wheel [Re: Icarni] #321956
05/03/10 20:14
05/03/10 20:14
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Ah, okay, my code refers to 3D, and wouldn't work without loading a level.
The artifacts of your object could relate to anything.
Is it a view entity?

Re: Zoom with mouse wheel [Re: Icarni] #321957
05/03/10 20:17
05/03/10 20:17
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
How do you display your 2d Level? With Panels or is it a fake 2d with 3d Models?

Re: Zoom with mouse wheel [Re: Widi] #321959
05/03/10 20:28
05/03/10 20:28
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
I my level is exclusively panels.

Re: Zoom with mouse wheel [Re: Icarni] #322022
05/04/10 13:47
05/04/10 13:47
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Let me start fresh on this question. I'm creating a 2d game with panels. I have a border panel for my user interface, and a series of inside panels for the game itself. For now (until i get the hang of this system), all of my panels are onscreen but in the future i want to be able to have offscreen panels as well.

I'm trying to write a function that allows me to zoom in and out on the inside panels using the mouse wheel. My first attempt allows me to make the section I'm zooming bigger, but curiously enough it doesn't matter which way I spin the wheel, the result is always larger. My second problem is that the smaller versions of the section I'm zooming don't go away, resulting in a messy and sort of blurry effect. Here's the code I'm working with so far:

function zoom()
{
while(1)
{
object1.scale_x = (mickey.z*0.1*time_step);
object1.scale_y = (mickey.z*0.1*time_step);
wait(1);
}
}

Pappenheimer suggested I add a + prior to the =, but that didn't really solve anything. Any suggestions?

Page 1 of 2 1 2

Gamestudio download | 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