protected void CheckIfCrashed(SkyKidGame world) { //check to see if corners of sprite collide with world. if (world.Level.collide(X, Y) || world.Level.collide(X + Width, Y) || world.Level.collide(X, Y + Height) || world.Level.collide(X + Width, Y + Height)) { Dead = true; // TODO: play once?????? Animation.AutoAnimateOnce("dead", 0); } }
protected void CheckForBulletCollide(SkyKidGame world) { foreach (SkyKidGame.Bullet b in SkyKidGame.Bullets) { if (SkyKidGame.Collide(b.x, b.y, 1, 1, X, Y, Width, Height)) { Dead = true; Animation.AutoAnimateOnce("dead", 0); } } }
public void ShootBullets(SkyKidGame world) { if(FramesUntilCanShootAgain == 0) { FramesUntilCanShootAgain = FramesPerShot; SkyKidGame.Bullet b = new SkyKidGame.Bullet(); b.x = X + Width + 2; b.y = Y + 5; b.left = false; SkyKidGame.Bullets.AddFirst(b); } }
public void ShootBullets(SkyKidGame world) { if (FramesUntilCanShootAgain == 0) { FramesUntilCanShootAgain = FramesPerShot; SkyKidGame.Bullet b = new SkyKidGame.Bullet(); b.x = X + Width + 2; b.y = Y + 5; b.left = false; SkyKidGame.Bullets.AddFirst(b); } }
private void CheckForShoot(SkyKidGame world, KeyboardState ks) { if (ks.IsKeyDown(Keys.A) && FramesUntilCanShootAgain == 0) { FramesUntilCanShootAgain = FramesPerShot; SkyKidGame.Bullet b = new SkyKidGame.Bullet(); //Arbitrarily decide where to spawn bullet b.x = X - 2; b.y = Y + 5; b.left = true; SkyKidGame.Bullets.AddFirst(b); } }
private void MovePlane(SkyKidGame world, KeyboardState ks) { // X if (ks.IsKeyDown(Keys.Left) && X > world.CamX) X -= 5; else if (ks.IsKeyDown(Keys.Right) && X < world.CamX + SkyKidGame.BaseWidth + -Width) X -= 1; else X -= 3; // Y if (ks.IsKeyDown(Keys.Down)) Y += 3; else if (ks.IsKeyDown(Keys.Up)) Y -= 3; }
public void update(SkyKidGame world) { if (FramesUntilCanShootAgain != 0) FramesUntilCanShootAgain--; if (!Dead) { X++; CheckIfCrashed(world); CheckForBulletCollide(world); ShootBullets(world); } Animation.Update(); }
public void update(SkyKidGame world,KeyboardState ks) { if (FramesUntilCanShootAgain != 0) FramesUntilCanShootAgain--; if (!Dead) { MovePlane(world, ks); CheckForShoot(world, ks); CheckIfCrashed(world); CheckForBulletCollide(world); } Animation.Update(); }
public void update(SkyKidGame world) { if (FramesUntilCanShootAgain != 0) { FramesUntilCanShootAgain--; } if (!Dead) { X++; CheckIfCrashed(world); CheckForBulletCollide(world); ShootBullets(world); } Animation.Update(); }
static void Main() { using (var game = new SkyKidGame()) game.Run(); }