asteroids powerup help

student

Member
I'm a novice at programming with game maker and I can't seem to workout how I can make it so you pickup a power-up in asteroid then be able to shoot 3 bullets at once with 20 degrees apart from each other

the links are to show what results I want in case my words are confusing since I'm not the best at explaining things

without power up: http://piskel-imgstore-b.appspot.com/img/48022c21-599b-11e9-95b5-69efd2d768e4.gif

with power up: http://piskel-imgstore-b.appspot.com/img/d724bfb8-599a-11e9-828a-69efd2d768e4.gif
 

woods

Member
after fiddling with it a bit.. ive found a rather clunky way of doing it.. i know there are people here that can do it more efficiently ;o) but here goes..
quick and dirty

obj_player create
Code:
/// initialize variables

speed = 0;
direction = 0;
powerup_splitshot = false
obj_player step
Code:
/// movement

image_angle += ((keyboard_check(ord("A"))-keyboard_check(ord("D")))*3);
motion_add(image_angle,keyboard_check(ord("W"))*0.1);
friction = speed/20;

/// fire

if keyboard_check_pressed(vk_space)
{
instance_create(x,y,obj_bullet)
}
if (powerup_splitshot = true) and keyboard_check_pressed(vk_space)
{
instance_create(x,y,obj_bullet2)
instance_create(x,y,obj_bullet3)
}

/// powerup splitshot
if place_meeting(x,y,obj_powerup_splitshot)
{
powerup_splitshot = true
with other
    {
    instance_destroy(obj_powerup_splitshot)
    }
}

obj_bullet create
Code:
/// initialize variables
speed = 4;
direction = obj_player.image_angle;
image_angle = obj_player.image_angle;
obj_bullet2 create
Code:
/// initialize variables
speed = 4;
direction = obj_player.image_angle-20;
image_angle = obj_player.image_angle-20;
obj_bullet3
Code:
/// initialize variables
speed = 4;
direction = obj_player.image_angle+20;
image_angle = obj_player.image_angle+20;

like i said.. its quick and dirty and prolly not efficient... but its functional... you can expand it more to your liking ;o)
 
Last edited:
M

magic1313

Guest
So, I've literally done this exact thing when I was a novice and this is how I approached it
First, I made a global variable called upgrade and set it to 0. When it collides with the upgrade thing, it destroys the upgrade thing and adds 1 to global.upgrade.
Here's the code for the different shooting:
Code for before upgrade:
Code:
if (global.upgrade == 0)
{
    if (global.loadout == 0)
    {
    bullet = instance_create(x,y,obj_Bullet01);
    bullet.direction = image_angle;
    bullet.speed = 15;
    }
}
Code after upgrade:
Code:
if (global.upgrade == 1)
{
    if (global.loadout == 0)
    {
        bullet = instance_create(x,y,obj_Bullet01);
        bullet.direction = image_angle;
        bullet.speed = 15;

        bullet = instance_create(x,y,obj_Bullet01);
        bullet.direction = image_angle + 20;
        bullet.speed = 15;

        bullet = instance_create(x,y,obj_Bullet01);
        bullet.direction = image_angle - 20;
        bullet.speed = 15;
    }
}
P.S. I'm realizing I forgot to mention, I have multiple weapons so ignore the global.loadout part
 
Last edited by a moderator:
Top