// ACTIONS //
        private void GameClock_Tick(object sender, EventArgs e)
        {
            // Checks to see if player is in contact with an obstacle
            if (physics.inContact(player, ob, TopBar))
            {
                GameOver();
                return;
            }

            // Calculates new time
            score += (int)Math.Round(GameClock.Interval / 10.0);

            // Adds a new obstacle if necessary
            if (obstacleCounter == nextObstacle)
            {
                ob.Add(physics.addObstacle());
                obstacleCounter = 0;
                RestartNextObstacle();
            }

            // Moves the player
            int[] newPositions = physics.movePlayer(player);
            //int[] newPositions = Physics.move(player);
            player.Left = newPositions[0];
            player.Top  = newPositions[1];

            // Clear vertical acceleration applied
            physics.AccelApplied[1] = 0;

            // Displays velocities and time
            ScoreLabel.Text = string.Format("Score: {0}", score.ToString("D8"));

            // Moves the obstacles across bottom of screen
            for (int i = ob.Count - 1; i > -1; i--)
            {
                if (ob[i].Right <= ClientRectangle.Left)
                {
                    this.Controls.Remove(ob[i]);
                    ob.RemoveAt(i);
                }
                else
                {
                    ob[i].Left -= 5;// (5 + ((int)score / 1000));
                }
            }

            obstacleCounter++;
            ScoreLabel.SendToBack();
            HighScoreLabel.SendToBack();
        }
Beispiel #2
0
        void ReleaseDesignerOutlets()
        {
            if (HighScoreLabel != null)
            {
                HighScoreLabel.Dispose();
                HighScoreLabel = null;
            }

            if (NewGameButton != null)
            {
                NewGameButton.Dispose();
                NewGameButton = null;
            }

            if (ViewQuestionsButton != null)
            {
                ViewQuestionsButton.Dispose();
                ViewQuestionsButton = null;
            }
        }
Beispiel #3
0
        protected override void OnRenderFrame(FrameEventArgs E)
        {
            base.OnRenderFrame(E);

            var Modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref Modelview);

            RenderBackground();

            var PipeMarginY = (ProjectionHeight - MapHeight * SolidSize) / 2f;
            var PipeMarginX = (NominalHeight - MapHeight * SolidSize) / 2f;

            var Overwidth = ProjectionWidth - ProjectionHeight * (float)NominalWidth / NominalHeight;

            if (Overwidth > 0)
            {
                GL.Translate(Math.Min(Overwidth, (ProjectionWidth - MapWidth * SolidSize) / 2f), PipeMarginY, 0);
            }
            else
            {
                GL.Translate(PipeMarginX, PipeMarginY, 0);
            }

            RenderPipe();

            for (var X = 0; X < MapWidth; X++)
            {
                for (var Y = 0; Y < MapHeight; Y++)
                {
                    if (Map[X, Y] >= 0)
                    {
                        RenderSolid(X, Y + ImpactFallOffset[X, Y], Map[X, Y]);
                    }
                }
            }

            if (GameStateEnum.Fall == GameState)
            {
                for (var i = 0; i < StickLength; i++)
                {
                    if (StickColors[i] >= 0)
                    {
                        RenderSolid(StickPosition.X + i, StickPosition.Y, StickColors[i]);
                    }
                }
            }

            GL.Translate(MapWidth * SolidSize + PipeMarginX, 0, 0);

            NextStickLabel.Render();
            GL.Translate(0, NextStickLabel.Height, 0);
            RenderNextStick();
            GL.Translate(0, -NextStickLabel.Height, 0);

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            if (GameStateEnum.GameOver == GameState)
            {
                GameOverLabel.Render();
                GL.Translate(0, GameOverLabel.Height, 0);
                GameOverHint.Render();
                GL.Translate(0, -GameOverLabel.Height, 0);
            }
            else if (Paused)
            {
                PauseLabel.Render();
                GL.Translate(0, PauseLabel.Height, 0);
                UnpauseHint.Render();
                GL.Translate(0, -PauseLabel.Height, 0);
            }
            else
            {
                PlayingGameLabel.Render();
                GL.Translate(0, PlayingGameLabel.Height, 0);
                PauseHint.Render();
                GL.Translate(0, -PlayingGameLabel.Height, 0);
            }

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            ScoreLabel.Render();
            GL.Translate(0, ScoreLabel.Height, 0);
            ScoreRenderer.Label = Score.ToString();
            ScoreRenderer.Render();
            GL.Translate(0, -ScoreLabel.Height, 0);

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            HighScoreLabel.Render();
            GL.Translate(0, HighScoreLabel.Height, 0);
            HighScoreRenderer.Label = HighScore.ToString();
            HighScoreRenderer.Render();

            SwapBuffers();
        }
Beispiel #4
0
        void ReleaseDesignerOutlets()
        {
            if (ActiveItems_Label != null)
            {
                ActiveItems_Label.Dispose();
                ActiveItems_Label = null;
            }

            if (CandyButton != null)
            {
                CandyButton.Dispose();
                CandyButton = null;
            }

            if (Collected_Label != null)
            {
                Collected_Label.Dispose();
                Collected_Label = null;
            }

            if (HelpLabel != null)
            {
                HelpLabel.Dispose();
                HelpLabel = null;
            }

            if (HighScoreLabel != null)
            {
                HighScoreLabel.Dispose();
                HighScoreLabel = null;
            }

            if (InfoButton != null)
            {
                InfoButton.Dispose();
                InfoButton = null;
            }

            if (LevelLabel != null)
            {
                LevelLabel.Dispose();
                LevelLabel = null;
            }

            if (LevelUpLabel != null)
            {
                LevelUpLabel.Dispose();
                LevelUpLabel = null;
            }

            if (MainView != null)
            {
                MainView.Dispose();
                MainView = null;
            }

            if (RestartButton != null)
            {
                RestartButton.Dispose();
                RestartButton = null;
            }

            if (ScoreLabel != null)
            {
                ScoreLabel.Dispose();
                ScoreLabel = null;
            }

            if (SettingsButton != null)
            {
                SettingsButton.Dispose();
                SettingsButton = null;
            }
        }