<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
  <spriteName>&lt;undefined&gt;</spriteName>
  <solid>0</solid>
  <visible>-1</visible>
  <depth>-9999</depth>
  <persistent>-1</persistent>
  <parentName>&lt;undefined&gt;</parentName>
  <maskName>&lt;undefined&gt;</maskName>
  <events>
    <event eventtype="0" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>globalvar game_speed;
game_speed = 1;

global.game_status = GAME_STATUS_MENU;
global.game_size = 3;
global.message_text = "";

randomize();

window_set_caption("IGDC 132");
window_set_size(WIN_WIDTH*global.game_size, WIN_HEIGHT*global.game_size);
display_set_gui_size(WIN_WIDTH, WIN_HEIGHT);
alarm[0] = 1; // window_center
draw_set_colour($ffffff);
draw_set_font(fnt_interface);

speed_down = false;

global.prt_system = part_system_create();
part_system_depth(global.prt_system, -200);
sc_init_part_bullet();
sc_init_part_smoke();

global.snd_emitter = audio_emitter_create();
global.msc_emitter = audio_emitter_create();

ini_open("settings.ini");
audio_emitter_gain(global.snd_emitter, clamp(ini_read_real("SOUND", "sound_gain", 0.75), 0, 1));
audio_emitter_gain(global.msc_emitter, clamp(ini_read_real("SOUND", "music_gain", 0.75), 0, 1));
ini_close();

sc_init_keys();
sc_button_init();
sc_init_char_stats();
cur_menu = MENU_MAIN;
cur_button = 0;

audio_play_sound_on(global.msc_emitter, snd_music, true, 5);
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="4">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// Deactivating

instance_deactivate_object(obj_enemy_par);
instance_activate_region(view_xview[0]-32, view_yview[0]-32, view_wview[0]+64, view_hview[0]+64, true);

alarm[4] = 5;
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="3">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>global.message_text = "";
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="2">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>global.game_status = GAME_STATUS_MENU;
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="1">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>if (speed_down) {
  if (game_speed &gt; 0.4)
    game_speed -= 0.1;
  global.slow_motion--;
  if (global.slow_motion &lt;= 0)
    speed_down = false;
  alarm[1] = 3;
}
else {
  if (game_speed &lt; 1) {
    game_speed += 0.1;
    alarm[1] = 3;
  }
}
audio_emitter_pitch(global.snd_emitter, game_speed);
audio_emitter_pitch(global.msc_emitter, game_speed);
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// Center the window
window_center();
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="3" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>if (room == room_finish) exit;
switch(global.game_status) {
  case GAME_STATUS_PLAY:
    if (instance_exists(obj_char)) {
      view_xview[0] += ((obj_char.x - view_wview[0]/2) - view_xview[0]) * 0.2;
      view_yview[0] += ((obj_char.y - view_hview[0]/2) - view_yview[0]) * 0.2;
      
      view_xview[0] = floor(clamp(view_xview[0], 0, room_width-view_wview[0]));
      view_yview[0] = floor(clamp(view_yview[0], 0, room_height-view_hview[0]));
    }
    if (keyboard_check_pressed(vk_escape)) {
      global.game_status = GAME_STATUS_MENU;
      with (all) image_speed = 0;
    }
  break;
  case GAME_STATUS_MENU:
    alarm[1]++;
    if (keyboard_check_pressed(vk_escape))
      global.game_status = GAME_STATUS_PLAY;
    
    if (keyboard_check_pressed(ord('W')) || keyboard_check_pressed(vk_up)) {
      if (cur_button &gt; 0)
        cur_button--;
    }
    else if (keyboard_check_pressed(ord('S')) || keyboard_check_pressed(vk_down)) {
      if (cur_button &lt; array_length_2d(global.button, cur_menu)-1)
        cur_button++;
    }
    if (keyboard_check(ord('A')) || keyboard_check(vk_left)) {
      switch(global.button[cur_menu, cur_button]) {
        case BUTTON_SOUND:
          var _gain = audio_emitter_get_gain(global.snd_emitter);
          audio_emitter_gain(global.snd_emitter, max(_gain-0.05, 0));
        break;
        case BUTTON_MUSIC:
          var _gain = audio_emitter_get_gain(global.msc_emitter);
          audio_emitter_gain(global.msc_emitter, max(_gain-0.05, 0));
        break;
      }
    }
    else if (keyboard_check(ord('D')) || keyboard_check(vk_right)) {
      switch(global.button[cur_menu, cur_button]) {
        case BUTTON_SOUND:
          var _gain = audio_emitter_get_gain(global.snd_emitter);
          audio_emitter_gain(global.snd_emitter, min(_gain+0.05, 1));
        break;
        case BUTTON_MUSIC:
          var _gain = audio_emitter_get_gain(global.msc_emitter);
          audio_emitter_gain(global.msc_emitter, min(_gain+0.05, 1));
        break;
      }
    }
    if (keyboard_check_pressed(global.key[KEY_JUMP]) || keyboard_check_pressed(vk_enter)) {
      switch(global.button[cur_menu, cur_button]) {
        case BUTTON_PLAY:
          global.game_status = GAME_STATUS_PLAY;
          if (room == room_menu)
            room_goto(room_level1);
        break;
        case BUTTON_SETTINGS:
          cur_button = 0;
          cur_menu = MENU_SETTINGS;
        break;
        case BUTTON_BACK:
          cur_button = 0;
          cur_menu = MENU_MAIN;
        break;
        case BUTTON_EXIT:
          game_end();
        break;
        case BUTTON_CONTROLS:
          cur_button = 0;
          cur_menu = MENU_CONTROLS;
        break;
        case BUTTON_SOUND:
          audio_play_sound_on(global.snd_emitter, snd_hurt, false, 8);
        break;
        case BUTTON_K_LEFT:
        case BUTTON_K_RIGHT:
        case BUTTON_K_UP:
        case BUTTON_K_DOWN:
        case BUTTON_K_FIRE:
        case BUTTON_K_JUMP:
        case BUTTON_K_POS:
        case BUTTON_K_TIME:
          global.game_status = GAME_STATUS_CONTROL_SET;
        break;
      }
    }
  break;
  case GAME_STATUS_CONTROL_SET:
    alarm[1]++;
    if (keyboard_check_pressed(vk_anykey)) {
      switch(global.button[cur_menu, cur_button]) {
        case BUTTON_K_LEFT:
          global.key[KEY_LEFT] = keyboard_key;
        break;
        case BUTTON_K_RIGHT:
          global.key[KEY_RIGHT] = keyboard_key;
        break;
        case BUTTON_K_UP:
          global.key[KEY_UP] = keyboard_key;
        break;
        case BUTTON_K_DOWN:
          global.key[KEY_DOWN] = keyboard_key;
        break;
        case BUTTON_K_FIRE:
          global.key[KEY_FIRE] = keyboard_key;
        break;
        case BUTTON_K_JUMP:
          global.key[KEY_JUMP] = keyboard_key;
        break;
        case BUTTON_K_POS:
          global.key[KEY_LOCK_POS] = keyboard_key;
        break;
        case BUTTON_K_TIME:
          global.key[KEY_TIME_SLOW] = keyboard_key;
        break;
      }
      sc_button_input();
      alarm[2] = 20;
    }
  break;
}
if (keyboard_check(vk_control) &amp;&amp; keyboard_check_pressed(ord('P')))
  game_restart();
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="4">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>var _view = 0;

view_enabled = true;
view_visible[_view] = true;

view_wview[_view] = WIN_WIDTH;
view_hview[_view] = WIN_HEIGHT;
view_wport[_view] = WIN_WIDTH;
view_hport[_view] = WIN_HEIGHT;

if (room == room_finish) {
  with(obj_char) instance_destroy();
  exit;
}
if (room != room_menu &amp;&amp; room != room_finish) {
  alarm[4] = 1;
  instance_create(0, 0, obj_draw_back);
  if (!instance_exists(obj_char)) {
    instance_create(0, 0, obj_char);
  }
  if (instance_exists(obj_char)) {
    global.char_start_coins = global.char_coins;
    obj_char.alarm[2] = 20;
    obj_char.state = STATE_START;
    obj_char.x = obj_startchar.x;
    obj_char.y = obj_startchar.y;
    obj_char.image_xscale = obj_startchar.image_xscale;
    with(obj_item_par) {
      for(var i = 0; i &lt; ds_list_size(global.item_list); i++) {
        var _item = ds_list_find_value(global.item_list, i);
        if (name == _item)
          instance_destroy();
      }
    }
  }
}
tile_layer_depth(100000, 1000);
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="3">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>ini_open("settings.ini");

ini_write_real("CONTROLS", "key_left", global.key[KEY_LEFT]);
ini_write_real("CONTROLS", "key_right", global.key[KEY_RIGHT]);
ini_write_real("CONTROLS", "key_up", global.key[KEY_UP]);
ini_write_real("CONTROLS", "key_down", global.key[KEY_DOWN]);
ini_write_real("CONTROLS", "key_fire", global.key[KEY_FIRE]);
ini_write_real("CONTROLS", "key_jump", global.key[KEY_JUMP]);
ini_write_real("CONTROLS", "key_lock_pos", global.key[KEY_LOCK_POS]);
ini_write_real("CONTROLS", "key_time_slow", global.key[KEY_TIME_SLOW]);

ini_write_real("SOUND", "sound_gain", audio_emitter_get_gain(global.snd_emitter));
ini_write_real("SOUND", "music_gain", audio_emitter_get_gain(global.msc_emitter));

ini_close();

part_system_destroy(global.prt_system);
for(var i = 0; i &lt; array_length_1d(global.prt); i++)
  part_type_destroy(global.prt[i]);
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="8" enumb="64">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>switch(global.game_status) {
  case GAME_STATUS_PLAY:
    
    if (room == room_finish) break;
    
    draw_sprite(spr_lifebar, 1, 0, 0);
    draw_sprite_part(spr_lifebar, 0, 0, 0, global.char_life/global.char_life_max*80, 10, 0, 0);
    draw_sprite(spr_slow_mo_bar, 1, 0, 10);
    draw_sprite_part(spr_slow_mo_bar, 0, 0, 0, global.slow_motion/global.slow_motion_max*80, 10, 0, 10);
    
    draw_set_font(fnt_small);
    if (keyboard_check(vk_tab)) {
      draw_set_halign(fa_center);
      
      draw_text(40, 0, string(global.char_life) + '/' + string(global.char_life_max));
      draw_text(40, 10, string(global.slow_motion) + '/' + string(global.slow_motion_max));
      
      draw_set_halign(fa_left);
    }
    draw_text(80, 0, "Extra: " + string(global.char_extra_life));
    draw_text(80, 10, "Coins: " + string(global.char_coins));
    draw_set_font(fnt_interface);
    
    draw_set_halign(fa_center);
    if (global.message_text != "") {
      var _width = string_width(global.message_text)/2;
      var _height = string_height(global.message_text);
      draw_set_alpha(min(alarm[3]/10, 1));
      draw_rectangle_colour(view_wview[0]/2-_width, view_hview[0]-_height, view_wview[0]/2+_width, view_hview[0], 0, 0, 0, 0, false);
      draw_text(view_wview[0]/2, view_hview[0]-_height, global.message_text);
      
      draw_set_alpha(1);
    }
    
    if (instance_exists(obj_char)) {
      if (obj_char.alarm[2] != -1) {
        draw_set_alpha(obj_char.alarm[2]/20);
        draw_rectangle_colour(0, 0, view_wview[0], view_hview[0], 0, 0, 0, 0, false);
        draw_set_alpha(1);
      }
      if (global.char_extra_life &lt;= 0) {
        draw_set_alpha(0.6);
        draw_rectangle_colour(0, 0, view_wview[0], view_hview[0], 0, 0, 0, 0, false);
        draw_set_alpha(1);
        draw_text(view_wview[0]/2, view_hview[0]/2, "Game Over");
      }
    }
    draw_set_halign(fa_left);
  
  break;
  case GAME_STATUS_MENU:
    draw_set_halign(fa_center);
    draw_set_valign(fa_center);
    
    if (room == room_menu)
      draw_set_alpha(0);
    else
      draw_set_alpha(0.6);
    draw_rectangle_colour(0, 0, view_wview[0], view_hview[0], 0, 0, 0, 0, false);
    draw_set_alpha(1);
    
    var _xx = view_wview[0]/2;
    var _yy = 40;
    var _width = string_width(global.button_text[global.button[cur_menu, cur_button]]) div 2 + 4;
    switch(global.button[cur_menu, cur_button]) {
      case BUTTON_SOUND:
        var _gain = audio_emitter_get_gain(global.snd_emitter)*_width;
        draw_rectangle_colour(_xx-_gain, _yy-8+cur_button*20, _xx+_gain, _yy+8+cur_button*20, $ff, $ff, $ff, $ff, false);
        draw_text(_xx+_width+16, _yy+cur_button*20, round(_gain/_width*100));
      break;
      case BUTTON_MUSIC:
        var _gain = audio_emitter_get_gain(global.msc_emitter)*_width;
        draw_rectangle_colour(_xx-_gain, _yy-8+cur_button*20, _xx+_gain, _yy+8+cur_button*20, $ff, $ff, $ff, $ff, false);
        draw_text(_xx+_width+16, _yy+cur_button*20, round(_gain/_width*100));
      break;
      default:
        draw_set_colour($007700);
        draw_rectangle(_xx-_width, _yy-8+cur_button*20, _xx+_width, _yy+8+cur_button*20, false);
        draw_set_colour($ffffff);
      break;
    }
    
    for(var i = 0; i &lt; array_length_2d(global.button, cur_menu); i++)
      draw_text(_xx, _yy+i*20, global.button_text[global.button[cur_menu, i]]);
    
    draw_set_halign(fa_left);
    draw_set_valign(fa_top);
  break;
  case GAME_STATUS_CONTROL_SET:
    draw_set_halign(fa_center);
    draw_set_valign(fa_center);
    
    draw_rectangle_colour(0, 0, view_wview[0], view_hview[0], 0, 0, 0, 0, false);
    draw_text(view_wview[0]/2, view_hview[0]/2, global.button_text[global.button[cur_menu, cur_button]]);
    draw_text(view_wview[0]/2, view_hview[0]/2+20, "Press any key...");
    
    draw_set_halign(fa_left);
    draw_set_valign(fa_top);
  break;
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="9" enumb="107">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>global.slow_motion += 10;
global.slow_motion_max += 10;
</string>
          </argument>
        </arguments>
      </action>
    </event>
  </events>
  <PhysicsObject>0</PhysicsObject>
  <PhysicsObjectSensor>0</PhysicsObjectSensor>
  <PhysicsObjectShape>0</PhysicsObjectShape>
  <PhysicsObjectDensity>0.5</PhysicsObjectDensity>
  <PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
  <PhysicsObjectGroup>0</PhysicsObjectGroup>
  <PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
  <PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
  <PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
  <PhysicsObjectAwake>-1</PhysicsObjectAwake>
  <PhysicsObjectKinematic>0</PhysicsObjectKinematic>
  <PhysicsShapePoints/>
</object>
