Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: American Football  (Read 730 times)

0 Members and 1 Guest are viewing this topic.

Arcade

  • Full Member
  • ***
  • Posts: 204
    • View Profile
American Football
« on: February 02, 2019, 08:24:49 pm »
A while back I posted in the Screenshot thread with a brief gif of an American football game I had started to work on. I've managed to continue working on it off and on since then so I decided to go ahead and make this thread where I can post some more detail for anyone interested. The game is far from done, but it feels like good timing since the real life football Superbowl Championship is this weekend.

The biggest challenge so far has been implementing the AI. The interesting thing about making a video game based on a real game is that there are pre-established rules that the AI needs to follow and they need to behave somewhat realistically. I don't want to fill up this thread with explanations of how American football works for those unfamiliar, but I'll try to give some brief descriptions of what my following gifs are showing.



A lot of these gifs are showing different game situations. The first one shows the offensive team on the left in white shirts throwing a quick pass to one of their receivers. The red lines show the routes that each receiver is going to run. The job of the thrower (quarterback) is to find an open receiver and throw them the ball.

Some of the players on the defense side in purple shirts have big yellow circles. These defenders are in a "zone" defense. The yellow circles represent the zone that they will try to prevent receivers from catching the ball in. The other defenders are either trying to tackle the quarterback while he still has the ball or are defending the receivers 1-on-1 in a "man" defense. In this case the receiver is able to catch the ball and gain 6 or 7 yards down the field before being tackled.

The small numbers above the players head and the small colored circles under their feet are just debugging information I have being displayed. They mostly represent the ID of the player and what behavior the AI is running.

(click to show/hide)

Part of my motivation for working on this game is that I've always wondered how sports games handle AI. I thought it would be a fun challenge to try and replicate it. The throwing aspect is one part that took me a while to get right. It's hard to calculate the direction angle, height angle, and speed the QB needs to throw the ball in order for the receiver to catch it on the run. The previous gif shows the QB just able to get the ball between 2 defenders so that the receiver can make a big catch. Sometimes the defense is able to crowd the receiver a little better resulting in an unsuccessful catch.

(click to show/hide)

There are also several kicking situations in American football, which I've been implementing. This next gif is a Field Goal kick where the team with the ball (in purple) tries to kick the ball between the goal posts for 3 points.

(click to show/hide)

In order to design these plays that I want each team to run, I've built an editor into the game. The next gif shows me designing the starting position and route I want a receiver to run. I then simulate the play which shows the receiver following the route, making a catch, and then juking the defenders for a big gain.
(click to show/hide)

The last thing I'll show off are some of the menu systems outside of the main game. These still need a lot more work aesthetically, but one of the important things you can do from here is set your "depth chart". This basically means setting which of your players you want playing at each position. Each player has different stats and abilities.

(click to show/hide)

The post is getting long, so I'll stop it here. The game still needs a lot of work, including a lot of planned AI improvements, but I hope to stick with it as I have time. The libraries I've been using to put this all together are just SFML (window, graphics, etc) and SQLite for the database backend to store information about each player.

neves768

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: American Football
« Reply #1 on: April 21, 2019, 05:16:04 am »
Looks amazing! Can't wait for more :)
Are you still working on it?

Arcade

  • Full Member
  • ***
  • Posts: 204
    • View Profile
Re: American Football
« Reply #2 on: April 22, 2019, 04:39:04 pm »
Thanks for taking a look, I'm glad you like it so far. Yup, I'm still working on it as I have time, but there is still a lot of work to be done.

I've taken a break from working on the football simulation aspect of it for a bit and am now focusing on some of the menus. I'm specifically implementing the ability to create new teams/schools from the main menu right now (I say 'schools' because I actually intend for this game to be based on American college football). This means things like being able to customize the team name/colors (the gifs above have the team colors hard coded), and generating a realistic roster.

The roster generation part has been pretty hard to get something implemented I'm happy with. I've had to throw it away and re-do it few times. My first naive approach was to just generate the abilities of each player on the team completely randomly, but as expected this would cause goofy things to happen like randomly making a lineman the fastest player on the team, or making the kicker the best thrower on the team. I've now attempted to put a weight on each ability based on the player's position and how good I want the player to be. My current implementation still isn't perfect, but it's getting closer. I think if I just tune the distributions on my random number generators a little more I can end up with something pretty good.

Hopefully sometime soon I'll have more screenshots/gifs to share.

Arcade

  • Full Member
  • ***
  • Posts: 204
    • View Profile
Re: American Football
« Reply #3 on: May 16, 2019, 06:50:25 am »
As I mentioned in my last post, I've been working on menus to allow creating new football teams in-game. It needs to be polished up and made to look nicer, but I think a lot of the initial functionality I want is there. Sorry that my gifs below have been shrunk down, which makes the text a bit hard to read.


Creating a new team also means creating players for that team. Each player has 17 abilities right now (speed, strength, etc) that impact how they perform. Again, sorry the text is hard to read in the below gif, but it also shows off some of the improvements I've made to my widgets for displaying tables of text. I can now scroll vertically and horizontally to see all of my players and all of their abilities.
(click to show/hide)

Lastly, I've started working on a "dynamic" camera which attempts to automatically follow the action of the game and also automatically zoom in/out as needed.
(click to show/hide)

higgipoker

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: American Football
« Reply #4 on: July 30, 2019, 11:00:43 am »
Great project! I'm doing something similar with soccer, in the style of that timeless classic - Sensible Soccer: