Page 1 of 1

shot

PostPosted: Mon Feb 27, 2012 2:19 pm
by BogdansB
Hi,
How to allow an actor just to shot after 500ms?
so when you press a key and shot you need to wait 500ms.

Re: shot

PostPosted: Mon Feb 27, 2012 3:55 pm
by MrJolteon
Code: Select all
EventDisable("Event Actor", EVENTKEYDOWN);
CreateTimer("Event Actor", "delay", 500);

Then in a Timer event, put
Code: Select all
EventEnable("Event Actor", EVENTKEYDOWN);

Re: shot

PostPosted: Mon Feb 27, 2012 5:37 pm
by BogdansB
but that means, that my player can'T move when i press right or left :?

Re: shot

PostPosted: Mon Feb 27, 2012 5:52 pm
by MrJolteon
Right... Forgot to include that
Try this then:
In the shot event, do this:
Code: Select all
if(shoot==1)
{
//shoot script here
shoot=0;
CreateTimer("Event Actor", "delay", 500);

Then, in a Timer event, put
Code: Select all
shoot=1;

Re: shot

PostPosted: Mon Feb 27, 2012 6:12 pm
by BogdansB
thanks, i want to put it in Draw Actor but there are glitches idk :?

Code: Select all
char* key = GetKeyState();

if(shot>=1 && shotwait==1 && key[KEY_PAD_4]==1 )
{

CreateActor("bullet_left", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_7]==1 )
{

CreateActor("bullet_upleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_8]==1 )
{

CreateActor("bullet_up", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_9]==1 )
{

CreateActor("bullet_upright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_6]==1 )
{

CreateActor("bullet", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_PAD_3]==1 )
{

CreateActor("bullet_downright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_2]==1 )
{

CreateActor("bullet_down", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_1]==1 )
{

CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}






CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);

meansthe bullet creates and I made when it creates it goes xvelocity=10;

Re: shot

PostPosted: Mon Feb 27, 2012 6:18 pm
by MrJolteon
BogdansB wrote:thanks, i want to put it in Draw Actor but there are glitches idk :?

Code: Select all
char* key = GetKeyState();

if(shot>=1 && shotwait==1 && key[KEY_PAD_4]==1 )
{

CreateActor("bullet_left", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_7]==1 )
{

CreateActor("bullet_upleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_8]==1 )
{

CreateActor("bullet_up", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_9]==1 )
{

CreateActor("bullet_upright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}

else if(shot>=1 && shotwait==1 && key[KEY_6]==1 )
{

CreateActor("bullet", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_PAD_3]==1 )
{

CreateActor("bullet_downright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_2]==1 )
{

CreateActor("bullet_down", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}
else if(shot>=1 && shotwait==1 && key[KEY_1]==1 )
{

CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);


}






CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);

meansthe bullet creates and I made when it creates it goes xvelocity=10;

I see... The code I posted was meant to be put in a key down event
Hey, do you have Dropbox (Or TeamViewer) btw?
Edit: Did you make the Timer event?

Re: shot

PostPosted: Mon Feb 27, 2012 6:27 pm
by BogdansB
yes.

i have another question: how can i make jus one actor, the bullet wich goes up when you press [8] or down if you press [2] and so on..