Skip to content

Efty34/iOS_Lab_Assignment_01

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Personal Details

  • Roll: 2007052
  • Name: Efty Hasan

ColorExpert

ColorExpert is a fun and interactive iOS game built with SwiftUI where players match the name of a color with the correct color circle within a time limit. The game tracks the score and provides a simple restart option after it ends.

Features

  • Randomly generated colors for each round.
  • Score tracking based on correct answers.
  • Countdown timer for added challenge.
  • Interactive UI with buttons to select colors.
  • Option to restart the game after it ends.

Screenshots

Code Overview

ContentView Structure:

  • State Variables:

    • allColors: List of color names and their associated colors.
    • currentColor: The name of the color to match.
    • displayedColors: Randomly selected colors displayed on the screen.
    • score: Tracks the player’s score.
    • timeRemaining: Countdown timer for each round.
    • gameActive: Boolean to track if the game is running or over.
    • timer: Timer object for managing time.
  • UI Layout:

    • A title displaying the game’s name.
    • The target color name shown in bold text.
    • A countdown timer and current score display.
    • A grid of four color circles as options to pick from.
    • A "Game Over" screen with the final score and a "Play Again" button.
  • Game Functions:

    • startGame: Initializes the game, resets the timer, and picks random colors to display.
    • pickRandomColors: Randomly selects four colors, including the correct one, and shuffles them.
    • checkAnswer: Checks if the selected color matches the target; updates the score or ends the game.
    • resetTimer: Resets the timer to 10 seconds and schedules it to count down.
    • endGame: Stops the timer and switches to the game-over screen.
    • restartGame: Resets the score and restarts the game.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages