<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
  <spriteName>sprPlayerIdle</spriteName>
  <solid>0</solid>
  <visible>-1</visible>
  <depth>0</depth>
  <persistent>0</persistent>
  <parentName>&lt;undefined&gt;</parentName>
  <maskName>sprPlayer</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>///creacion

//iniciar variables

maxSpeed = 1;
accel = 0.25;
horSpeed = 0;
verSpeed = 0;

contadorDePasos = 0;

soundPunch = 0;
shockWave = 0;

soundPunchEnabled = true;
shockWaveEnabled = true;

cargaSoundPunch = 0;

keys = 0;

if(global.checkpointX == 0 &amp;&amp; global.checkpointY == 0)
{
    global.checkpointX = x;
    global.checkpointY = y;
}


    
if(global.checkpoint != noone)
{
    x = global.checkpointX;
    y = global.checkpointY;
    
    with(global.checkpoint)
    {
        alarm[0] = 1;
    }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="1" 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>with(instance_nearest(x,y,objMarker))
instance_destroy();
</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>soundPunchEnabled = true;
</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>///Player Step

//input

key_right = (keyboard_check(vk_right)||keyboard_check(ord("D")));   //D o Derecha dan 0 o 1
key_left = -(keyboard_check(vk_left)||keyboard_check(ord("A")));    //A o Izquierda dan 0 o -1
key_down = (keyboard_check(vk_down)||keyboard_check(ord("S")));     //S o Abajo dan 0 o 1
key_up = -(keyboard_check(vk_up)||keyboard_check(ord("W")));        //W o Arriba dan 0 o 1

mouse_right_pressed = (mouse_check_button_pressed(mb_right));
mouse_right_released = (mouse_check_button_released(mb_right));
mouse_right = (mouse_check_button(mb_right));

mouse_left_pressed = (mouse_check_button_pressed(mb_left));
mouse_left_released = (mouse_check_button_released(mb_left));
mouse_left = (mouse_check_button(mb_left));

//reaccion al input
if(!mouse_right &amp;&amp; !mouse_left)
{
    horMove = key_left + key_right;
    verMove = key_up + key_down;
}
else
{
    horMove = 0;
    verMove = 0;
}

//limitar velocidad diagonal
if(horMove != 0 &amp;&amp; verMove != 0)
{
    maxSpeed = 0.7071;
}
else maxSpeed = 1;

//dar signo a la aceleracion

if(horMove != 0) horAccel = horMove * accel;
else if(horMove == 0)
{
    if(horSpeed &gt; 0) horAccel = -accel;
    if(horSpeed &lt; 0) horAccel = accel;
    if(horSpeed == 0) horAccel = 0;
}

if(verMove != 0) verAccel = verMove * accel;
else if(verMove == 0)
{
    if(verSpeed &gt; 0) verAccel = -accel;
    if(verSpeed &lt; 0) verAccel = accel;
    if(verSpeed == 0) verAccel = 0;
}


if((abs(horSpeed) &gt; maxSpeed) &amp;&amp; (horMove != 0))
horAccel = -sign(horSpeed) * accel;

if((abs(verSpeed) &gt; maxSpeed) &amp;&amp; (verMove != 0))
verAccel = -sign(verSpeed) * accel;

//sumar aceleracion a la velocidad

horSpeed += horAccel;
verSpeed += verAccel;


/*version vieja de limitar velocidad
if(horSpeed &gt; maxSpeed) horSpeed = maxSpeed;
if(horSpeed &lt; -maxSpeed) horSpeed = -maxSpeed;

if(horSpeed &gt; maxSpeed) horSpeed = maxSpeed;
if(horSpeed &lt; -maxSpeed) horSpeed = -maxSpeed;
*/

//si se pasa la velocidad del máximo, bajarla al máximo
//antes de aplicar la velocidad al movimiento

if(abs(horSpeed) &gt; maxSpeed)&amp;&amp;(horMove != 0)     //si la velocidad se paso del maximo, y estamos manteniendo apretado
{
    if(horSpeed &gt; maxSpeed) horSpeed = maxSpeed;    //colocarla en el maximo
    if(horSpeed &lt; -maxSpeed) horSpeed = -maxSpeed;
}

if(abs(verSpeed) &gt; maxSpeed)&amp;&amp;(verMove != 0)     //si la velocidad se paso del maximo, y estamos manteniendo apretado
{
    if(verSpeed &gt; maxSpeed) verSpeed = maxSpeed;    //colocarla en el maximo
    if(verSpeed &lt; -maxSpeed) verSpeed = -maxSpeed;
}

if(abs(horSpeed) &lt; 0.5) &amp;&amp; (horMove == 0) horSpeed = 0;
if(abs(verSpeed) &lt; 0.5) &amp;&amp; (verMove == 0) verSpeed = 0;



//COLISION

if(place_meeting(x+horSpeed,y,objWall))     //si sumando a la posicion del objeto, en horizontal, la velocidad, encontramos una pared
{   
    contador = 0;                                    //entramos aca
    while((!place_meeting(x+sign(horSpeed),y,objWall))&amp;&amp;(contador &lt; maxSpeed))   //mientras sumandole uno en horizontal no encontremos una pared
    {
        x += sign(horSpeed);
        contador++;                             //lo vamos moviendo para acercarlo más y más
    }
    horSpeed = 0;                                        //ya lo acercamos lo máximo posible, esto nos traba así que la velocidad debería ser cero
}

if(place_meeting(x,y+verSpeed,objWall))     //si sumando a la posicion del objeto, en horizontal, la velocidad, encontramos una pared
{                                       //entramos aca
    contador = 0;
    while((!place_meeting(x,y+sign(verSpeed),objWall))&amp;&amp;(contador &lt; maxSpeed))   //mientras sumandole uno en horizontal no encontremos una pared
    {
        y += sign(verSpeed);                             //lo vamos moviendo para acercarlo más y más
        contador++;
    }
    verSpeed = 0;                                        //ya lo acercamos lo máximo posible, esto nos traba así que la velocidad debería ser cero
}

if(place_meeting(x+horSpeed,y+verSpeed, objWall))
{
    contador = 0;
    while((!place_meeting(x+sign(horSpeed),y+sign(verSpeed),objWall))&amp;&amp;(contador &lt; maxSpeed))
    {
        x += sign(horSpeed);
        y += sign(verSpeed);
        contador++;
    }
    horSpeed = 0;
    verSpeed = 0;
}

//MOVER

x += horSpeed;
y += verSpeed;

if(abs(horSpeed) + abs(verSpeed) &gt;= 2)
contadorDePasos += 2;
else
contadorDePasos += (abs(horSpeed) + abs(verSpeed));

if(contadorDePasos &gt;= 30)
{
    if(round(random_range(1, 2)) == 1)
    audio_play_sound(sndPlayerStep1, 10, false);
    else
    audio_play_sound(sndPlayerStep2, 10, false);
    objDarkRoom.iluminar = true;
    nuevo = instance_create(x, y, objLightSource);
    nuevo.maxRadius = 50;
    contadorDePasos -= 30;
}

//ANIMACION DE CAMINAR

if((horSpeed == 0) &amp;&amp; (verSpeed == 0))
{
    if(image_index != 3)
    sprite_index = sprPlayerIdle;
}
else
{
    sprite_index = sprPlayerWalk;
    image_speed = 0.15;
}

//APUNTAR HACIA EL MOUSE

image_angle = point_direction(x, y, mouse_x, mouse_y);

// Descolisionar si el giro lo trabo con una pared
//COMENTADO PORQUE CAUSABA TELEPORT
/*
if(place_meeting(x, y, objWall))     //si sumando a la posicion del objeto, en horizontal, la velocidad, encontramos una pared
{   
    contador = 0;                                    //entramos aca
    while(place_meeting(x ,y, objWall))   //mientras sumandole uno en horizontal no encontremos una pared
    {
        if(x &gt; objWall.x)
        {
            x--;
        }
        else if(x &lt; objWall.x)
        {
            x++;
        }
        
        if(y &gt; objWall.y)
        {
            y--;
        }
        else if(x &lt; objWall.y)
        {
            y++;
        }
    }
}
*/
if(place_meeting(x,y+verSpeed,objWall))     //si sumando a la posicion del objeto, en horizontal, la velocidad, encontramos una pared
{                                       //entramos aca
    contador = 0;
    while((!place_meeting(x,y+sign(verSpeed),objWall))&amp;&amp;(contador &lt; maxSpeed))   //mientras sumandole uno en horizontal no encontremos una pared
    {
        y += sign(verSpeed);                             //lo vamos moviendo para acercarlo más y más
        contador++;
    }
    verSpeed = 0;                                        //ya lo acercamos lo máximo posible, esto nos traba así que la velocidad debería ser cero
}

if(place_meeting(x+horSpeed,y+verSpeed, objWall))
{
    contador = 0;
    while((!place_meeting(x+sign(horSpeed),y+sign(verSpeed),objWall))&amp;&amp;(contador &lt; maxSpeed))
    {
        x += sign(horSpeed);
        y += sign(verSpeed);
        contador++;
    }
    horSpeed = 0;
    verSpeed = 0;
}
/*
// Ver personaje
awareness = instance_create(x,y,objLightSource);
awareness.maxRadius = 20;
awareness.callsEnemies = false;
*/

// Cargar poder
if ((mouse_right_pressed) &amp;&amp; (!mouse_left))
{
    audio_play_sound(sndCarga, 100, false);
    shockWave += 60;
}
if (shockWave &gt; 0)
{
    shockWave += 3; 
}
if (shockWave &gt; 300)
{
    shockWave = 300;
}



if(mouse_right_released)
{
    
    if(audio_is_playing(sndCarga))
    {
        audio_stop_sound(sndCarga)
    }
    if(audio_is_playing(sndCargaFinal))
    {
        audio_stop_sound(sndCargaFinal)
    }
    
    audio_play_sound(sndShockwave,10,false);
    
    otroNuevo = instance_create(x, y, objLightSource);
    otroNuevo.maxRadius = shockWave;
    shockWave = 0;
    
    sprite_index = sprPlayerPunch;
    image_speed = 0;
    image_index = 3;
}

if((mouse_right) &amp;&amp; !audio_is_playing(sndCarga) &amp;&amp; !audio_is_playing(sndCargaFinal))
{
    audio_play_sound(sndCargaFinal,10,false)
}

if ((mouse_left_pressed &amp;&amp; soundPunchEnabled) &amp;&amp; !mouse_right)
{
    audio_play_sound(sndCarga,10,false);
    
    alarm[0] = 90;
    instance_create(x,y,objSoundPunch);
    soundPunchEnabled = false;
    
}

//ANIMAR ATAQUES
if(shockWave &gt; 0)
{
    sprite_index = sprPlayerPunch;
    image_speed = 0;
    image_index = 1;
}
if(shockWave &gt; 150)
{
    image_index = 2;
}

if(instance_exists(objSoundPunch))
{
    if(cargaSoundPunch &lt; 100)
    cargaSoundPunch++;
}
else
{
    cargaSoundPunch = 0;
}

if(cargaSoundPunch &gt; 0)
{
    sprite_index = sprPlayerPunch;
    image_speed = 0;
    image_index = 1;
}

if(cargaSoundPunch &gt; 50)
{
    image_index = 2;
}

//VOLVER AL SPRITE IDLE


</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>/*
//dibujar texto

draw_set_colour(c_white);
draw_text(20, 20, shockWave);
draw_text(20, 40, soundPunch);
if(alarm[0] != -1)
{
    draw_text(20, 60, string_format(alarm[0]/60, 1, 2));
}

draw_text(20, 80, image_index);

//draw_text(20, 60, horSpeed);
//draw_text(20, 100, verSpeed);


*/
</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>
