|
0 registered members (),
1,919
guests, and 11
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
zoom to gun
#337008
08/07/10 13:51
08/07/10 13:51
|
Joined: Dec 2009
Posts: 361
rtsgamer706
OP
Senior Member
|
OP
Senior Member
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
Senior Expert
|
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:
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. 
Last edited by 3run; 08/07/10 15:13. Reason: changed zoom thing...
|
|
|
Re: zoom to gun
[Re: 3run]
#337017
08/07/10 15:52
08/07/10 15:52
|
Joined: Dec 2009
Posts: 361
rtsgamer706
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2009
Posts: 361
|
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|