Gamestudio Links
Zorro Links
Newest Posts
How to select between IB accounts by script?
by AndrewAMD. 06/13/26 15:44
Zorro tutorial ideas?
by AndrewAMD. 06/13/26 15:01
Zorro 3.01 recoded MMI function issue
by 11honza11. 06/13/26 11:40
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/12/26 08:50
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
Z9 getting Error 058
by k_ivan. 06/10/26 14:38
ZorroGPT
by TipmyPip. 06/10/26 13:07
Z12 live performance
by alx. 06/09/26 20:42
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 2,164 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
zoom to gun #337008
08/07/10 13:51
08/07/10 13:51
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
I am a programmer working with the free version of lite-c
I am making a game where you take control of a tank and can change the gun's direction using the arrow keys, and fire using space, using the code below:

action cannon()
{
var fire_percent;
var shooting = 0;
var cool = 0;
t_gun = me;
set(my,PASSABLE);
while (me)
{
cool -= 1;
if (key_cul)
{
my.pan += 1;
}

if (key_cur)
{
my.pan -= 1;
}

if (key_cuu)
{
my.tilt += 1;
}

if (key_cud)
{
my.tilt -= 1;
}
if (key_space)
{
if (cool <= 1)
{
ent_create("tank_bullet.mdl", vector (1000, 50, 7200000000000), shell); //create environment
shooting = 100;
fire_percent = 0;
cool = 75;
}
}
//////////////////////////////
if (my.tilt >= 78)
{
my.tilt = 78;
}

if (my.tilt <= -78)
{
my.tilt = -78;
}
//////////////////////////////
fire_percent += 4;
if (shooting >= 0)
{
ent_animate(my,"shoot",fire_percent, ANM_CYCLE);
shooting -= 4;
}
//////////////////////////////
vec_for_vertex(me.x, t_bod, 9);
wait(1);
}
}

The next step for me is to make it so when you press a specific key you zoom in to "cannon view"
I have tried some simple things with vec_for_vertex and camera.pan = my.pan etc...
But My problems were so convoluted I couldn't even explain them on the forum so I am asking for suggestions...
Thanks in advance
rtsgamer706

Re: zoom to gun [Re: rtsgamer706] #337010
08/07/10 14:47
08/07/10 14:47
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Your script has to many unnecessary things... here is the example that works same as yours with included zoom, but it is smaller then your example, and this way it looks more better:
Code:
action cannon()
{
	var fire_percent;
	var shooting = 0;
	var cool = 0;
	t_gun = me;
	set(my,PASSABLE);
	while (me)
	{
		cool -= 1;
		my.pan -= 1 * (key_cul - key_cur) * time_step;
		my.tilt += 1 * (key_cuu - key_cud) * time_step;
		my.tilt = clamp(my.tilt,-78,78);
		//ZOOM START // when you press CTRL
		if(key_ctrl){camera.arc -= 1 * time_step;}else{camera.arc += 1 * time_step;} // play with 1
		camera.arc = clamp(camera.arc,45,70); // play with 45 to make zoom bigger
		//ZOOM END
		if (key_space)
		{
			if (cool <= 1)
			{
				ent_create("tank_bullet.mdl", vector (1000, 50, 7200000000000), shell); //create environment
				shooting = 100;
				fire_percent = 0;
				cool = 75;
			}
		}
		//////////////////////////////
		fire_percent += 4;
		if (shooting >= 0)
		{
			ent_animate(my,"shoot",fire_percent, ANM_CYCLE);
			shooting -= 4;
		}
		//////////////////////////////
		vec_for_vertex(me.x, t_bod, 9);
		wait(1);
	}
}

If you'll need any more help, PM me. Or register on my website, I'll help you there. wink

Last edited by 3run; 08/07/10 15:13. Reason: changed zoom thing...

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: zoom to gun [Re: 3run] #337012
08/07/10 15:04
08/07/10 15:04
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Thanks for the effort but it didn't exactly have the desired effect.
When the game starts the camera is really close to the back of the tank. when I hold Ctrl the camera slowly zooms out.
I think this is because of a mi swording in my original post so I'm gonna reword it now...

I would like it so when I press a key I now see what the cannon see's.
If I use the arrow keys to aim the cannon I am aiming the camera at the same time.
When I press a different key the camera goes back to floating behind the tank so I can see it as a whole.
Sorry for the misunderstanding
rtsgamer706

Re: zoom to gun [Re: rtsgamer706] #337014
08/07/10 15:13
08/07/10 15:13
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
PM me, I'll help you laugh Waiting for your message.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: zoom to gun [Re: 3run] #337017
08/07/10 15:52
08/07/10 15:52
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
PM?

Re: zoom to gun [Re: rtsgamer706] #337018
08/07/10 15:57
08/07/10 15:57
Joined: Jul 2010
Posts: 129
B
bk9iq Offline
Member
bk9iq  Offline
Member
B

Joined: Jul 2010
Posts: 129
PM == Private Message ....


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