JavaScript Baseball
Tim Myers
Posted on April 10, 2021
Do It Because It's Fun
Some advice I give to people a lot is once you have a good grasp on your preferred language you should build something you're passionate about or something you enjoy.
With new programmers a lot of the struggle is habit building. Getting into the groove of studying and learning takes time. And it's a lot easier if you're having fun while you're doing it.
Now the key like I said before is to try and create a project that you find interesting. You may be thinking, "But I only like nuclear physics... how am I going to write a program about that?"
The key here is not to build some elaborate project... at least not at first. You could create a project that asks you Nuclear Physics questions and you can keep track of correct answers and provide a scoreboard.
Then you can build on that idea. You can add multiplayer support. A timer to answer the questions. Some fun animations, etc. Just add onto it piece by piece until you have something.
Play Ball
I'm not particularly fond of Baseball. I played Little League as a kid, I umpired games for the really small kids, and I played in High School. But I sort of lost interest in it after that.
I decided to do this project because I had given this project to people that I had mentored in the past and I wanted to see how difficult it really was, (maybe I was asking too much of them). Now, I didn't build a Baseball game with full 3D graphics and controller support. It's basically just a bunch of HTML output in the browser:
I've abstracted away a lot of the complexity. You don't swing at a pitch or anything. You just pitch the ball. Then a random number generator will either make that pitch a "strike", or a "ball". Once you get to 4 balls the batter is "walked". If you get 3 "strikes" the batter is out. Basically I just use the fundamental rules of baseball to keep track of everything.
I picked baseball because it's a relatively slow paced game but you can really do this with anything:
- Horse Racing
- Tennis
- A simple solar system simulator
- Cricket
- A (Pet) Program where there is a creature of some sort that you have to take care of.
There are tons of options. Pick something you enjoy and simulate it. Start small, and build the project up. Do you think that Twitter or Dev.to started out the way they are now? Nope. Twitter probably had the ability to login and send a message and that was it. You probably couldn't like, follow, retweet, block, mute, etc. They built an app with minimal functionality and build up from there.
Here is the link to my easy-baseball repo if you'd like to take a look at the whole project. You can run it yourself and try and figure out how it works. It's actually not a lot of code so don't be intimidated. Just go have a look.
If you want you have my full permission and encouragement to build on this project. There isn't a lot of functionality and there are a few bugs. See if you can find them and fix them.
Thanks for reading and that's all y'all.
Posted on April 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.