D
dcj64
Guest
Hi everyone,
I have been following the Space Rocks tutorial by FriendlyCosmonaut and have been learning a lot, however I am stuck on the power ups, the tutorial uses an older version of GM and I am having trouble implementing the power up features using scripts and the new method for passing values, I think thats what they are called?
I can get the ship to fire one bullet at a time and destroy enemy and asteroids correctly, I can also get the ship to fire three bullets at a time but only if that is set as the default, however the enemy also fire three bullets at a time.
I have tried changing the values being passed so many time with no success my head is spinning. I think my issue is I have not grasped what the initialise_bullet script is doing, it seems a script is calling another script within itself?
Tried implementing changes which were on the YouTube channel posts but that hasn't worked either, I have searched this forun as well as Reddit but can't find any other mention of this problem, is it just me?
If anyone has any ideas or can point me in the right direction I would be very greatful, many thanks.
obj_ship step event
create bullet script
The gun type is correctly being initialised and changes when the ship collects a power up but no change in gun behaviour is happening?
I think var _creator = id is part of the problem, but not sure what? I think I am not 'defining' who the creator of the bullets is?
initialise_bullet script
I have been following the Space Rocks tutorial by FriendlyCosmonaut and have been learning a lot, however I am stuck on the power ups, the tutorial uses an older version of GM and I am having trouble implementing the power up features using scripts and the new method for passing values, I think thats what they are called?
I can get the ship to fire one bullet at a time and destroy enemy and asteroids correctly, I can also get the ship to fire three bullets at a time but only if that is set as the default, however the enemy also fire three bullets at a time.
I have tried changing the values being passed so many time with no success my head is spinning. I think my issue is I have not grasped what the initialise_bullet script is doing, it seems a script is calling another script within itself?
Tried implementing changes which were on the YouTube channel posts but that hasn't worked either, I have searched this forun as well as Reddit but can't find any other mention of this problem, is it just me?
If anyone has any ideas or can point me in the right direction I would be very greatful, many thanks.
obj_ship step event
Code:
if (keyboard_check_pressed(vk_space)){ //create bullets
create_bullet(image_angle ,bulletSpd, faction, guns);
}
The gun type is correctly being initialised and changes when the ship collects a power up but no change in gun behaviour is happening?
Code:
/// @description create_bullet
function create_bullet( _dir, _spd, _fac, _gun_type){
_gun_type = -1;
if(argument_count > 3) _gun_type = argument[3];
//Choose gun type
switch(_gun_type){
case powerups.three_bullets:
var bulletID = instance_create_layer(x,y, "Instances", obj_bullet);
initialise_bullet(bulletID, _dir, _spd, _fac);
case powerups.two_bullets:
audio_play_sound(snd_zap, 1, false);
var _sep = 10;
var bulletID = instance_create_layer(x+lengthdir_x(_sep, _dir+90),y+lengthdir_y(_sep,_dir+90), "Instances", obj_bullet);
initialise_bullet(bulletID, _dir, _spd, _fac);
var bulletID = instance_create_layer(x+lengthdir_x(_sep,_dir-90),y+lengthdir_y(_sep,_dir-90), "Instances", obj_bullet);
initialise_bullet(bulletID, _dir, _spd, _fac);
break;
default:
audio_play_sound(snd_zap, 1, false);
var bulletID = instance_create_layer(x,y, "Instances", obj_bullet);
initialise_bullet( bulletID, _dir, _spd, _fac);
break;
}
}
initialise_bullet script
Code:
///@description initialize_bullet
function initialise_bullet(bulletID, _dir,_spd,_fac){
var _creator = id;
with(bulletID){
direction = _dir;
speed = _spd;
faction = _fac;
creator = _creator;
if(faction == factions.ally) image_blend = c_aqua;
else if(faction == factions.enemy) image_blend = c_red;
}
}