Baseball Physics Sim/Hitting Game

Austin Shin

Introduction

   My final project was a baseball hitting game. A baseball isthrown towards the player, who can then swing the bat at it to hit it. Last hit distance, max hit distance, and average hit distance is stored and displayed. Some of the technologies I incorporated were spot lights, directional lights, physics, and shadow mapping using FBO's.

   I was inspired to do this project because I love baseball. I played as a kid and I love playing with friends now, and one of my favorite things to do is play baseball video games: MLB The Show, MLB 2k, Backyard Baseball, Super Mega Baseball, you name it. I love the hitting system in these types of games and I wanted to emulate a casual version of it.


Controls

N - Swing

L - Unlock/Lock camera

WASD - Camera translation (unlocked)

Mouse - Camera rotation (unlocked)

Physics and collisions

   The thing I'm most proud of is the physics and collision system. I spent way too much time on these because I got so into it but, I feel like they're pretty true to the real world. I wanted the ball's movement to feel realistic so you get the satisfaction of watching it fly, and I feel like I've accomplished that. The physics system uses the standard kinematic equations to simulate the ball's flight path (without air resistance), and the collision system uses the angle of the bat and MLB stats/averages to calculate a reasonable ball launch angle and exit velocity.

Lighting

   Another expansion on what we learned in class that I added was spot lighting and directional lighting. I added spot lights to simulate the light poles around the stadium and I added a directional sunlight and a fake ground reflection light. The light colors and design were inspired by an Angels game I was watching that was around sunset, as I liked how everything looked.

Textures and Materials

   I wanted to have a grass texture for my field but because of issues I was having with the .obj file and aspect ratios it turned out flat green, which I honestly was okay with. I never planned on making this look super realistic and I like how it all looks.

Difficulties

   I implemented the code for shadow mapping but due to spending too much time on the physics/collision systems and issues with textures I didn't get the chance to showcase it. You can't really see or tell what's going on.

   I wrote code for text rendering for hit distance stats but the thing that blocked me was linking the FreeType library to VS 2019. I spent at least an hour and a half trying to figure it out but to no avail. Compiling it as /MD, moving the .dll to system32, using vcpkg, everything. This is the reason why I put the stats into the console instead.