B
BannanDylan
Guest
Sorry if wrong place, incredibly new to this but have been googling for a while but can't find what I'm looking for.
Whenever I run my game I spawn enemies from the top to fall down. I have now added a menu room and when I click play it simply goes to my game room. However now the enemies don't seem to spawn and I have no idea why as it works when my first room is my game room.
Spawn Code:
Create:
alarm[0] = room_speed*0.1;
Alarm 0:
instance_create_layer(irandom_range(30,980),-50,1,o_enemy);
alarm[0] = random_range(room_speed*0.1, room_speed*0.1);
--------
Menu Code:
Create:
menu_x = x;
menu_y = y;
button_h = 32;
button[0] = "Play!";
button[1] = "Quit!";
buttons = array_length_1d(button)
menu_index = 0;
last_selected = 0;
Step:
var menu_move =0;
menu_move += (keyboard_check_pressed(vk_down) or gamepad_button_check_pressed(0,gp_padd));
menu_move -= (keyboard_check_pressed(vk_up) or gamepad_button_check_pressed(0,gp_padu));
menu_index += menu_move;
if (menu_index < 0) menu_move = buttons - 1;
if (menu_index > buttons - 1) menu_index = 0;
if (menu_index != last_selected) audio_play_sound(s_switch,1,false);
last_selected = menu_index;
if keyboard_check_pressed(vk_enter) or (gamepad_button_check_pressed(0,gp_face1))
{
switch(menu_index)
{
case 0:
room_goto(r_game);
break;
case 1:
game_end();
break;
}
}
Draw:
var i = 0;
repeat(buttons)
{
draw_set_font(f_menu);
draw_set_halign(fa_center);
draw_set_color(c_ltgray);
if (menu_index == i) draw_set_color(c_red)
draw_text(menu_x, menu_y + button_h * i, button);
i++;
}
Thanks for any possible help!
Whenever I run my game I spawn enemies from the top to fall down. I have now added a menu room and when I click play it simply goes to my game room. However now the enemies don't seem to spawn and I have no idea why as it works when my first room is my game room.
Spawn Code:
Create:
alarm[0] = room_speed*0.1;
Alarm 0:
instance_create_layer(irandom_range(30,980),-50,1,o_enemy);
alarm[0] = random_range(room_speed*0.1, room_speed*0.1);
--------
Menu Code:
Create:
menu_x = x;
menu_y = y;
button_h = 32;
button[0] = "Play!";
button[1] = "Quit!";
buttons = array_length_1d(button)
menu_index = 0;
last_selected = 0;
Step:
var menu_move =0;
menu_move += (keyboard_check_pressed(vk_down) or gamepad_button_check_pressed(0,gp_padd));
menu_move -= (keyboard_check_pressed(vk_up) or gamepad_button_check_pressed(0,gp_padu));
menu_index += menu_move;
if (menu_index < 0) menu_move = buttons - 1;
if (menu_index > buttons - 1) menu_index = 0;
if (menu_index != last_selected) audio_play_sound(s_switch,1,false);
last_selected = menu_index;
if keyboard_check_pressed(vk_enter) or (gamepad_button_check_pressed(0,gp_face1))
{
switch(menu_index)
{
case 0:
room_goto(r_game);
break;
case 1:
game_end();
break;
}
}
Draw:
var i = 0;
repeat(buttons)
{
draw_set_font(f_menu);
draw_set_halign(fa_center);
draw_set_color(c_ltgray);
if (menu_index == i) draw_set_color(c_red)
draw_text(menu_x, menu_y + button_h * i, button);
i++;
}
Thanks for any possible help!