once created the arrow objects have a speed=4 in their create events (-4 for left) and also an alarm to tell them when to destory themselves.
all the character does is create the arrow when the spacebar has been pressed (and reloading time)
is that what you mean?
Well, the "direction" defines the direction so you don't need a "-4" for that.
I should assume that you have a wall and enemy objects (very obvious).
So you can use those to destroy the arrow without needing a alarm.
You can even use the Others/ Outside Room event to remove the arrow when its outside the room.
This way it won't be a hassle to your computer memory.
By the way, the "Test Chance" code is used for the character (presuming that it is human, or human-like) because they can be tired sometimes (sore muscles and stuff) so there are times where the arrows are drawn quick and there are other times they are slow. If you want to be realistic then test chance is there, there is another way for that though...
IN YOUR CREATE EVENT:
timing = 0// "timing" makes an external alarm inside the script. For as long as the player holds the <Space> key, "timing" adds up
// until it reaches 5.
---------------------------------------------------------------------------------------
IN THE KEYBOARD/<SPACE> EVENT:
switch(weapon){
case 0:
show_message('You have no weapon selected');
break;
case 1:
if sprite_index==spr_char_right
{
if timing < 50{
timing += 1;
}
if timing == 50 {
show_debug_message('player shoots to the right.');
new_arrow = instance_create(x+4,y+16,obj_arrow_right);
new_arrow.direction = 0;
new_arrow.speed = 15;
timing = 0;
}
}
if sprite_index==spr_char_left
{
if timing < 50{
timing += 1;
}
if timing == 50 {
show_debug_message('player shoots to the left.');
new_arrow = instance_create(x+4,y+16,obj_arrow_left);
new_arrow.direction = 180;
new_arrow.speed = 15;
timing = 0;
}
}
break;
}Might be unprofessional, but it should work... Now timing can be either > 5 (for slow projectiles) and 5 for fast ones. All it takes is to fine tune the code...
*** EDIT: Fixed the code.
Edited by CRxTRDUDE, 05 July 2010 - 09:59 AM.