1/56
Looks like no tags are added yet.
[Overview] What is the goal of Mini Golf?
Finish the three-hole round with the fewest total strokes. Multiplayer compares the two totals. Solo lets you try to beat your personal best.
[Overview] What are the four main menu options?
Singleplayer, Multiplayer, How to play, and Practice mode. See src/GameManager.cpp:13–22.
[Overview] What order do the main courses appear in?
Star Hollow, Crosswind, then Sand. The rectangular Practice Course is separate. See src/CourseLayouts.cpp:3–65.
[Overview] How do you play a shot?
Click near a stopped ball, drag away from the direction you want to shoot, then release. Right-click cancels.
[Overview] What happens in Practice mode?
You can play one rectangular hole without entering a name or saving a score. R restarts the hole and M returns to the menu. See src/GameManager.cpp:163–185 and 264–275.
[Overview] What does raylib handle?
It opens the window, reads input, converts coordinates using the camera, and draws shapes and text. The game classes handle the rules.
[Overview] Who worked on which parts?
Ayoub covered ball, aiming, and camera. Mayse covered course layouts, walls, and hazards. Akhil covered screens, turns, scores, the main loop, and the build setup.
[Overview] Trace one shot through the game.
ShotControls sets launch velocity and returns true. Game counts a stroke and runs small time steps. Course calls Ball to move and slow down, then checks collisions. Game decides what comes next when the ball stops.
[Ball] What does each Ball object store?
Position, velocity, radius, and inHole. Position and velocity use raylib Vector2 for x and y. See includes/Ball.h:4–10.
[Ball] How are the constructor and reset() used?
The constructor sets the radius to 7 and initializes the ball. reset(start) puts an existing ball at a given position, zeros velocity, and clears inHole. See src/Ball.cpp:5–18.
[Ball] How does getSpeed() turn velocity into one number?
It takes the length of the velocity vector using sqrt(vx² + vy²). For velocity {3, 4}, the speed is 5. See src/Ball.cpp:21–28.
[Ball] Why multiply velocity by seconds to update position?
Velocity is in board units per second. At 100 units per second, a 0.01-second step moves the ball one unit. See src/Ball.cpp:48–49.
[Ball] How does friction slow the ball without turning it?
It subtracts friction times seconds from speed. Then both velocity components are multiplied by newSpeed / speed, so the direction stays the same. See src/Ball.cpp:51–64.
[Ball] How does the game know when a roll is over?
Ball::update sets velocity to zero when the new speed drops below 5. isMoving() returns false at zero speed. See src/Ball.cpp:31–34 and 55–57.
[Ball] Why does update() return early for a sunk or stationary ball?
Those balls have no movement to update. The stationary check also prevents division by zero in newSpeed / speed. See src/Ball.cpp:38–45.
[Ball] How does the ball get drawn?
It uses three raylib circles for the shadow, colored ball, and white highlight. A sunk ball is skipped. See src/Ball.cpp:67–77.
[Aiming] What are aiming and anchor?
aiming tracks whether a shot is being lined up. anchor is where the player first clicked and stays fixed until the next valid click. See includes/shotcontrols.h:5–8.
[Aiming] Why calculate anchor minus mouse?
It points the shot opposite the drag. If you click at x = 100 and pull left to x = 70, the result is +30, which points right. See src/ShotControls.cpp:25–26.
[Aiming] What happens if you drag farther than 120 units?
Both components scale by 120 divided by the drag length. That keeps the direction and caps power. See src/ShotControls.cpp:29–39.
[Aiming] What makes a click close enough to the ball?
The click must be within a circle around the ball with radius ball.radius + 8 board units. See src/ShotControls.cpp:55–60.
[Aiming] Why use Pressed to aim and Released to shoot?
Pressed is true on the frame the button goes down, so the anchor is saved once. Released is true on the frame the button comes up, which is when a valid shot launches. See src/ShotControls.cpp:55–78.
[Aiming] Why compare squared drag length with 16?
The minimum drag is 4 board units. Comparing squared lengths uses 4² = 16 and avoids a square root for that check. See src/ShotControls.cpp:69–74.
[Aiming] How does drag become launch velocity?
ShotControls multiplies the drag vector by 5.75. At full power, the starting speed is 120 × 5.75 = 690 board units per second. See src/ShotControls.cpp:77–78.
[Aiming] Why do the aiming arrow and launch use the same getDrag()?
Both get the same direction and capped drag calculation, so the arrow preview points in the same direction the shot will launch.
[Aiming] How are the arrow and power bar calculated?
Power is drag length divided by 120. The normalized drag gives the arrow direction, power changes its length, and a perpendicular vector places the arrowhead sides. See src/ShotControls.cpp:91–128.
[Camera] How does the portrait board fit inside the window?
The board is 500 by 1040 units. boardCamera() uses the smaller of the width and height scale ratios and centers the board in the window. See includes/PortraitView.h:8–29.
[Camera] Why do clicks still line up when the window resizes?
Drawing uses boardCamera(). GetScreenToWorld2D uses that same camera to convert the mouse from window pixels to the ball's board coordinates. See game.cpp:38–44 and src/ShotControls.cpp:11–14.
[Camera] Why are the dimensions constexpr and boardCamera() inline?
constexpr makes the dimensions compile-time constants. inline allows the same function definition in the header to be included by several .cpp files. See includes/PortraitView.h:8–14.
[Course] Why use std::vector for course geometry?
Each course can have a different number of corners, bumpers, and solid obstacles. Vectors let those collections vary in size. See includes/Course.h:7 and 26–31.
[Course] How does SolidObstacle reuse Wall behavior?
SolidObstacle publicly inherits Wall, so it can call the same bounce function. using Wall::Wall also makes the wall constructors available to it. See includes/Course.h:9–21.
[Course] Why can a const Wall::bounce() change the ball?
The trailing const protects the Wall object's state. The separate Ball& parameter gives it access to modify the original ball. See includes/Course.h:13.
[Course] How does a wall detect ball contact?
It finds the closest point on each edge segment and compares the distance from that point to the ball's radius. An overlap happens when the distance is smaller than the radius. See src/Course.cpp:46–57.
[Course] What happens to velocity during a wall bounce?
The part heading into the wall reverses and keeps 80% of its original size. The part parallel to the wall stays the same. The ball is also pushed clear of the edge. See src/Course.cpp:59–66.
[Course] Why does Course check whether the ball is inside a polygon?
It uses that check to choose sand friction and detect entry into the boost strip. The check flips inside or outside each time a ray to the right crosses an edge. See src/Course.cpp:6–17 and 69–79.
[Course] How does the game fill a shape like the star?
For each horizontal row, it sorts the x positions where the edges cross and draws between each inside pair. See src/Course.cpp:19–43.
[Course] How do sand and boost differ?
Sand uses friction 560 instead of the grass value of 180. A boost adds velocity in the arrow direction when the ball enters the strip during the first 10 seconds of a shot. See src/Course.cpp:69–79.
[Course] What exactly does the instructor's RNG randomize?
For a bumper collision during the first 10 seconds, RNG141::getRandom(500.0f, 530.0f) chooses the launch speed in that range. The direction is outward from the bumper's center. See src/Course.cpp:80–88.
[Course] Where does the random-number generator come from?
Course owns an RNG141 object. The provided cs141random.cpp implements the float and int overloads. The bumper uses the float overload. See includes/Course.h:27 and src/cs141random.cpp:28–40.
[Course] What conditions make a ball sink?
The ball's center must be within 11 board units of the cup and its speed must be below 100. Course then places it at the cup, zeros velocity, and sets inHole. See src/Course.cpp:90–94.
[Course] Why can a fast ball roll over the cup?
The distance check only captures the ball when the speed check also passes. A ball moving at 100 units per second or faster keeps rolling. See src/Course.cpp:90–94.
[Game] What does Game own and coordinate?
It owns a Course, ShotControls, player balls, names, strokes, and a map of best scores. It coordinates screens, inputs, turns, and the round. See includes/GameManager.h:10–54.
[Game] What are the named screen states?
MENU, INSTRUCTIONS, ENTER_NAMES, PLAYING, PRACTICE, and RESULTS. The game starts in MENU. See includes/GameManager.h:13–16.
[Game] Why use std::array for players and std::vector for obstacles?
Player capacity is fixed at two, even when solo uses only slot zero. The number of obstacles varies by course. See includes/GameManager.h:23–25 and includes/Course.h:29–30.
[Game] What counts as exactly one stroke?
Game increments strokes[active] when controls.update(ball) reports a valid launch and there is no shot already in progress. See src/GameManager.cpp:291–302.
[Game] Why use small time steps for physics?
A large update could move past a thin wall or cup between checks. Game caps elapsed time at 0.05 seconds and uses steps of at most 1/240 second. See src/GameManager.cpp:304–318.
[Game] How does local multiplayer advance turns?
When the ball stops, finishShot searches the player slots in order and picks the next player whose ball is still outside the cup. See src/GameManager.cpp:179–194 and 308–318.
[Game] When does the next hole or scorecard appear?
After all active players finish the current hole, Game loads the next hole. After the third hole it saves eligible bests and enters RESULTS. See src/GameManager.cpp:187–203.
[Game] How are multiplayer ties handled?
The scorecard checks whether both totals are equal and displays Tie game. Otherwise it shows the player with the lower total. See src/GameManager.cpp:517–528.
[Scoring] How does a personal best follow the player between slots?
The map is keyed by the name with ASCII capitals converted to lowercase. The name still displays as typed. See src/GameManager.cpp:29–47.
[Scoring] When should a best score change?
After a completed three-hole round, a new or lower total qualifies. A worse total leaves the old best in place when the saved file is loaded correctly. Practice skips saving. See src/GameManager.cpp:66–79 and 179–203.
[Scoring] What does findBest() return and who owns it?
It returns a const int* pointing to a score owned by the map, or nullptr if missing. The caller checks it before reading and does not delete it. See src/GameManager.cpp:42–47 and 542–548.
[Scoring] What is the save-file bug in the reviewed ZIP?
loadBests() reads pesonal_bests.txt at line 53, while saveBests() writes personal_bests.txt at line 93. Match the spellings before showing persistence across sessions.
[Scoring] Why use std::quoted and a temporary file?
std::quoted keeps names with spaces together. The code writes the full new record list to a temporary file before renaming it to the final name. See src/GameManager.cpp:53–61 and 85–97.
[C++] What is the difference between Ball& and const Ball&?
Both refer to the original ball. Ball& can change it, as aiming does on launch. const Ball& allows read-only access through the reference, as drawing uses. See includes/shotcontrols.h:14–18.
[C++] What does the trailing const on draw(const Ball& ball) const mean?
The first const protects the ball argument. The trailing const means draw does not modify the ShotControls object's own ordinary fields. See includes/shotcontrols.h:18.
[Build] What does game.cpp do each frame?
It calls Game::update with elapsed time, starts the drawing pass, applies the board camera, calls Game::draw, then finishes drawing. See game.cpp:27–48.
[Build] How do you build and run it in CodingRooms?
Run make build, then make run_game from the project root. Build compiles the game sources and links raylib into game.out. See makefile:21–41.