private void GameTimer_Tick(object sender, EventArgs e) { tick++; // tick cloudX -= backgroundMoveSpd; // move cloud dist += backgroundMoveSpd; // add to dist actualDist = dist / 100; // actual distance travelled if (endGame && tick % 15 == 0) { if (backgroundMoveSpd > 0) { backgroundMoveSpd--; } else if (bounce < 10 && backgroundMoveSpd == 0) { GameOver(); } } if (endGame && player.hb.Bottom >= this.Height && !bounceUp) { bounceUp = true; bounce /= 2; if (bounce < 15) { bounce = 0; } } if (player.hb.Bottom > this.Height - bounce && bounceUp && endGame) { player.move(-10); airDownFrames = 0; } else { bounceUp = false; } if (r.Next(0, 101) < coinChance && tick % 120 == 0 && !endGame) { generateCoin(r.Next(0, 3), r.Next(100, this.Height - 100)); } if (r.Next(0, 2) == 0 && tick % 1200 == 0 && !endGame && curntMech == "none") { Classes.mechToken m = new Classes.mechToken(this.Width, r.Next(0, this.Height - 50)); if (!abort) { MTokens.Add(m); } else { abort = false; } } if (tick == 180) { lasers.Add(new Classes.laser(this.Width, 10, midLaser, laserWidth, Properties.Resources.laserV)); } else if (tick % timeBtwnLasers == 0 && !endGame) { generateLaser(player.y); } if (tick % 1200 == 0 && coinChance < 35 && !endGame) { coinChance += 5; } if (tick % 240 == 0) { cloudX = this.Width; } if (tick % 550 == 0 && !endGame) { if (backgroundMoveSpd < 20) { backgroundMoveSpd += 2; } //if (timeBtwnLasers > 15) timeBtwnLasers -= 15; } if (tick % 240 == 0) { if (timeBtwnLasers > 20) { timeBtwnLasers -= 15; } else { //timeBtwnLasers = 5; } } if (tick % 600 == 0 && r.Next(0, 3) == 0 && !upgrades["jammer"]) { if (r.Next(0, 5) == 0) { spawnBarrage = true; barrageSpawns = 0; } Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25); alert.Stop(); alert.Play(); rockets.Add(rc); } if (spawnBarrage && tick % 30 == 0 && barrageSpawns < 5) { Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25); rockets.Add(rc); barrageSpawns++; } switch (curntMech) { case "none": standardGrounded(); standardUp(); standardGav(); standardJump(); break; case "teleporter": grounded = true; break; case "superJump": superJumpUp(); superJumpGav(); break; case "gravity": GsuitGav(); break; } if (endGame) { up = false; } Refresh(); }
private void GameTimer_Tick(object sender, EventArgs e) { tick++; // tick cloudX -= backgroundMoveSpd; // move cloud dist += backgroundMoveSpd; // add to dist actualDist = dist / 100; // actual distance travelled if (endGame && tick % 15 == 0) // for bounces and slowing down after being killed { if (backgroundMoveSpd > 0) { backgroundMoveSpd--; } else if (bounce < 10 && backgroundMoveSpd == 0) { GameOver(); // if fully stopped, gameover } } if (endGame && player.hb.Bottom >= this.Height && !bounceUp) // if player hits bottom, bounce up { bounceUp = true; bounce /= 2; if (bounce < 15) { bounce = 0; } } if (player.hb.Bottom > this.Height - bounce && bounceUp && endGame) // if less than bounce height, keep moving up { player.move(-10); airDownFrames = 0; } else { bounceUp = false; // turn around and fall down } if (r.Next(0, 101) < coinChance && tick % 120 == 0 && !endGame) // if game isnt over, and chance is met, generate a coin pattern { generateCoin(r.Next(0, 3), r.Next(100, this.Height - 100)); } if (r.Next(0, 2) == 0 && tick % 1200 == 0 && !endGame && curntMech == "none") // every 1200 ticks, have a chance to generate a mech token { Classes.mechToken m = new Classes.mechToken(this.Width, r.Next(0, this.Height - 50)); if (!abort) // if the player doesn't have the generated mech, stop the generation { MTokens.Add(m); } else { abort = false; } } if (tick == 180) // generates startup laser { lasers.Add(new Classes.laser(this.Width, 10, midLaser, laserWidth, Properties.Resources.laserV)); } else if (tick % timeBtwnLasers == 0 && !endGame) //from here on out, generate a laser every timebtwnlaser ticks { generateLaser(player.y); } if (tick % 1200 == 0 && coinChance < 35 && !endGame) { coinChance += 5; // every 1200 ticks increase chance to get coins } if (tick % 240 == 0) // move the cloud to front of screen { cloudX = this.Width; } if (tick % 550 == 0 && !endGame) // movespeed increase every 550 ticks { if (backgroundMoveSpd < 20) // caps speed at 20 { backgroundMoveSpd += 2; } } if (tick % 240 == 0) //every 240 ticks, decrease spawn timeout for lasers { if (timeBtwnLasers > 20) { timeBtwnLasers -= 15; } } if (tick % 600 == 0 && r.Next(0, 3) == 0 && !upgrades["jammer"]) // spawn rockets on 1/3 chance, every 600 ticks, and if you haven't bought jammer { if (r.Next(0, 5) == 0) // 1/5 chance to spawn a 5 rocket barrage { spawnBarrage = true; barrageSpawns = 0; } Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25); // create a rocket that follows the player alert.Stop(); //play alert alert.Play(); rockets.Add(rc); } if (spawnBarrage && tick % 30 == 0 && barrageSpawns < 5) // spawn barrage rockets every 30 ticks until 5 are spawned { Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25); rockets.Add(rc); barrageSpawns++; } switch (curntMech) //based on mech, do different physics { case "none": standardGrounded(); standardUp(); standardGav(); standardJump(); break; case "teleporter": grounded = true; break; case "superJump": superJumpUp(); superJumpGav(); break; case "gravity": GsuitGav(); break; } if (endGame) { up = false; // stop the player from flying if they got hit } Refresh(); }