USF-OS / FogOS

Other
0 stars 48 forks source link

Add pong command to user space #58

Open mikesmith-23 opened 1 month ago

mikesmith-23 commented 1 month ago

Command: The "pong" command will run a terminal-based version of the classic Atari game Pong, providing users with an interactive experience within the terminal. Players will control paddles using keyboard inputs, aiming to keep the ball in play as it bounces back and forth across the screen.

Plan:

  1. Implementation: The pong command will launch a text-based version of Pong, rendering the paddles, ball, and boundary in the terminal. The paddles will be controlled by the arrow keys (or alternative keys if necessary), while the ball will move at a constant speed, bouncing off both the walls and paddles.

  2. Difficulty Modes: Flags will be added to adjust the difficulty by altering the ball's speed and refresh rate.

    • -e (easy - default mode): A slower refresh rate and reduced ball speed for beginner players.
    • -m (medium): Moderate ball speed and refresh rate, providing a balanced challenge.
    • -h (hard): Fast ball speed and high refresh rate, creating a more challenging gameplay experience.
  3. Key Input: Players will use keyboard input to move the paddles up or down. A key concern here is ensuring that the OS supports the necessary library calls to handle real-time keypresses, such as reading arrow key input or using an alternative method for key control if the OS lacks arrow key support.

  4. Game Logic: The game will continue until one player scores a set number of points or quits the game by pressing a designated key. Scoring will be displayed in the terminal, and the game will reset after each round.

  5. Future Enhancements:

    • Multiplayer Mode: Add a flag (e.g., -mp) for two-player gameplay, where one player controls each paddle using separate keys.
    • Obstacles: Consider introducing additional obstacles (e.g., bouncing blocks) to make the game more dynamic and unpredictable in future versions.

Files to be Added/Modified:

Concerns: To achieve the desired cursor logic in the terminal, this might involve calling third-party libraries (which might not be feasible -- being that we haven't covered this in class yet).

malensek commented 1 month ago

This sounds good to me. To make life easier, I would probably assume that you're going to clear and repaint the whole screen for each iteration of your game loop. It will probably be a bit slow, but you are right: we don't have libraries like ncurses here, so the alternative is manually sending escape codes to the terminal to selectively modify character cells (probably a decent amount of work on top of an already large project).

Will you be working with a teammate?