Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,397 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
gun code #71686
04/20/06 22:39
04/20/06 22:39
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Hi all!

I try to write a code for my gun. And now I have a problem with my code(what else? )

If press <ctrl> for shot, not the ball moves but my gun!
Plz help me!


Code:

function fWeapon_fire() I think it s correct...
{
Weapon_fire=1;
while(key_ctrl==1 || mouse_left==1){wait(1);}
Weapon_fire=0;
}

function fShoot(shot_speed,shot_gravity)
{

while(1)
{
c_move(me,vector(0,shot_speed*time,0),vector(0,0,shot_gravity*time),ignore_models);Here is my bug....?
shot_gravity-=0.05;
wait(1);
}
}

action aPlayer
{
ePlayer=me;

my._health=100;
my._shot_damage=25;
my._shot_speed=85;
my._shot_gravity=-0.1;
my._shots_per_sec=3;

var shot_speed;
var shot_gravity;

while(1)
{
if(Weapon_fire==1)
{
ent_create(sShot, vector(my.x+65,my.y, my.z+5),fShoot(my._shot_speed,my._shot_gravity)); or is it here...?
}
sleep(1/my._shots_per_sec);
}

}




thx nipx


PS: plz dont deride my code, I'm still a newbie!

Last edited by nipx; 04/21/06 01:51.
Re: gun code [Re: nipx] #71687
04/21/06 21:16
04/21/06 21:16
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
c_move(me,vector(0,shot_speed*time,0),vector(0,0,shot_gravity*time),ignore_models);
- - - should be - - -
c_move(me,vector(my._shot_speed*time,0,0),vector(0,0,my._shot_gravity*time),ignore_models);

I'm not sure if you can assign a function to an entity, so try this...

Code:
 

action fShoot
{
my.enable_impact = on;
my.event = fShootEvent;
while(my != null)
{
c_move(me, vector(0, my._shot_speed * time, 0), vector(0, 0, my._shot_gravity * time), ignore_models);
my._shot_gravity -= 0.05;
wait(1);
}
}

function fShootEvent()
{
if (event_type == event_impact)
{
my.event = null;
wait(1);
ent_remove(me);
}
}

...
temp.x = 65;
temp.y = 0;
temp.z = 5;
vec_rotate(temp.x, my.pan);
vec_add(temp.x, my.x);
you = ent_create(sShot, temp.x, fShoot);
you._shot_speed = my._shot_speed;
you._shot_gravity = my._shot_gravity;
...





xXxGuitar511
- Programmer
Re: gun code [Re: xXxGuitar511] #71688
04/21/06 22:53
04/21/06 22:53
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
you can I would say throw the templates over board and code a gun on you own, youŽll have a hard time, but after that you will thank god for giving us this engine + scriptlanguale =)

p.s very late, I should really go to bed...

Re: gun code [Re: TWO] #71689
04/22/06 21:16
04/22/06 21:16
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Yeah!! Now it works!

Nice code!


thx, I think I'll write a credit if i use the code for my game!

nipx

Re: gun code [Re: nipx] #71690
04/23/06 05:54
04/23/06 05:54
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Glad to help... thats kool if you can put me (Josh Miller) in credits, but if not, i dont care...


xXxGuitar511
- Programmer

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