woods
Member
local multiplayer split screen space shooter..
i am using a handful of ship objects that the player can collide with to select that ship in the pre-game room. the players takes on the properties of one of the ships and moves to the starting area. when both players are in the starting area, we can goto room next.. and start the game.
everything is working well with one exception: rate of fire does not update to the player
a little bit of info for debugging
controller object draw event
player 1 create event
player 1 step event - select ship
code repeats from ship 0 to 7
player 1 step event -shooting
the countdown variable changes in the debug text in the top corner.. but the rate of fire stays the same..
tested with P1 and P2 using different ships with different countdown timers..
i understand there is a difference between instance variable and local variable (most likely my issue)
this is a gray area for me on how to use/change them properly
i see that i am declaring countdown at the top of the script in the shoot code.. ive tried changing that up a few different ways... with poor results.
how do i change the countdown timer to use the "countdown" from the selection ship like the rest of the variables?
i am using a handful of ship objects that the player can collide with to select that ship in the pre-game room. the players takes on the properties of one of the ships and moves to the starting area. when both players are in the starting area, we can goto room next.. and start the game.
everything is working well with one exception: rate of fire does not update to the player
a little bit of info for debugging
controller object draw event
Code:
if (room == rm_start)
{
//P1
if (view_current == 0)
{
draw_text_transformed(view_xview[0], view_yview[0], "HP " + string(obj_P1.HP),4,4,0); // draw P1 HP
draw_text_transformed(view_xview[0], view_yview[0]+64, "FIRE " + string(obj_P1.countdown),3,3,0); // draw P1 ready to fire
draw_text_transformed(view_xview[0], view_yview[0]+96, "turn " + string(obj_P1.turn_spd),3,3,0); // draw P1 turn spd
draw_text_transformed(view_xview[0], view_yview[0]+128, "thrust " + string(obj_P1.thrust),3,3,0); // draw P1 thrust
draw_text_transformed(view_xview[0], view_yview[0]+160, "max spd " + string(obj_P1.spd),3,3,0); // draw P1 max speed
}
player 1 create event
Code:
/// initialize vars
image_angle = 0;
image_index = spr_P1; // default sprit no ship
friction = 0.01 // gotta slow down in space too
can_shoot = true; // to slow down rate of fire
HP = 10;
countdown = room_speed*1; // timer for shoot
turn_spd = 1; // rotate image_angle
thrust = 0.02; // must be higher than friction to move
spd = 2; // max speed clamp
code repeats from ship 0 to 7
Code:
/// select ship
if (place_meeting(x, y, obj_ship_select_0))
{
sprite_index = spr_ship_0;
HP = obj_ship_select_0.HP;
countdown = obj_ship_select_0.countdown;
turn_spd = obj_ship_select_0.turn_spd;
thrust = obj_ship_select_0.thrust;
spd = obj_ship_select_0.spd;
image_xscale = 0.5
image_yscale = 0.5
}
if (place_meeting(x, y, obj_ship_select_1))
{
sprite_index = spr_ship_1;
HP = obj_ship_select_1.HP;
countdown = obj_ship_select_1.countdown;
turn_spd = obj_ship_select_1.turn_spd;
thrust = obj_ship_select_1.thrust;
spd = obj_ship_select_1.spd;
image_xscale = 0.5
image_yscale = 0.5
}
if (place_meeting(x, y, obj_ship_select_2))
{
sprite_index = spr_ship_2;
HP = obj_ship_select_2.HP;
countdown = obj_ship_select_2.countdown;
turn_spd = obj_ship_select_2.turn_spd;
thrust = obj_ship_select_2.thrust;
spd = obj_ship_select_2.spd;
image_xscale = 0.5
image_yscale = 0.5
}
player 1 step event -shooting
Code:
/// shoot
if (keyboard_check(vk_space) && can_shoot == true)
{
countdown = room_speed*1; // Set shot_timer to 1 second
can_shoot = false;
instance_create(x,y,obj_bullet_P1_1);
}
if (countdown > -1)
{
countdown -= 1;
}
if (countdown == 0) {
can_shoot = true;
// Reset can_use_skill back to true after shot_timer hits 0
}
the countdown variable changes in the debug text in the top corner.. but the rate of fire stays the same..
tested with P1 and P2 using different ships with different countdown timers..
i understand there is a difference between instance variable and local variable (most likely my issue)
this is a gray area for me on how to use/change them properly
i see that i am declaring countdown at the top of the script in the shoot code.. ive tried changing that up a few different ways... with poor results.
how do i change the countdown timer to use the "countdown" from the selection ship like the rest of the variables?