Ejemplo n.º 1
0
 public Quiz(ContentManager content)
 {
     answerInterface = content.Load<Texture2D>("interface1");
     fontvragen = content.Load<SpriteFont>("QuizSpritefont");
     fontantwoorden = content.Load<SpriteFont>("fontAntwoorden");
     quizDB = new Database();
     timer = new Timer(400);
     timer.Elapsed += new ElapsedEventHandler(stopFeedbackDraw);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Allows the game to run logic such as updating the world,
 /// checking for collisions, gathering input, and playing audio.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 protected override void Update(GameTime gameTime)
 {
     currKeyboardState = Keyboard.GetState();
     if (Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         this.Exit();
     }
     switch (currState)
     {
         case State.main:
             MainMenuKeys();
             break;
         case State.playing:
             beat.Update(gameTime);
             if (beat.isGameOver())
             {
                 Database conn = new Database();
                 conn.insertHighScore(currentUserId, beat.getFinalScore());
                 conn.close();
                 Console.WriteLine("Closed db connection after writing highscore");
                 beat = null;
                 currState = State.highscores;
             }
             break;
         case State.instructions:
             username += GetChars();
             if (currKeyboardState.IsKeyDown(Keys.Back) && currKeyboardState != prevKeyboardState && username.Length > 0)
             {
                 username = username.Remove(username.Length - 1);
             }
             break;
         case State.highscores:
             break;
         case State.credits:
             break;
         case State.quiz:
             quiz.Update(gameTime);
             if (quiz.isQuizOver())
             {
                 correctAnswers = quiz.getCorrectAnswers();
                 beat = new Playing(this.Content, correctAnswers, currentUserId);
                 currState = State.playing;
             }
             break;
         default:
             break;
     }
     base.Update(gameTime);
     prevKeyboardState = currKeyboardState;
 }
Ejemplo n.º 3
0
        public void DrawInstructions()
        {
            spriteBatch.DrawString(instructionfont, "INSTRUCTIES", new Vector2(500, 150), Color.Black);
            spriteBatch.DrawString(instructionfont, "We beginnen met een quiz om je vaardigheden\nte testen\nOm een antwoord te geven druk je op\n1 = A\n2 = B\n3 = C \n \n\nNa de quiz begint de praktijk oefening\n\nVul hier uw naam in: ", new Vector2(500, 210), Color.Black);
            spriteBatch.Draw(TextBox, new Vector2(1100, 775), Color.White);
            spriteBatch.Draw(Button, InstructionStartButton, Color.White);

            spriteBatch.DrawString(usernameFont, username, new Vector2(1200, 825), Color.Black);
            spriteBatch.DrawString(font, "Start (Spatie)", new Vector2(950, 975), Color.Black);

            if (currKeyboardState.IsKeyDown(Keys.Space))
            {
                Database conn = new Database();
                conn.insertUser(username);
                currentUserId = (int) conn.getUserIdFromUserName(username);
                conn.close();
                currState = State.quiz;
                quiz = new Quiz(Content);
            }
        }
Ejemplo n.º 4
0
 public void DrawHighScore()
 {
     spriteBatch.DrawString(highscoreFont, "HIGHSCORES!", new Vector2(900, 200), Color.Black);
     Database conn = new Database();
     Dictionary<String, int> highscores = conn.getHighScores(20);
     conn.close();
     int currY = 250;
     foreach (KeyValuePair<string, int> currHighscore in highscores)
     {
         spriteBatch.DrawString(highscoreFont, currHighscore.Key.Remove(currHighscore.Key.Length - 1) + "- " + currHighscore.Value.ToString(), new Vector2(900, currY), Color.Black);
         currY += 31;
     }
     if (currKeyboardState.IsKeyDown(Keys.Back))
     {
         currState = State.main;
     }
 }