internal void StartGame() { cue.Shoot(OnHit); gameState = GameState.Game; uiManager.SetState(gameState); SFXPlayer.PlayClip(SFX.Go); MusicPlayer.SetFilterActive(false); }
public MainForm() { InitializeComponent(); powerBarGfx = this.imgPowerBar.CreateGraphics(); Init(this, this.timer.Interval); this.imgTable.SendToBack(); AddFormEvents(); DrawShotPowerBar(0f); // adds handlers for various winform events such as mouse clicks void AddFormEvents() { this.MouseMove += (sender, e) => { // moves crosshair image on GUI if cue ball is scratched to indicate where it will be placed if (!BallsMoving && Scratched) { MoveCrossHair(e.Location); } }; this.MouseMove += MoveAndChargeCue; this.MouseDown += MoveAndChargeCue; // readjusts position of cue void MoveAndChargeCue(object sender, MouseEventArgs e) { // adjusts angle of attack on cue ball if in shooting phase if (!BallsMoving && !Scratched) { Cue.ChangePos(e.Location); // draws shot power if mouse held down if (e.Button == MouseButtons.Left) { DrawShotPowerBar(Cue.ShotPower()); } } } this.MouseUp += (sender, e) => { if (e.Button == MouseButtons.Left && !BallsMoving) { // places cue ball onto table if left click while scratched if (Scratched) { PlaceCueBall(e.Location); } // shoots cue ball if left click while not scratched else { Cue.Shoot(e.Location); DrawShotPowerBar(0f); BallsMoving = true; MoveBalls(); // resets timer this.timer.Stop(); this.timer.Start(); } } }; } }