using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace GameName5
{
///
/// This is the main type for your game
///
///
partial class Game1 : Microsoft.Xna.Framework.Game
{
partial void menu();
partial void puerta();
partial void efecto(Texture2D bajo, Texture2D mask);
partial void efectoquitar(Texture2D mask);
public struct lem
{
public int posx;
public int posy;
public int numframes,numpelda;
public int actualframe;
public bool activo;
public bool derecha;
public int pixelscaida;
public bool walker,blocker;
public bool cae,puente,pared,pico,puentenomas;
public bool cavar;
public bool onmouse;
public bool salir,explota,explotando;
public bool muerto,rompesuelo;
public bool escalar,escalando;
public bool paraguas,cayendo,framescut;
public double tiempo;
}
//public Color[] c;
public Rectangle rect_flecha = new Rectangle(1050,90,400,200);
public int numerodentro = 0,contador=1,contador2=0,frente=0,frente2=0,a=0,desplaza=0;
public float lem_depth = 0.300f,contadortime=0,contadortime2=0;
public static int numeronecesario = 1;
public static int numerolems=1;
public int numlemnow = 0,z1=0,z2=0,z3=0,z4=0;
public int frec = 10,value,value2,value3;
public static int framesecond=6,framesecond2=3; // velocidad frames menos van todos locos 6ok
lem[] lemming = new lem[numerolems];
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
RenderTarget2D renderTarget, renderTargetquitar;
private Texture2D walker2;
private int numeromaximocaida = 210,usaparaguas=100;
private bool dibuja = true,luzmas=true,luzmas2=true,dibuja2=true;
private bool raton = false;
private bool fade = true;
private double tiempototal, tiempototalmili,milisegundos=0;
private int Frame = 0;
private int Frame2 = 0,Frame3=0;
public Texture2D background,mascaraexplosion,mascarapared,mascarapico;
public Texture2D shuttle,flechas,hazluz;
public Texture2D earth,flechassobre;
public Texture2D walker;
public Texture2D cae;
public Texture2D cavar;
public Texture2D ratonon,lucesfondo;
public Texture2D ratonoff,mas,menos,escala,paraguas,blocker,puente,pausa,explota,pared,pico,bomba,rompesuelo;
public Texture2D circulo_plata,puente_nomas;
public Texture2D circulo_oro;
public Texture2D myTexture,circulo_led;
public Texture2D puerta_ani;
public Texture2D salida_ani1, salida_ani1_1,sale,explode;
public Texture2D numfont, lemfont,backmenu1,backmenu2,backmenu3,backlogo;
public Texture2D avanzar,cuadrado_menu,logo_fondo,nubes_2,nubes,agua2,agua_ani,olas1,olas2,rainbow;
public Texture2D ScreenTexture, maskTexture;
public String sposicionMouse;
private int xscroll; // scroll pantalla fondo background
private int yscroll;
SpriteFont Font1,Font2,Font3;
int frameCounter = 0;
float _elapsed_time = 0.0f;
int _fps = 0;
Vector2 posicionMouse = new Vector2(0, 0);
MouseState estadoMouseActual,estadoMouseAnterior;
public void MoverLemming()
{
Color[] c = new Color[earth.Width * earth.Height];
earth.GetData(c);
raton = false; // scroll horizontal
if (posicionMouse.Y > 0 && posicionMouse.Y < earth.Height)
{
if (posicionMouse.X + 60 > graphics.PreferredBackBufferWidth)
{ if (xscroll + graphics.PreferredBackBufferWidth < earth.Width) { xscroll += 5; } }
if (xscroll + graphics.PreferredBackBufferWidth > earth.Width) { xscroll = earth.Width - graphics.PreferredBackBufferWidth; }
if (posicionMouse.X < 25) { if (xscroll > 0) { xscroll -= 5; } }
if (xscroll < 0) { xscroll = 0; }
}
for (int i = 0; i < numerosaca; i++)
{
if (dibuja == false)
{
// break;
}
if (puertaon) break; // arrancar solo
if (lemming[i].muerto) continue;
lemming[i].onmouse = false;
if (posicionMouse.X + 16 >= lemming[i].posx - xscroll && posicionMouse.X + 16 <= lemming[i].posx - xscroll + 28 && posicionMouse.Y + 16 >= lemming[i].posy && posicionMouse.Y + 16 <= lemming[i].posy + 28)
{
if (raton == false) { raton = true; lemming[i].onmouse = true; }
} // dentro del cuadrado
if (raton && (estadoMouseAnterior.LeftButton == ButtonState.Released && estadoMouseActual.LeftButton == ButtonState.Pressed))
{
if (op10 && lemming[i].cavar == false && numerocavan > 0 && lemming[i].onmouse == true
&& (lemming[i].walker || lemming[i].puente || lemming[i].pared || lemming[i].pico))
{
lemming[i].cavar = true; numerocavan--;
lemming[i].cae = false; lemming[i].puente = false;
lemming[i].walker = false; lemming[i].pared = false; lemming[i].pico = false;
lemming[i].actualframe = 0;
lemming[i].numframes = 16;
}
if (op3 && lemming[i].onmouse == true && numeroescalan>0 && lemming[i].escalar==false)
{
lemming[i].escalar = true; numeroescalan--;
}
if (op4 && lemming[i].onmouse == true && numeroparaguas > 0 && lemming[i].paraguas == false)
{
lemming[i].paraguas = true; numeroparaguas--;
}
if (op5 && lemming[i].onmouse == true && numeroexplotan > 0 && lemming[i].explota == false)
{
lemming[i].explota = true; numeroexplotan--;
}
if (op6 && lemming[i].onmouse == true && numeroblockers > 0 && lemming[i].blocker == false
&& (lemming[i].walker || lemming[i].cavar || lemming[i].puente || lemming[i].pared || lemming[i].pico))
{
lemming[i].blocker = true; numeroblockers--; lemming[i].puente = false; lemming[i].pared = false; lemming[i].pico = false;
lemming[i].walker = false; lemming[i].cavar = false; lemming[i].actualframe = 0;
lemming[i].numframes = 16; continue;
}
if (op7 && lemming[i].onmouse == true && numeropuentes > 0 && lemming[i].puente == false
&& (lemming[i].walker || lemming[i].cavar || lemming[i].pared || lemming[i].pico))
{
lemming[i].puente = true; lemming[i].actualframe = 0; lemming[i].walker = false; lemming[i].cavar = false;
lemming[i].pared = false; lemming[i].pico = false;
lemming[i].numframes = 16; numeropuentes--; continue;
}
if (op8 && lemming[i].onmouse == true && numeropared > 0 && lemming[i].pared == false
&& (lemming[i].walker || lemming[i].cavar || lemming[i].puente || lemming[i].pico))
{
lemming[i].pared = true; lemming[i].actualframe = 0; lemming[i].walker = false; lemming[i].cavar = false;
lemming[i].puente = false; lemming[i].pico = false;
lemming[i].numframes = 32; numeropared--; continue;
}
if (op9 && lemming[i].onmouse == true && numeropico > 0 && lemming[i].pico == false
&& (lemming[i].walker || lemming[i].cavar || lemming[i].pared || lemming[i].puente))
{
lemming[i].pico = true; lemming[i].actualframe = 0; lemming[i].walker = false; lemming[i].cavar = false;
lemming[i].pared = false; lemming[i].puente = false;
lemming[i].numframes = 24; numeropico--; continue;
}
}
if (dibuja==true && (lemming[i].puente==false || lemming[i].pared==false || lemming[i].pico==false))
{
lemming[i].actualframe++;
if (lemming[i].actualframe > lemming[i].numframes-1 && lemming[i].explotando==false) { lemming[i].actualframe = 0; }
//ojo las actualizaciones de los frames no hacerla si esta explotando
}
if (dibuja2 == true && (lemming[i].puente || lemming[i].pared || lemming[i].pico))
{
lemming[i].actualframe++;
if (lemming[i].actualframe > lemming[i].numframes - 1 && lemming[i].explotando == false) { lemming[i].actualframe = 0; }
}
if (lemming[i].salir)
{
if (lemming[i].actualframe == lemming[i].numframes-1)
{
lemming[i].muerto = true;
numlemnow--;
numerodentro++; // aqui es donde entra despues de la animacion de la puerta
}
continue;
}
int arriba = 0, abajo = 0;
/*int medx = (walker2.Width - (118 * (8 + 1))) / 2 / 4; // div por 4 porque sprite 25% 0.25f <<>> 8 son los frames del walker2
int medy = walker2.Height / 2 / 4; // OJO CON LA MEDIA SALE DEL WALKER para todos sprites posible conflicto siempre sale x14 y14 */
int medx = 14; int medy = 14;
int pixx = lemming[i].posx + medx;
int pixy = ((lemming[i].posy + medy + medy) * earth.Width);
int ancho = earth.Width;
for (int x = 0; x <= 8; x++)
{
int pos_real = lemming[i].posy+x+medy+medy; ///////////// pixel por debajo.............
if (pos_real == earth.Height ) { abajo = 9; break; }
if (pos_real < 0) pos_real = 0;
if (pos_real > earth.Height)
{
lemming[i].muerto = true; abajo = 9; lemming[i].activo = false;
numlemnow--;
break;
}
uint pixelabajo = c[(pos_real * earth.Width) + pixx].PackedValue;
if (pixelabajo == 0) { abajo++; } else { break; } //////////////// OJOJOJOJOJOJOJOJOJOJOJOJOJOJOJOOJO break;
}
// if (lemming[i].cayendo == false && lemming[i].cavar==false) { lemming[i].pixelscaida += 3; }
if (lemming[i].pixelscaida>usaparaguas && lemming[i].cayendo==false && lemming[i].paraguas && lemming[i].cavar==false)
{
lemming[i].pixelscaida = 11;
lemming[i].cayendo = true;
lemming[i].cae = false;
lemming[i].actualframe = 0;
lemming[i].numframes = 10;
}
if ((abajo>8 && lemming[i].cae==false && lemming[i].cavar==false) && lemming[i].cayendo==false && lemming[i].explotando==false)
{
lemming[i].cae = true; lemming[i].walker = false; lemming[i].actualframe = 0; lemming[i].numframes = 4;
lemming[i].pared = false; lemming[i].puente = false; lemming[i].pico = false; continue;
}
if ((abajo == 0) && (lemming[i].cae || lemming[i].cayendo) &&lemming[i].cavar==false) //OJO LOCO A VECES AL CAVAR Y SIGUE WALKER
{
if (lemming[i].pixelscaida <= numeromaximocaida)
{
lemming[i].pixelscaida = 0;
lemming[i].framescut = false;
lemming[i].cayendo = false;
lemming[i].walker = true;
lemming[i].cae = false;
lemming[i].actualframe = 0;
lemming[i].numframes = 8; //8 walker;4 cae;16 cavar;rompesuelo 16;escala ...
}
else
{
lemming[i].cae = false;
lemming[i].walker = false;
lemming[i].cayendo = false;
lemming[i].activo = false;
lemming[i].rompesuelo = true;
lemming[i].numframes = 20;
lemming[i].actualframe = 0;
continue;
}
}
if ((abajo == 0) && lemming[i].walker && lemming[i].cavar == false) { lemming[i].pixelscaida = 0; };
for (int x = 0; x <= 20; x++)
{
int pos_real = lemming[i].posy + medy + medy - x;
if (pos_real == earth.Height) // rompe los calculos si sale de la pantalla o se cuelga AARRIBBBAAAA
{
lemming[i].activo = false;
break;
}
if (pos_real < earth.Height && pos_real>0)
{
uint pixelarriba = c[(pos_real * earth.Width) + pixx].PackedValue;
if (pixelarriba != 0) { arriba++; } else break;
}
}
/* TextLem("abajo:" + String.Format("{0,4:D4}", abajo), new Vector2(10, 290), Color.Blue, 0.5f, 0.1f);
TextLem("arriba:" + String.Format("{0,4:D4}", arriba), new Vector2(10, 350), Color.Blue, 0.5f, 0.1f);
TextLem("posy:" + String.Format("{0,4:D4}", lemming[i].posy), new Vector2(10, 310), Color.Blue, 0.5f, 0.1f);
TextLem("posx:" + String.Format("{0,4:D4}", lemming[i].posx), new Vector2(10, 330), Color.Blue, 0.5f, 0.1f);
TextLem("pixelscaida:" + String.Format("{0,4:D4}", lemming[i].pixelscaida), new Vector2(10, 370), Color.Red, 0.5f, 0.1f); */
if (lemming[i].blocker)
{
if (abajo > 2) { lemming[i].blocker = false; lemming[i].cae = true;
lemming[i].actualframe = 0; lemming[i].numframes = 4; continue;}
}
if (lemming[i].pico && dibuja2 && (lemming[i].actualframe==7 || lemming[i].actualframe==8))
{
lemming[i].actualframe = 9; //ojojojojo mirar si fast falla tambien
if (lemming[i].derecha)
{
int ancho2 = 20;
int alto2 = 20;
int px = lemming[i].posx + 12;
int py = lemming[i].posy + 14;
if (px + ancho2 >= earth.Width)
{
ancho2 = earth.Width - px;
}
if (py + alto2 >= earth.Height)
{
alto2 = earth.Height - py;
}
int cantidad = ancho2 * alto2;
Color[] colorsobre2 = new Color[cantidad];
Color[] colormask2 = new Color[cantidad];
mascarapared.GetData(colormask2);
earth.GetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
for (int r = 0; r < cantidad; r++)
{
if (colorsobre2[r].PackedValue != 0) { frente2++; }
if (colormask2[r].PackedValue != 0)
{
colorsobre2[r].PackedValue = 0;
}
}
earth.SetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
earth.GetData(c); ///////// TRY TO CHANGE THIS OPTIMIZEDDDDDDDDDDDD CONFLICT WITH BUILDERS RESTORE PIXELS
lemming[i].posx += 12; lemming[i].posy++;
if (frente2 == 0)
{
lemming[i].pico = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8; continue;
}
}
else
{
int ancho2 = 20;
int alto2 = 20;
int px = lemming[i].posx - 4;
int py = lemming[i].posy + 14;
if (px + ancho2 >= earth.Width)
{
ancho2 = earth.Width - px;
}
if (py + alto2 >= earth.Height)
{
alto2 = earth.Height - py;
}
int cantidad = ancho2 * alto2;
Color[] colorsobre2 = new Color[cantidad];
Color[] colormask2 = new Color[cantidad];
mascarapared.GetData(colormask2);
earth.GetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
for (int r = 0; r < cantidad; r++)
{
if (colorsobre2[cantidad - 1 - r].PackedValue != 0) { frente2++; }
if (colormask2[cantidad - 1 - r].PackedValue != 0)
{
colorsobre2[r].PackedValue = 0;
}
}
earth.SetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
earth.GetData(c); ///////// TRY TO CHANGE THIS OPTIMIZEDDDDDDDDDDDD CONFLICT WITH BUILDERS RESTORE PIXELS
lemming[i].posx -= 12; lemming[i].posy++;
if (frente2 == 0)
{
lemming[i].pared = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8; continue;
}
}
frente2 = 0; /////// PPPPPPPPIIIIIIIIIICCCCCCCCCCCCCCCCCOOOOOOOOOOOOOOOOOOO
}
if (lemming[i].pared && (lemming[i].actualframe == 10 || lemming[i].actualframe == 26
|| lemming[i].actualframe == 11 || lemming[i].actualframe == 27) && dibuja2)
{
if (lemming[i].actualframe == 10 || lemming[i].actualframe == 11) { lemming[i].actualframe = 12; }
if (lemming[i].actualframe == 26 || lemming[i].actualframe == 27) { lemming[i].actualframe = 28; }
if (lemming[i].derecha)
{
int ancho2 = 20;
int alto2 = 20;
int px = lemming[i].posx + 14;
int py = lemming[i].posy + 8;
if (px + ancho2 >= earth.Width)
{
ancho2 = earth.Width - px;
}
if (py + alto2 >= earth.Height)
{
alto2 = earth.Height - py;
}
int cantidad = ancho2 * alto2;
Color[] colorsobre2 = new Color[cantidad];
Color[] colormask2 = new Color[cantidad];
mascarapared.GetData(colormask2);
earth.GetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
for (int r = 0; r < cantidad; r++)
{
if (colorsobre2[r].PackedValue != 0) { frente2++; }
if (colormask2[r].PackedValue != 0)
{
colorsobre2[r].PackedValue = 0;
}
}
earth.SetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
earth.GetData(c); ///////// TRY TO CHANGE THIS OPTIMIZEDDDDDDDDDDDD CONFLICT WITH BUILDERS RESTORE PIXELS
lemming[i].posx += 14;
if (frente2 == 0)
{
lemming[i].pared = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8; continue;
}
}
else
{
int ancho2 = 20;
int alto2 = 20;
int px = lemming[i].posx-6;
int py = lemming[i].posy + 8;
if (px + ancho2 >= earth.Width)
{
ancho2 = earth.Width - px;
}
if (py + alto2 >= earth.Height)
{
alto2 = earth.Height - py;
}
int cantidad = ancho2 * alto2;
Color[] colorsobre2 = new Color[cantidad];
Color[] colormask2 = new Color[cantidad];
mascarapared.GetData(colormask2);
earth.GetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
for (int r = 0; r < cantidad; r++)
{
if (colorsobre2[cantidad-1-r].PackedValue != 0) { frente2++; }
if (colormask2[cantidad-1-r].PackedValue != 0)
{
colorsobre2[r].PackedValue = 0;
}
}
earth.SetData(0, new Rectangle(px, py, ancho2, alto2), colorsobre2, 0, cantidad);
earth.GetData(c); ///////// TRY TO CHANGE THIS OPTIMIZEDDDDDDDDDDDD CONFLICT WITH BUILDERS RESTORE PIXELS
lemming[i].posx -= 14;
if (frente2 == 0)
{
lemming[i].pared = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8; continue;
}
}
frente2 = 0;
////////////////////////////////////////////////////////////////////// PPPPPPPPPAAAAAAARRRRRRRRRRRRRRRREEEEEEEDDDDDDDDD
}
if ( lemming[i].pared)
{
// Console.WriteLine(" abajo del pared: " + abajo);
if (abajo > 0) { lemming[i].pared = false;lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8;
continue;
}
}
if (lemming[i].puente && dibuja2) // calculo del puente
{
for (int b = 0; b < numerosaca; b++) // bloqueo que afecte a los puentes
{
if (lemming[b].blocker == false || b == i) { continue; }
else
{
Rectangle bloqueo = new Rectangle(lemming[b].posx, lemming[b].posy, 28, 28); // todo el cuadrado entero 28x28
Point poslem = new Point(lemming[i].posx + medx, lemming[i].posy + medy); //OJOJOJOJO A VER CON PUENTE COMO VA ESTO MIRA CENTRO PA WALKER
if (bloqueo.Contains(poslem))
{
if (lemming[i].derecha)
{
lemming[i].derecha = false; lemming[i].posx -= 6; break; //ojo resta 4 porque si van muy juntos se vuelvevn locos
}
else
{
lemming[i].derecha = true; lemming[i].posx += 6; break;
}
}
}
}
if (lemming[i].actualframe >= 14 && lemming[i].numpelda<12) // frame 14 o 15 >=14
{
frente = 0;lemming[i].actualframe = 15;
if (lemming[i].derecha)
{
for (int y = 1; y <= 3; y++) // 14 es la posicion de los pies del lemming[i].posy porque tiene 28 pixels de alto 28/2=14
{
int posi_real = (lemming[i].posy + 24 + y) * earth.Width + lemming[i].posx;
for (int z = 14; z <= 28; z++)
{
if (c[posi_real + z].PackedValue == 0) { c[posi_real + z] = new Color(255, 0, 255, 255); } else
{
if (z==19) frente++;
continue;
}
}
}
lemming[i].numpelda++;
lemming[i].posy -= 3;
lemming[i].posx += 6;
earth.SetData(c);
if (frente == 3)
{
lemming[i].puente = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8;
lemming[i].numpelda = 0; lemming[i].posx -= 7;lemming[i].derecha = false;
continue;
}
continue;
} else
{
for (int y = 1; y <= 3; y++) // 14 es la posicion de los pies del lemming[i].posy porque tiene 28 pixels de alto 28/2=14
{
int posi_real = (lemming[i].posy + 24 + y) * earth.Width + lemming[i].posx;
for (int z = 0; z <= 14; z++)
{
if (c[posi_real + z].PackedValue == 0) { c[posi_real + z] = new Color(255, 0, 255, 255); }
else
{
if (z == 9) frente++;
continue;
}
}
}
lemming[i].numpelda++;
lemming[i].posy -= 3;
lemming[i].posx -= 6;
earth.SetData(c);
if (frente == 3)
{
lemming[i].puente = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8;
lemming[i].numpelda = 0; lemming[i].posx += 8;lemming[i].derecha=true; continue;
}
continue;
}
}
if (lemming[i].numpelda>=12)
{
if (lemming[i].puentenomas==false)
{
lemming[i].puente = false; lemming[i].puentenomas = true;
if (lemming[i].derecha) { lemming[i].posx -= 6; } else { lemming[i].posx += 6; }
lemming[i].actualframe = 0; lemming[i].numframes = 8;
}
}
}
if (lemming[i].puentenomas)
{
if (lemming[i].actualframe == 7 && lemming[i].puentenomas)
{
lemming[i].puentenomas = false; lemming[i].walker = true; lemming[i].actualframe = 0; lemming[i].numframes = 8;
lemming[i].numpelda = 0; continue;
}
}
if (lemming[i].cavar) ///// cavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
{
if (abajo == 0 || abajo==1 ) // 5 ok que no se aceleren a cavar si hay mas de 2 juntos antes era <9 los pixeles debajo de sus pies
{
int abajo2 = 0;
int pixx2 = lemming[i].posx + 14;
int pixy2 = ((lemming[i].posy + 28) * earth.Width);
for (int x = 0; x <= 4; x++)
{
int pos_real2 = lemming[i].posy + x + 28; ///////////// pixel por debajo.............
if (pos_real2 == earth.Height) { abajo2 = 9; break; }
if (pos_real2 < 0) pos_real2 = 0;
if (pos_real2 > earth.Height)
{ pos_real2 = earth.Height; }
uint pixelabajo2 = c[(pos_real2 * earth.Width) + pixx2].PackedValue;
if (pixelabajo2 != 0) { abajo2++; } else { break; } //////////////// OJOJOJOJOJOJOJOJOJOJOJOJOJOJOJOOJO break;
}
// TextLem("Abajo2:" + String.Format("{0,4:D4}", abajo2), new Vector2(10, 420), Color.Blue, 0.5f, 0.00000001f);
if ((lemming[i].actualframe == 15 || lemming[i].actualframe==7) && dibuja)
{
for (int y=9;y<=18;y++) // 14 es la posicion de los pies del lemming[i].posy porque tiene 28 pixels de alto 28/2=14
{
int posi_real = (lemming[i].posy + 14 + y) * earth.Width + lemming[i].posx;
if (lemming[i].posy + 14 + y >= earth.Height) { break; } // cortar si esta en el limite por debajo 512=earth.height
for (int z = 4; z <= 24; z++)
{
c[posi_real + z] = new Color(0, 0, 0, 0);
}
}
earth.SetData(c);
lemming[i].posy += abajo2;continue;
}
}
else
{
lemming[i].pared = false; lemming[i].puente = false; lemming[i].pico = false;
lemming[i].cavar = false; lemming[i].cae = true; lemming[i].walker = false;
lemming[i].actualframe = 0; lemming[i].numframes = 4;
continue; //break o continue nose
}
}
if (lemming[i].escalando)
{
if (lemming[i].derecha)
{
int pos_real2 = lemming[i].posy + 27;
uint pixelarriba2 = c[(pos_real2 * earth.Width) + pixx - 2].PackedValue;
if (pixelarriba2 > 0)
{
lemming[i].derecha = false; lemming[i].posx -= 2; // 1 o 2 mirar
lemming[i].escalando = false; lemming[i].walker = true;
lemming[i].numframes = 8; lemming[i].actualframe = 0; continue;
}
}
else
{
int pos_real2 = lemming[i].posy + 27;
uint pixelarriba2 = c[(pos_real2 * earth.Width) + pixx +2].PackedValue;
if (pixelarriba2 > 0)
{
lemming[i].derecha = true; lemming[i].posx += 2; // 1 o 2 mirar
lemming[i].escalando = false; lemming[i].walker = true;
lemming[i].numframes = 8; lemming[i].actualframe = 0; continue;
}
}
if (arriba>0)
{
//if (lemming[i].actualframe == 1) { lemming[i].posy--; } // sube mas despacio segun el frame elegido mejor o peor
if (dibuja) lemming[i].posy--;
}
if (arriba==0)
{
if (lemming[i].derecha) { lemming[i].posx++; } else { lemming[i].posx--; }
lemming[i].escalando = false; lemming[i].walker = true;
lemming[i].numframes = 8; lemming[i].actualframe = 0; continue;
}
}
if (lemming[i].walker)
{
if (abajo < 3 && lemming[i].derecha) { lemming[i].posx++; if (arriba < 16) { lemming[i].posy -= arriba; } } //// <6 o <8 falla cava
if (abajo < 3 && lemming[i].derecha == false) { lemming[i].posx--; if (arriba < 16) { lemming[i].posy -= arriba; } }
if (arriba>=16)
{
if (lemming[i].escalar == false)
{
if (lemming[i].derecha && arriba >= 16)
{
lemming[i].derecha = false; lemming[i].posx -= 2; // 1 o 2 mirar
}
else
{
lemming[i].derecha = true; lemming[i].posx += 2; // 1 o 2 mirar
}
}
else
{
lemming[i].walker = false;
lemming[i].escalando = true;
lemming[i].numframes = 8;
lemming[i].pixelscaida = 0;
lemming[i].actualframe = 0;
continue;
}
}
}
// bucle de blocker pa comprobar BBBBBBBBBBBBBLLLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOOOCCCCCCCCCCCCCCCCCKKKKKKKKKKKKKKKKKKEEEEEEEEEEEERRRRRRR
for (int b = 0; b < numerosaca; b++)
{
if (lemming[b].blocker == false || b==i) { continue; }
else
{
Rectangle bloqueo = new Rectangle(lemming[b].posx+13,lemming[b].posy+2,3,26);
Point poslem = new Point(lemming[i].posx+medx, lemming[i].posy+medy); //OJOJOJOJO A VER CON PUENTE COMO VA ESTO MIRA CENTRO PA WALKER
if (bloqueo.Contains(poslem))
{
if (lemming[i].derecha)
{
lemming[i].derecha = false; lemming[i].posx -= 2; break; //ojo resta 4 porque si van muy juntos se vuelvevn locos
}
else
{
lemming[i].derecha = true; lemming[i].posx += 2; break;
}
}
}
}
if (lemming[i].cayendo == false)
{
if (abajo >= 3) { lemming[i].posy += 3; lemming[i].pixelscaida += 3; }
else { lemming[i].posy += abajo; lemming[i].pixelscaida += abajo; } // cae 3 como maximo
}
else
{
if (dibuja) { if (abajo >= 3) { lemming[i].posy += 3; } else { lemming[i].posy += abajo; } }
}
}
}
public Game1()
{
graphics = new GraphicsDeviceManager(this)
{
PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8,
PreferredBackBufferWidth=1100,
PreferredBackBufferHeight=700
};
//// this.IsMouseVisible = true; apaga raton total
Content.RootDirectory = "Content";
Window.Title = "Lemmings c#";
Window.AllowUserResizing = false;
//graphics.ApplyChanges();
}
///
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
///
///
protected void ActualizarMouse()
{
estadoMouseAnterior = estadoMouseActual;
estadoMouseActual = Mouse.GetState();
int valorx = estadoMouseActual.X;
valorx += xscroll;
posicionMouse = new Vector2(estadoMouseActual.X, estadoMouseActual.Y);
sposicionMouse = valorx.ToString() + " " +estadoMouseActual.Y.ToString();
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
//this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 20.0f);// cambia si quieres camara lenta
//graphics.SynchronizeWithVerticalRetrace = false;
renderTarget = new RenderTarget2D(GraphicsDevice, 1700, 700, false, GraphicsDevice.PresentationParameters.BackBufferFormat,
DepthFormat.Depth24Stencil8);
//renderTargetquitar = new RenderTarget2D(GraphicsDevice, 2000, 512, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24Stencil8);
//Window.IsBorderless = true;
base.Initialize(); //OJOJOJOJOJOJOJ DEPTH FORMAT SUPER IMPORTANTE
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
background = Content.Load("stars");
shuttle = Content.Load("LemmingTexture"); // if you are using your own images.
earth = Content.Load("levels/fun/fun018");
//renderTargetquitar = new RenderTarget2D(GraphicsDevice, earth.Width, earth.Height, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24Stencil8);
walker = Content.Load("walker");
walker2 = Content.Load("walker_ok");
ratonon = Content.Load("raton_on1");
ratonoff = Content.Load("raton_off1");
cae = Content.Load("cae_ok");
cavar = Content.Load("cavar_ok");
circulo_plata = Content.Load("circle_plata");circulo_oro = Content.Load("circle_oro");circulo_led = Content.Load("circulo_brillante");
puerta_ani = Content.Load("puerta1");salida_ani1 = Content.Load("salida1");salida_ani1_1 = Content.Load("salida1_1");
sale = Content.Load("sale");
numfont = Content.Load("nummfont");lemfont = Content.Load("lemmfont");
backmenu1 = Content.Load("background_01"); backmenu2 = Content.Load("background_012");
backmenu3 = Content.Load("background_02"); backlogo = Content.Load("lemlogo_01");
avanzar = Content.Load("avanzar"); cuadrado_menu = Content.Load("border");
logo_fondo = Content.Load("logo"); nubes_2 = Content.Load("fondos/nubes2"); nubes = Content.Load("fondos/nubes");
agua2 = Content.Load("Animations/water2"); agua_ani = Content.Load("fondos/agua_ok");
olas1 = Content.Load("fondos/olas_ok"); olas2 = Content.Load("fondos/olas_ok2");
lucesfondo = Content.Load("fondos/luces de fondo guays");
rainbow = Content.Load("surge-rainbow"); mas = Content.Load("mas"); menos = Content.Load("menos");
paraguas = Content.Load("paraguas"); escala = Content.Load("escala");
explota = Content.Load("explota"); blocker = Content.Load("blocker");
puente = Content.Load("puente"); pared = Content.Load("pared");
rompesuelo = Content.Load("rompesuelo"); explode = Content.Load("explode");
mascaraexplosion = Content.Load("mascara_explode"); puente_nomas = Content.Load("puente_nomas");
mascarapared = Content.Load("mascara_pared"); mascarapico = Content.Load("mascara_pico");
pico = Content.Load("pico"); pausa = Content.Load("pausa"); bomba = Content.Load("bomba");
ScreenTexture = Content.Load("fondos/olas_ok"); flechas = Content.Load("fondos/arrow1");
maskTexture = Content.Load("fondos/ice outttt"); //mascara para las pruebas de las olas
hazluz = Content.Load("smoke/haz_luz");
Font1 = Content.Load("SpriteFont1");
Font2 = Content.Load("Arial");
Font3 = Content.Load("Font");
xscroll = 200; // inicio de la pantalla
yscroll = earth.Height;
flechassobre = new Texture2D(GraphicsDevice, rect_flecha.Width, rect_flecha.Height);
/*c = new Color[earth.Width * earth.Height];
earth.GetData(c);*/
}
///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
//this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 120.0f); // Speed 120 frames second 2X-----240 = 4X
//graphics.SynchronizeWithVerticalRetrace = false;
tiempototalmili += gameTime.ElapsedGameTime.TotalMilliseconds;
milisegundos += gameTime.ElapsedGameTime.Milliseconds;
_elapsed_time += (float)gameTime.ElapsedGameTime.TotalSeconds;
frameCounter++;
if (_elapsed_time > 1)
{
_fps = frameCounter;
frameCounter = 0;
_elapsed_time = 0;
}
Frame2++; Frame3++; dibuja = false; dibuja2 = false;
if (Frame2 > framesecond) { Frame2 = 0; Frame++; dibuja = true; }
if (Frame3 > framesecond2) { Frame3 = 0; dibuja2 = true; }
ActualizarMouse();
MoverLemming();
contadortime++; contadortime2++;
tiempototal = contadortime / 59;
int maxluz = 14; // numero de ciclos de variar el rectangle del EFECTO DE LUCES 50 normalmente
int maxluz2 = 200;
if (luzmas2)
{contador2++; if (contador2 >= maxluz2) { contador2 = maxluz2 - 2; luzmas2 = false; }}
else { contador2--; if (contador2 <= 0) { contador2 = 2; luzmas2 = true; } }
if ((contadortime2 / 4) % 2 == 0) //velocidad del refresco efecto de luces
{
if (luzmas){contador++; if (contador >= maxluz) { contador = maxluz - 2; luzmas = false; }
}else{contador--; if (contador <= 0) { contador = 2; luzmas = true; }}
/*Random rand = new Random();
byte[] values = new byte[3];
rand.NextBytes(values);
value = values[0];
value2 = values[1];
value3 = values[2];*/
//contador = value3 % 12 +1;
}// abajo calculos nubes nubes2 y waterfall
z1 = (int)contadortime2 / 3;
z2 = (int)contadortime2 / 10;
z3 = (int)contadortime2 / 9;
z4 = (int)contadortime2 / 12; z4 = z4 % 8;
z3 = z3 % 4; // mumero de frames del agua a ver 4 de 5 que tiene la ultima esta vacia nose porque
puerta();
//myTexture = Content.Load("particles//Magic Trails Sparkle//magictrailssparkle_" + a);
myTexture = Content.Load("luces/" + contador);// okokokokokokokok
//myTexture = Content.Load("particles//Star Trail 2//startrail2_" + a);
if (dibuja2)
{
int cantidad22 = rect_flecha.Width * rect_flecha.Height;
Color[] colorsobre22 = new Color[cantidad22];
Color[] colormask22 = new Color[flechas.Width * flechas.Height];
Color[] colormasktotal = new Color[cantidad22];
flechas.GetData(colormask22);
earth.GetData(0, rect_flecha, colorsobre22, 0, cantidad22);
desplaza--;
if (desplaza < 0) { desplaza = flechas.Width-1; } // fuera si es a la izquierda y desplaza++ linea arriba
for (int y4 = 0; y4 < rect_flecha.Height; y4++)
{
for (int x4 = 0; x4 < rect_flecha.Width; x4++)
{
int posy456 = y4 % flechas.Height;
//int posx456 = ((x4 / (flechas.Width)) + (x4 % flechas.Width)+1);
int posx456 = x4 % flechas.Width;
posx456 = ((posx456 + desplaza) % flechas.Width);
//posx456 = ((posx456 + desplaza) % flechas.Width); inquierda okok
//posx456 = (flechas.Width-1)-((posx456 + desplaza) % flechas.Width); // izquierda perfecto
//Console.WriteLine(" x relativa: " + posx456);
colormasktotal[(y4 * rect_flecha.Width) + x4].PackedValue = colormask22[(posy456 * flechas.Width) + posx456].PackedValue;
}
}
for (int r = 0; r < cantidad22; r++)
{
if (colorsobre22[r].PackedValue != 0)
{
colorsobre22[r].PackedValue = colormasktotal[r].PackedValue;
}
}
flechassobre.SetData(colorsobre22);
}
base.Update(gameTime);
}
///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.AnisotropicWrap, null, null);
GraphicsDevice.Clear(Color.Black); // color del fondo darkslategray,cornblue,dimgray,black,gray,lighslategray
// TODO: Add your drawing code here
// spriteBatch.Begin();
if (debug) efectoquitar(maskTexture);
if (debug) spriteBatch.Draw(renderTargetquitar, new Vector2(0, 0),null,Color.White, 0f, Vector2.Zero, 0.4f, SpriteEffects.None, 0.500f);
if (debug)
{
spriteBatch.End();
int ani_x = 400; int ani_y = 200; // TAMAÑO DE LA TEXTURA PRIMERA DE EFECTO
efecto(olas1, maskTexture);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.AnisotropicWrap, null, null);
spriteBatch.Draw(renderTarget, new Rectangle(190, 200, ani_x, ani_y), new Rectangle(0, 0, ani_x, ani_y),
new Color(255, 255, 255, 220), 0f, Vector2.Zero, SpriteEffects.None, 0.101f);
}
spriteBatch.Draw(logo_fondo, new Rectangle(0 , 0, 1100, 512), new Rectangle(0 + xscroll / 7, 0, 1100, 512), new Color(150, 150, 150, 160),0f,
Vector2.Zero, SpriteEffects.None, 0.806f);
// LUCES DE FONDO EFECTO
//spriteBatch.End();
//spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive, SamplerState.LinearClamp, null, null);
//spriteBatch.Draw(lucesfondo, new Rectangle(0, 0, graphics.PreferredBackBufferWidth+100, graphics.PreferredBackBufferHeight),
// new Rectangle(contador, 0, lucesfondo.Width, lucesfondo.Height), new Color(255, 255, 255, 120), // new Color(200, 50, 255, 70)
// 0f, Vector2.Zero, SpriteEffects.None, 0.805f);
//spriteBatch.Draw(myTexture, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight),
// new Rectangle(myTexture.Width / 2, myTexture.Height/2, myTexture.Width, myTexture.Height), new Color(230, 70, 255, 80), // new Color(200, 50, 255, 70)
// 0.4f+(contador*0.02f), Vector2.Zero, SpriteEffects.FlipHorizontally, 0.805f); //0.805f
spriteBatch.Draw(myTexture, new Vector2(1100 / 2, 512 / 2), new Rectangle(0, 0, myTexture.Width, myTexture.Height), new Color(255, 255, 255, 10+contador*2),
0.4f+contador2*0.001f,new Vector2(myTexture.Width / 2, myTexture.Height / 2), 3f, SpriteEffects.FlipHorizontally, 0.805f); // okokok
//spriteBatch.Draw(flechas, new Vector2(100,100), new Rectangle(0, 0, flechas.Width,flechas.Height), new Color(255, 255, 255,255),
// 0f, new Vector2(flechas.Width / 2, flechas.Height / 2), 1f, SpriteEffects.None, 0.01f);
//spriteBatch.End();
//spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.AnisotropicWrap, null, null);
Console.Title="LEMMINGS OutPUT";
Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
Console.WriteLine(" Contador: "+String.Format("{0,2:D2}", contador));
Console.WriteLine(" Frame: " + Frame); Console.WriteLine(" Frame2: " + Frame2);
Console.WriteLine(" Z1: " + z1); Console.WriteLine(" Time: " + gameTime.TotalGameTime);
Console.WriteLine(" Z2: " + z2); Console.WriteLine(" elapsed: " + gameTime.ElapsedGameTime);
Console.WriteLine(" slowly: " + gameTime.IsRunningSlowly); Console.WriteLine(" milisegundos: " + milisegundos);
Console.WriteLine(" Z3: " + z3); Console.WriteLine(" Z4: " + z4); Console.WriteLine(" contadortime: " + contadortime);
Console.WriteLine(" timeTOTAL: " + tiempototal); Console.WriteLine(" contadortime: " + contadortime/59);
Console.WriteLine(" contadortime2: " + contadortime2); Console.WriteLine(" frente: " + frente);
Console.WriteLine(" frente: " + lemming[0].numpelda); Console.WriteLine(" CONTADOR: " + contador);
Console.WriteLine(" VALUE: " + value); Console.WriteLine(" CONTADOR2: " + contador2);
Console.WriteLine(" xscroll: " + xscroll); Console.WriteLine(" caidos" + lemming[0].pixelscaida);
spriteBatch.Draw(nubes_2, new Rectangle(0, 50, 1100, nubes_2.Height), new Rectangle(z1, 0, 1100, nubes_2.Height), new Color(255, 255, 255, 110), 0f,
Vector2.Zero,SpriteEffects.None, 0.804f);
spriteBatch.Draw(nubes, new Rectangle(0, 220, 1100, nubes.Height), new Rectangle(z2,0,1100, nubes.Height),new Color(255, 255, 255, 110), 0f,
Vector2.Zero,SpriteEffects.None, 0.803f);
spriteBatch.Draw(agua2, new Rectangle(1560 - xscroll, -80, 260, 750), new Rectangle(0 + z3 * 192, 0, 192, 192), new Color(230, 50, 255, 160),0f,
Vector2.Zero,SpriteEffects.None, 0.802f); //0.802f
spriteBatch.Draw(earth, new Vector2(0,0),new Rectangle(xscroll, 0, graphics.PreferredBackBufferWidth, yscroll),
Color.White,0f,Vector2.Zero,1f,SpriteEffects.None,0.500f);
spriteBatch.Draw(flechassobre, new Vector2(rect_flecha.X - xscroll, rect_flecha.Y), new Rectangle(0, 0,flechassobre.Width,flechassobre.Height),
new Color(255,255,255,170), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.499f);
/*spriteBatch.Draw(hazluz, new Rectangle(100, 10, hazluz.Width, hazluz.Height), new Rectangle(0, 0, hazluz.Width, hazluz.Height),
new Color(255, 255, 255, 255), 0f, Vector2.Zero,SpriteEffects.None, 0.798f);
spriteBatch.Draw(hazluz, new Vector2(300, 10), new Rectangle(0, 0, hazluz.Width, hazluz.Height),
new Color(255, 255, 255, 255-contador*15), 1.1f, Vector2.Zero, 2, SpriteEffects.None, 0.799f);
spriteBatch.Draw(hazluz, new Vector2(700, 10), new Rectangle(0, 0, hazluz.Width, hazluz.Height),
new Color(145, 200, 255, 150 - contador * 4), 1.1f, Vector2.Zero, 2 - 0.07f * contador, SpriteEffects.None, 0.801f);*/
if (debug)
{
spriteBatch.Draw(agua_ani, new Rectangle(100, 330, 800, 40), new Rectangle(0, z4 * 134, 543, 134),
new Color(255, 255, 255, 170), 0f, Vector2.Zero, SpriteEffects.None, 0.01f); // animated water
spriteBatch.Draw(olas1, new Rectangle(40, 50, 128, 32), new Rectangle(0, z4 * 32, 128, 32),
new Color(255, 255, 255, 200), 0f, Vector2.Zero, SpriteEffects.None, 0.02f); // animated waves water 128x32
spriteBatch.Draw(olas1, new Rectangle(170, 50, 128, 32), new Rectangle(0, z4 * 32, 128, 32),
new Color(255, 255, 255, 134), 0f, Vector2.Zero, SpriteEffects.None, 0.02f); // animated waves water 128x32
spriteBatch.Draw(olas2, new Rectangle(170, 50, 128, 32), new Rectangle(0, z4 * 32, 128, 32),
new Color(255, 255, 255, 200), 0f, Vector2.Zero, SpriteEffects.None, 0.03f); // animated waves water 128x32 uno encima del otro mejora
spriteBatch.Draw(olas2, new Rectangle(300, 50, 128, 32), new Rectangle(0, z4 * 32, 128, 32),
new Color(255, 255, 255, 200), 0f, Vector2.Zero, SpriteEffects.None, 0.03f); // animated waves water 128x32 uno encima del otro mejora
TextLem("z3:" + String.Format("{0,2:D2}", z3), new Vector2(10, 270), Color.Red, 0.5f, 0.1f);
}
menu();
//puerta(); // aqui dibuja la salida el calculo lo paso a update
int framereal565 = (framepuerta * 50);
spriteBatch.Draw(puerta_ani, new Vector2(puerta1x - xscroll, puerta1y), new Rectangle(0, framereal565, 96, 50),
Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.403f);// resize con vector + rectangle (( creo mejor asi por lo del scale ))
int frameact = (framesalida * 16);
spriteBatch.Draw(salida_ani1_1, new Vector2(salida1x - xscroll, salida1y), new Rectangle(0, frameact, 96, 16), Color.White,
0f, Vector2.Zero, 1f, SpriteEffects.None, 0.400f);
spriteBatch.Draw(salida_ani1, new Vector2(salida1x - xscroll, salida1y + 16), new Rectangle(0, 0, 96, 34), Color.White,
0f, Vector2.Zero, 1f, SpriteEffects.None, 0.401f);
// infos varios
spriteBatch.DrawString(Font1, string.Format("FPS={0}", _fps), new Vector2(960, 50), Color.White,0f,new Vector2(0,0),1f,SpriteEffects.None,0.1f);
spriteBatch.DrawString(Font1, sposicionMouse, new Vector2(940, 10), Color.White,0f,Vector2.Zero,1f,SpriteEffects.None,0.1f);
Vector2 posicionRectangulo = new Vector2(lemming[0].posx+60, 60);
for (int i = 0; i < numerosaca; i++) //si lo hace de 100 a cero dibujara los primeros encima y mejorara el aspecto
{
/* TextLem("Frame:" + String.Format("{0,2:D2}", lemming[i].actualframe), new Vector2(10, 270), Color.Red, 0.5f, 0.1f);
if (lemming[i].actualframe==10) { TextLem("10", new Vector2(lemming[i].posx-xscroll, lemming[i].posy), Color.Red, 0.5f, 0.1f);}
if (lemming[i].actualframe==26) { TextLem("26", new Vector2(lemming[i].posx-xscroll, lemming[i].posy), Color.Red, 0.5f, 0.1f);}*/
if (puertaon) break;
if (lemming[i].muerto) continue;
if (lemming[i].explota && lemming[i].explotando==false)
{
if (lemming[i].tiempo==0) lemming[i].tiempo = tiempototal;
double timez = tiempototal - lemming[i].tiempo;
int crono = (int)(6f - (float)timez);
Console.WriteLine(" crono: " + crono);
TextLem(String.Format("{0}", crono), new Vector2(lemming[i].posx + 3 - xscroll, lemming[i].posy - 10), Color.White, 0.4f, 0.000000000004f);
if (crono<=0)
{
lemming[i].explotando = true;
lemming[i].activo = false;
lemming[i].paraguas = false;
lemming[i].walker = false;
lemming[i].cavar = false;
lemming[i].escalar = false;
lemming[i].cae = false;
lemming[i].cayendo = false;
lemming[i].escalando = false;
lemming[i].salir = false;
lemming[i].blocker = false;
lemming[i].puente = false;
lemming[i].puentenomas = false;
lemming[i].pared = false;
lemming[i].pico = false;
lemming[i].actualframe = 0;
lemming[i].numframes = 16;
}
}
int framereal55 = (lemming[i].actualframe * 118);
if (lemming[i].walker)
{
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(walker2, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.Red, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth+(i*0.00001f)); }
else { spriteBatch.Draw(walker2, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(walker2, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.Red, 0f, Vector2.Zero, 0.25f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(walker2, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].blocker)
{
int framesale = (lemming[i].actualframe * 20);
if (lemming[i].onmouse) { spriteBatch.Draw(blocker, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(blocker, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
if (debug){
Rectangle bloqueo = new Rectangle(lemming[i].posx + 12, lemming[i].posy + 2, 4, 26);
q = new Texture2D(GraphicsDevice, 1, 1);
q.SetData(new Color[] { Color.White });
spriteBatch.Draw(q, new Rectangle(bloqueo.Left - xscroll, bloqueo.Top, bloqueo.Width, bloqueo.Height), null,
Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.1f);
}
}
if (lemming[i].puentenomas)
{
int framesale = (lemming[i].actualframe * 26);
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(puente_nomas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 3), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(puente_nomas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 3), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(puente_nomas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 3), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(puente_nomas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 3), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].puente)
{
int framesale = (lemming[i].actualframe * 26);
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(puente, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy-3), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(puente, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy-3), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(puente, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy-3), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(puente, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy-3), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].pico)
{
int framesale = (lemming[i].actualframe * 26);
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(pico, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 2), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(pico, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 2), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(pico, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 2), new Rectangle(0, framesale, 32, 26), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(pico, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 2), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].pared)
{
int framesale = (lemming[i].actualframe * 20);
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(pared, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy+4), new Rectangle(0, framesale, 32, 20), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(pared, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy+4), new Rectangle(0, framesale, 32, 20), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(pared, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy+4), new Rectangle(0, framesale, 32, 20), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(pared, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy+4), new Rectangle(0, framesale, 32, 20), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].explotando)
{
int framesale = (lemming[i].actualframe * 20);
if (lemming[i].onmouse) { spriteBatch.Draw(explota, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(explota, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
if (lemming[i].actualframe >= 15)
{
spriteBatch.Draw(explode, new Vector2(lemming[i].posx - xscroll, lemming[i].posy),new Rectangle(0, 0, 64, 64), Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, lem_depth + (i * 0.00000001f));
////////////////////////////////////////////////////////////////////////////////////// dibuja dibuja zona rota de la explosion
///////////////// CALCULA LOS LIMITES PARA EVITAR EXCEPCIONES
int ancho = 32;
int alto = 44;
int px = lemming[i].posx;
int py = lemming[i].posy;
if (px+ancho>=earth.Width)
{
ancho = earth.Width - px;
}
if (py+alto>=earth.Height)
{
alto = earth.Height - py;
}
int cantidad = ancho * alto;
Color[] colorsobre = new Color[cantidad];
Color[] colormask = new Color[cantidad];
mascaraexplosion.GetData(colormask);
earth.GetData(0,new Rectangle(px,py,ancho,alto),colorsobre,0,cantidad);
for (int r=0;r(0, new Rectangle(px, py, ancho, alto), colorsobre, 0, cantidad);
//earth.GetData(c);
lemming[i].muerto = true; numlemnow--; lemming[i].explotando = false; lemming[i].explota = false; continue;
//ClickTarget.GetData(0, new Rectangle(X, Y, 1, 1), color, 0, 1);`
}
}
if (lemming[i].rompesuelo)
{
int framesale = (lemming[i].actualframe * 20);
if (lemming[i].onmouse) { spriteBatch.Draw(rompesuelo, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(rompesuelo, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 4), new Rectangle(0, framesale, 32, 20), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
if (lemming[i].actualframe==15)
{
lemming[i].muerto = true; numlemnow--;
}
}
if (lemming[i].cayendo)
{
if (lemming[i].framescut==false && lemming[i].actualframe==9)
{
lemming[i].framescut = true; lemming[i].actualframe = 0; lemming[i].numframes = 6;
}
int framesale;
if (lemming[i].framescut == false) framesale = (lemming[i].actualframe * 32);
else framesale= (lemming[i].actualframe+4)*32;
if (lemming[i].onmouse)
{ spriteBatch.Draw(paraguas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 4),new Rectangle(0, framesale, 32, 32), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f));}
else
{ spriteBatch.Draw(paraguas, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy - 4),new Rectangle(0, framesale, 32, 32), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f));}
}
if (lemming[i].cae)
{
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(cae, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.Red, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(cae, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(cae, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(cae, new Vector2(lemming[i].posx - xscroll, lemming[i].posy), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
if (lemming[i].salir && lemming[i].muerto==false)
{
int framesale = (lemming[i].actualframe * 26);
spriteBatch.Draw(sale, new Vector2(lemming[i].posx - xscroll - 1, lemming[i].posy + 1), new Rectangle(0, framesale, 32, 26), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f));
}
if (lemming[i].cavar)
{
if (lemming[i].onmouse) { spriteBatch.Draw(cavar, new Vector2(lemming[i].posx - xscroll, lemming[i].posy + 6), new Rectangle(framereal55, 0, 118, 118), Color.Red, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(cavar, new Vector2(lemming[i].posx - xscroll, lemming[i].posy + 6), new Rectangle(framereal55, 0, 118, 118), Color.White, 0f, Vector2.Zero, 0.25f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
if (lemming[i].escalando)
{
int framesale = (lemming[i].actualframe * 24);
if (lemming[i].derecha)
{
if (lemming[i].onmouse) { spriteBatch.Draw(escala, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 6), new Rectangle(0, framesale, 32, 24), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(escala, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 6), new Rectangle(0, framesale, 32, 24), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, lem_depth + (i * 0.00001f)); }
}
else
{
if (lemming[i].onmouse) { spriteBatch.Draw(escala, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 6), new Rectangle(0, framesale, 32, 24), Color.Red, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
else { spriteBatch.Draw(escala, new Vector2(lemming[i].posx - xscroll - 5, lemming[i].posy + 6), new Rectangle(0, framesale, 32, 24), Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.FlipHorizontally, lem_depth + (i * 0.00001f)); }
}
}
}
// MoverLemming();
if (fade)
{
float a = (float)tiempototalmili;
float b = a / 10;
int c = (int)b % 1400;
/* spriteBatch.Draw(backlogo, new Vector2(540, 320), new Rectangle(0, 0, backlogo.Width, backlogo.Height), new Color(0, 0, 0, 190), 0,
new Vector2(backlogo.Width / 2, backlogo.Height / 2), 1.7f, SpriteEffects.None, 0f); // LOGO
spriteBatch.Draw(backlogo,new Vector2(540,320),new Rectangle(0,0,backlogo.Width,backlogo.Height),new Color(255,255,255,190),0,
new Vector2(backlogo.Width/2,backlogo.Height/2),1.5f,SpriteEffects.None,0f); // LOGO */
if (c < 100) { c = 0; } else { c -= 100; }
DrawLine(spriteBatch, new Vector2(0, 0), new Vector2(graphics.PreferredBackBufferWidth, 0), new Color(0, 0, 0, 255 - c), graphics.PreferredBackBufferHeight,0f);
if (c > 255) { fade = false; tiempototal = 0; tiempototalmili = 0; }
}
if (raton)
{
spriteBatch.Draw(ratonon, new Vector2(posicionMouse.X, posicionMouse.Y), new Rectangle(0, 0, 34, 34), Color.White, 0f, Vector2.Zero,
1f, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(ratonoff, new Vector2(posicionMouse.X, posicionMouse.Y), new Rectangle(0, 0, 34, 34), Color.White, 0f, Vector2.Zero,
1f, SpriteEffects.None, 0f);
}
spriteBatch.End();
base.Draw(gameTime);
}
}
}