Science Projects Project Guides Ask An Expert Blog Science Careers Teachers Parents Students

Hit Boxes: How Size Affects Score

Difficulty
Time Required Average (6-10 days)
Prerequisites None
Material Availability Readily available
Cost Very Low (under $20)
Safety No issues

Abstract

Video games come in many varieties: aim-and-shoot games, city-building games, racing games... the list goes on. In many, you get points for colliding with or hitting something. In this computer and video games project, you will learn about how hit boxes are used to detect collisions and you will determine if the size and placement of a hit box affects the score in the game.

Objective

To build a video game using a programming language of your choice and experiment with how the size and placement of a hit box affect the game's score.

Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Credits

Michelle Maranowski, PhD, Science Buddies

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Science Buddies Staff. "Hit Boxes: How Size Affects Score." Science Buddies, 6 Jan. 2018, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Games_p028/video-computer-games/hit-boxes-how-size-affects-score. Accessed 16 Dec. 2018.

APA Style

Science Buddies Staff. (2018, January 6). Hit Boxes: How Size Affects Score. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Games_p028/video-computer-games/hit-boxes-how-size-affects-score


Last edit date: 2018-01-06

Introduction

If, on my daily walk, I bumped into my neighbor walking her dog, we would both know the reason we bumped into each other was that we were trying to occupy the same space at the same time. But how does a video game "know" when two characters have bumped into each other, or if a racing car has hit the speedway's wall? The answer is through collision detection and hit boxes. Why are hit boxes important? Because a poorly designed hit box can lead to errors during game play, like a collision between two characters in a game that are visually far apart. It is also frustrating for a player who can't score in a game.

A hit box, also known as a bounding box or bounding volume, is either a two-dimensional or three-dimensional shape that surrounds a character, which the game's programming uses to detect a hit or collision. Figure 1 shows an example of a hit box or bounding box. In the case of the racing game mentioned, both the racing car and the speedway wall have a hit box surrounding them. If the x- and y-coordinates of the racing car's hit box overlap or match the x- and y-coordinates of the wall's hit box, then the game's programming registers a collision. As the character moves through the game, the size, shape, and coordinates of the hit box change. If the character is still, the hit box lies on top of the character. But as a character runs or moves, the hit box stays marginally behind it in order to account for lag. Lag is the delay between the action of the player and the reaction of the game's programming (or the server if the game is online). This makes a big difference in shooting games, when the player can shoot accurately at a character but doesn't score because the character has moved. To compensate for lag, the hit box trails spatially behind the character.

Bounding box

Figure 1. In this image, a bust of Athena is surrounded by a hit box or bounding box. (Wikipedia, 2011)

A hit box can be a simple rectangle that envelops the entire character, several boxes that surround the character's head, torso, or arms, or a complicated set of boxes or cylinders that closely follows the character's outline. A basic rectangular box means that the calculations that the game's programming performs to determine if a collision has occurred are simple. A complicated set of hit boxes or cylinders leads to complicated and time-consuming calculations. But the advantage that a complicated scheme of hit boxes has over a simple rectangle is that the collision is more realistic for the players.

In this computer and video game project, you will experiment with hit boxes and investigate how the size and placement of the hit box affects game score. You will use a programming language of your choice to perform your experiment. You will use the engineering design process to build a simple video game that enables you to test the effect of varying the dimensions of the hit box.

Terms and Concepts

  • Hit box
  • Programming
  • Lag
  • Flowchart
  • Sprite

Questions

  • What types of video games involve collision detection? Can you give specific examples of ones that do and do not?
  • Play a video game that involves collision detection. How do the hit boxes change over the time it takes to play the game?
  • What are some common types of hit boxes?

Bibliography

This page will help you get started with a programming language you can use to make a video game:

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Materials and Equipment

  • Computer with internet connection
  • Programming language of your choice. See the Kid-Friendly Programming Languages and Resources for ideas.
  • Volunteer game players (10). Try to find game players who are all approximately the same age.
  • Lab notebook

Remember Your Display Board Supplies

Artskills materials poster making kit

Poster Making Kit

ArtSkills buy now button
ArtSkills supplies trifold

ArtSkills Trifold with Header

ArtSkills buy now button
ArtSkills supplies poster lights

Poster Lights

ArtSkills buy now button


Hit Boxes: How Size Affects Score

www.sciencebuddies.org/science-fair-projects/project-ideas/Games_p028/video-computer-games/hit-boxes-how-size-affects-score

Experimental Procedure

Note: This engineering project is best described by the engineering design process, as opposed to the scientific method. You might want to ask your teacher whether it's acceptable to follow the engineering design process for your project before you begin. You can learn more about the engineering design process in the Science Buddies Engineering Design Process Guide.

Working with Human Test Subjects

There are special considerations when designing an experiment involving human subjects. Fairs affiliated with Intel International Science and Engineering Fair (ISEF) often require an Informed Consent Form (permission sheet) for every participant who is questioned. Consult the rules and regulations of the science fair that you are entering, prior to performing experiments or surveys. Please refer to the Science Buddies documents Projects Involving Human Subjects and Scientific Review Committee for additional important requirements. If you are working with minors, you must get advance permission from the children's parents or guardians (and teachers if you are performing the test while they are in school) to make sure that it is all right for the children to participate in the science fair project. Here are suggested guidelines for obtaining permission for working with minors:

  1. Write a clear description of your science fair project, what you are studying, and what you hope to learn. Include how the child will be tested. Include a paragraph where you get a parent's or guardian's and/or teacher's signature.
  2. Print out as many copies as you need for each child you will be surveying.
  3. Pass out the permission sheet to the children or to the teachers of the children to give to the parents. You must have permission for all the children in order to be able to use them as test subjects.

Programming the Test Game

  1. First you need to decide what programming language you will use to make your game. The Kid-Friendly Programming Languages and Resources page has lots of suggestions. However, to do this project you will need to make sure you pick a language that allows you to modify or control hit boxes. For example, many two-dimensional games use images called sprites to represent characters and objects in the game. The hit box can be a simple shape, like a circle or a square, that surrounds the entire object, a more complicated shape that closely follows the object's outline, or a combination of multiple smaller shapes. Try searching online for "[your programming language] hit box" or "[your programming language] sprite collisions" to learn more. If you aren't sure what language to use, GameMaker is a good starting point because it has options that let you easily adjust the hit box for a sprite.
  2. Before you start your project, work through some tutorials for the programming language you chose, and make sure you are comfortable using it.
  3. After practicing, it is time to start the project. In order to test your hit boxes, build a simple test game where one object collides with another several times. An example of a test game could be where you scatter an object several places in a room, and the goal is for the player to gather as many of the objects as possible in a set time. Another could be using a hook to "catch" as many fish as possible from the ocean in 10 seconds. In this example, both the hook and fish are sprites as described in the tutorials and the ocean is a room that you build.
  4. Follow the engineering design process to build your simple program. The following list will help you to focus your efforts. Remember, if you need assistance or are troubleshooting, the website for your programming language will probably contain tutorials, help information, and forums where you can ask questions.
    1. Define the problem. In this case, you will create a simple test game for the purpose of testing various hit boxes. Refer to the Science Buddies define the problem page to help you set the boundaries for the game.
    2. Do background research. Play some other video games and figure out techniques from these games that you can use in your own.
    3. Develop the project requirements. In this case, you are building a video game that helps you test the effects of differently sized hit boxes. Refer to the Science Buddies design requirements section to get tips on how to formulate your game's design requirements. Here are some ideas to consider:
      1. What kind of game should you build? The game should be engaging for the player.
      2. What kinds of sprites will you use and where will you get them?
      3. You need sprites that are big enough to easily change the size and position of the hit box.
      4. How will you control the time the player has to finish the game—with a timer incorporated in the game's programming or an outside timer that you control?
      5. How will you count the player's score?
    4. Create and analyze solutions. Keeping your project requirements in mind, think about different ways that you could build your game. Take a look at the Science Buddies document on creating alternative solutions to guide your efforts. Once you have developed a few solutions, analyze the solutions by making rough sketches and flowcharts for each one. Refer to the Science Buddies best solution document to help you pick a working solution.
    5. Build and test a sample video game. Once you have created a set of requirements and a possible solution, it is time to open your programming environment and start working on building a sample video game. Remember to review your requirements to keep focused on the task. Review the Science Buddies prototyping document.
    6. Program your video game. Keep testing each step of the game as you work. When you have fulfilled a requirement or task, run the game and test that requirement or task out.
      1. Break the game programming down into smaller tasks so that the project is not overwhelming.
      2. Fix small issues as they come up. This will prevent your having a long set of events at the end that don't work.
      3. Once you have finished programming your game, check to see that all of the project requirements are fulfilled.
    7. Test the game. Review the Science Buddies test and redesign document to help organize your work.

Hit Box Testing

  1. Now that your video game is built, it is time to start testing the effect of varying the size and position of the hit boxes.
  2. Based on the game example given where the player is supposed to gather fish using a hook, there are many ways to explore the effect of hit box sizes. You will use the game score as a way to explore the effect of changing the hit boxes. The following procedure will give just one example (changing the hit box size of the fish), but you could also change the hit box size of the hook.
  3. Before changing the hit box, direct each one of your players to play the game for the set time with all the default hit box sizes in place. Record each player's score in your lab notebook in a table like the one shown.

Player Score
Smaller Hit Box Default Hit Box Size Larger Hit Box
       
       
Table 1. Raw data for hit box variation tests
  1. Now change the size of the hit box for the fish to make it larger. Remember that you will need to look up how to do this in your programming language. Save the changes.
  2. Ask the first player to come in, sit down, and play the game. After the set time is over, record the player's score in your lab notebook.
  3. Repeat step 5 for the additional players. Record all scores in your lab notebook.
  4. Repeat steps 4 through 6, but this time make the hit box smaller.

Analyzing Your Data

  1. Plot the data you gathered in the previous section on a scatter plot. Label the x-axis Hit box size and the y-axis Score. Mark a point for each player's score. You can also calculate an average score for each hit box size and add a trend line to your graph.
  2. Based on your graph, does varying the hit box affect the score? Which condition affects the score the most?

If you like this project, you might enjoy exploring these related careers:

NASA flight software engineer

Computer Software Engineer

Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more
artist drawing at computer

Multimedia Artist or Animator

If you've ever watched a cartoon, played a video game, or seen an animated movie, you've seen the work of multimedia artists and animators. People in these careers use computers to create the series of pictures that form the animated images or special effects seen in movies, television programs, and computer games. Read more
Computer programmer typing on a keyboard

Computer Programmer

Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more


Variations

  • Some programming environments are easier than others in which to create certain game features. Try programming your video game in both GameMaker and Scratch (or another programming environment of your choice from the table of the Science Buddies resource Kid-Friendly Programming Languages and Resources. How do the two programs compare? Which programming environment made it easier to create hit boxes in? Why?
  • Some video games use visual effects to help a player know when they have, or have not, successfully come in contact with a hit box. What are some examples of such visual feedback in the games you play? Can you create and apply helpful visual effects for the hit boxes in your game?

Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Ask an Expert

Related Links

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity