NeilC
Member
Hey guys,
I'm new to GameMaker and game logic so having to take a guess on best practices without knowing what commands might solve my problem. This technically works but I'd be grateful if any of you could tell me if this is the wrong way of doing things - it would help me greatly in validating my progress.
So, I want my player to appear where I touch the screen (or in this test, click the LMB) and while I continue to hold the LMB, the player follows the cursor and fires bullets. My logic is that I'll only enable ship collision when the ship is visible.
Is this approach acceptable or should I be only creating the ship on LMB? If this alpha 'hack' is a bad practice, could anyone point out which command(s) I should be using to enable/disable the ship on LMB? I just can't find/see/figure out an alternative.
Thanks in advance!
Neil
This is in the Create event:
This is the the Step event:
I'm new to GameMaker and game logic so having to take a guess on best practices without knowing what commands might solve my problem. This technically works but I'd be grateful if any of you could tell me if this is the wrong way of doing things - it would help me greatly in validating my progress.
So, I want my player to appear where I touch the screen (or in this test, click the LMB) and while I continue to hold the LMB, the player follows the cursor and fires bullets. My logic is that I'll only enable ship collision when the ship is visible.
Is this approach acceptable or should I be only creating the ship on LMB? If this alpha 'hack' is a bad practice, could anyone point out which command(s) I should be using to enable/disable the ship on LMB? I just can't find/see/figure out an alternative.
Thanks in advance!
Neil
This is in the Create event:
Code:
fireTimer = 0
fireRate = room_speed/10
Code:
fireTimer += 1
// Draw the player at the mouse coordinate when they click the mouse
image_alpha = 0;
if (mouse_check_button(mb_left)) {
x = mouse_x;
y = mouse_y;
image_alpha = 1;
};
// Fire a bullet if the mouse button is pressed but only at a predetermined firing rate
if (mouse_check_button(mb_left)) and (fireTimer mod fireRate == 0) {
var inst = instance_create_layer(x,y, "Instances", obj_bullet);
inst.direction = 90;
audio_play_sound(snd_zap, 1, false);
};