Home Project Ideas Project Guide Ask An Expert Blog Careers Teachers Parents Students

Making It Real: Incorporating Physics in Video Games

Difficulty
Time Required Very Long (1+ months)
Prerequisites You should be comfortable programming in C++ language, familiar with the GameMaker software package, and able to program in GameMaker Language (GML). You should completely review and understand all the GameMaker tutorials and examples listed in the Science Buddies GameMaker User Guide and in the Tutorials section of YoYo Games Wiki.
Material Availability Readily available
Cost Low ($20 - $50)
Safety No issues

Abstract

Have you ever played a video game and gotten so involved that you felt as if you were living inside the game? What were the characteristics of the game that made you feel part of the action? One component of an absorbing video game is an onscreen world that makes sense—a world that takes physics into account. A game in which the player feels the effect of trudging through mud, slipping on ice, or catapulting a bird is more fun than one with no environmental interaction. In this science project, you will create a game or animation including the effects of physical principles. Have fun, because the sky's the limit.

Objective

To incorporate physical principles into a video game or animation for a more realistic experience.

Credits

Michelle Maranowski, PhD, Science Buddies

Thanks to Steve Johnson, Senior Director of Design and Web Development at LinkedIn, for valuable input on physics, animation, and video gaming.

  • Half-Life is a registered trademark of Valve Corporation.
  • Havok is a registered trademark of Telekinesys Research Ltd.
  • PhysX is a registered trademark of NVIDIA Corporation.
  • Portal is a registered trademark of Valve Corporation.

Cite This Page

MLA Style

Science Buddies Staff. "Making It Real: Incorporating Physics in Video Games" Science Buddies. Science Buddies, 15 Mar. 2013. Web. 24 July 2014 <http://www.sciencebuddies.org/science-fair-projects/project_ideas/Games_p031.shtml>

APA Style

Science Buddies Staff. (2013, March 15). Making It Real: Incorporating Physics in Video Games. Retrieved July 24, 2014 from http://www.sciencebuddies.org/science-fair-projects/project_ideas/Games_p031.shtml

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.


Last edit date: 2013-03-15

Introduction

Have you ever heard of the video game Pong? It was built and marketed back in 1972 as an electronic version of a ping-pong game. On either side of the screen are two white lines that act as the "paddles" and can be moved up and down vertically. The players use their paddles to bounce a moving circle, which acts as a ping-pong "ball," back and forth, with the object of somehow getting the ball past their opponent's paddle to score points and win the game. How the ball bounces, and the angles and trajectories involved, are all based on physical principles. This video game was among the first to use physics in its design.

The use of physics in video games has improved a lot since Pong. Physics is now playing a greater role in video game design. In 2004, the game Half-Life® 2 ushered in extremely realistic physics to video games. Today, players can immerse themselves in a game and feel as if they are playing in a real world. In fact, when the physics in a game world doesn't make sense, the player's immersion in the game can be easily broken.

But how do game developers incorporate physics into their designs? Do they struggle writing mathematic formulas in the programming language that they use to create the game? What are some common techniques used to simulate action?

First of all, game developers don't usually write complex physics formulas in their games. They rely on pre-made physics engines, or extensions, for the software package that they are using, to supply the physics for the game. An engine or extension is essentially a library of commands and functions that a developer adds to the software to accomplish different kinds of action. Two kinds of engines are used: high-precision engines and real-time engines. Scientists and developers designing computer-animated movies use high-precision physics engines because these projects need lots of processing power and time to perform the detailed calculations. Game developers use real-time physics engines because they don't require extremely detailed calculations; they need quick calculations to make a game look real for the player. Examples of physics engines that game developers use are HavokTM and PhysXTM.

Game developers have to use physics when dealing with the effects of gravity, elasticity, sound, and the interaction of light with objects. Typical physics engines and extensions employ the following techniques to address a variety of situations that depend on physical laws:

  • Collision detection. Checks for collisions and then responds to collisions.
  • Ragdoll physics. Creates animations that depict a character's death or when a character picks up a limp object.
  • Deformable bodies. Gives objects the ability to deform and shatter.
  • Soft-body physics. Allows for the simulation of hair, water, clothes, etc. The calculations here are very complex.
  • Particle physics. Allows for the simulation of phenomena like snow, rain, dust, and explosions.

Each of these techniques uses a variety of algorithms, or a list of coded instructions, to perform calculations, based on physical laws and modeling methods, to perform the simulations.

In this science project you will add a physics engine to GameMaker and use it to incorporate actions based on physical principles into a simple video game or animation of your own design. You can use a variety of physics engines made for GameMaker, such as ExtremePhysics. ExtremePhysics is a two-dimensional (2D) physics engine. This means that the physics is in two dimensions, not three dimensions, and the game must be two dimensional as well. The Mac version of GameMaker comes with the GM Physics engine, which also provides two-dimensional functionality. But whether your game is in 2D or 3D, your grasp of physics and how well you use the tools will determine how absorbing your game will be.

Terms and Concepts

  • Physics
  • Physics engines
  • High-precision engines
  • Real-time engines
  • Collision detection
  • Ragdoll physics
  • Deformable bodies
  • Soft-body physics
  • Particle physics
  • Algorithms
  • GameMaker scripts
  • ZIP file
  • Catapult physics
  • Flow chart

Questions

  • Have you played any video games that seemed unreal to you or defied physics? How did that affect your game play?
  • Can you determine the physical principle or law behind the effects that you see in the video games you play?
  • What is a graphics processing unit (GPU), and how do GPUs contribute to game play?
  • What is Newtonian physics?
  • What kinds of algorithms and modeling methods are used in the physics techniques mentioned in the Introduction?

Bibliography

The following articles discuss different techniques employed by typical physics engines:

The following sites are good resources for better understanding GameMaker and ExtremePhysics:

The following article investigates the physics of the popular Angry Birds game. It may give you some ideas that you can use in formulating your own game. At the bottom of the article are some other links related to physics and gaming that you can check out:

This article discusses physics as it is applied in the PortalTM 2 video game:

Materials and Equipment

  • Computer with Internet connection
  • GameMaker 8.1 Standard version for PCs or GameMaker 7 version for Macs. You can download GameMaker from www.yoyogames.com/gamemaker Note: At the time that this project was written, GameMaker worked better on PCs than on Macs.
  • Physics engine such as ExtremePhysics. You can download ExtremePhysics from www.maartenbaert.be/extremephysics free of charge. The Mac version of GameMaker comes with a physics engine.

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

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.

Preparing to Design Your Game or Animation in GameMaker

  1. The goal of this video and computer science project is to design a video game or animation that incorporates the laws of physics to make a realistic game for the player. You will use a physics engine package in GameMaker to incorporate physics in your game.
  2. First, purchase and download the GameMaker 8.1 Standard version for PCs or GameMaker 7 version for Macs from YoYo GameMaker. Make sure that your computer's operating system fits the requirements for running GameMaker listed on the download page. Run GameMaker in the advanced mode. Note: At the time that this project was written, GameMaker worked better on PCs than on Macs.
  3. Review scripting concepts and GameMaker Language (GML). Read the YoYo Wiki page on Scripts. Completely review and understand all of the tutorials at the YoYo Games Official Tutorials page.
    1. The YoYo Games Wiki has higher-level tutorials on a variety of topics. A tutorial that has good advice concerning this project is Guide to a Better Game Design.
    2. Also available are tutorials on drawing surfaces, transitioning from GML to C++ programming language, and on ending games.
  4. Download the ExtremePhysics physics engine from this page from Maarten Baert's website and install it in GameMaker.
    1. Download the ZIP file to your desktop and unzip it. Notice that there is a gm folder and a C++ folder. Open the gm folder and confirm the presence of ExtremePhysics.gex
    2. Open the GameMaker program. On the left menu, double click on the "extension packages" choice. You will see a window with available extension packages that come with the software in the right column.
    3. Click on the button labeled "Install," then navigate and choose the ExtremePhysics.gex. Click the button labeled "Open" at the bottom. Notice that the ExtremePhysics extension is now an available package in the right column. Select it and click the button labeled "Add." This moves the ExtremePhysics package from the "available packages" in the right column to the "used packages" column at the left. The physics extension is now installed.
  5. Devote some time to becoming familiar with ExtremePhysics.
    1. Go through all the example games that came in the ZIP file located in the gm folder. Open each example game in GameMaker and review the program code. Start by choosing an example with a title that demonstrates a concept you are interested in using in your game or animation. For example, if you are interested in learning about how to program water, choose the fluid simulation example to explore further. If you are interested in using fire and explosions in your game or animation, then open that example game.
    2. ExtremePhysics also has extensive tutorials written by the developer, Maarten Baert. Go through these tutorials, starting with the "Getting started" section, to gain more experience with ExtremePhysics.

Designing Your Game or Animation in GameMaker

  1. As noted at the beginning of this procedure, this project follows the Engineering Design Process. If you run into trouble making your game or animation, or if you feel you want more practice before starting this project, the GameMaker User Guide contains links to many other tutorials as well as links to GameMaker help documents, a wiki, and a forum you can turn to with specific questions.
  2. Define the problem. In this case, you will create a simple video game or animation that incorporates physics for a more realistic gaming, or viewing, experience for the player. Refer to the Science Buddies Define the Problem page to help you set the boundaries for the project.
  3. Do background research. Read about the history of physics in gaming and think about how physics can be used to make a game or animation better.
    1. Read the article "Evolution of Physics in Video Games" and other references in the bibliography to develop an understanding of how physics was used in games and how it is used now, and the various techniques employed for realistic simulations.
    2. Also study the YoYo Games tutorial What Is a Good Game? to start thinking about the goals of building a successful video game.
  4. Specify requirements. The project requirements are the characteristics that your video game or animation must have to be successful. In this case, to be successful, your game or animation must incorporate physical principles, resulting in a more realistic experience for the player. Refer to the Science Buddies Specify Requirements section for tips on how to formulate your game's design requirements. Here are some ideas to consider when formulating the requirements:
    1. Will you be designing a game or animation?
    2. What is the overarching concept of your game or animation? For instance, will you bounce a ball in a room? Create a bowling game? Throw bombs at a castle wall in a medieval game? Or ride a car through an obstacle course?
    3. What kinds of physical principles will you demonstrate? Bounce a ball against a wall and experiment with momentum? At what angles will the ball bounce off the wall? Roll balls on various surfaces and take friction into account? How will mud differ from grass? Or will you play with catapult physics and experiment with beam angles?
    4. What kinds of sprites (that is, images or animation) will you be using in your game or animation, and where will you get them?
    5. What are the physical actions that you wish to demonstrate throughout the game or animation? Does the physics engine you are using support these physical actions? How will you use the physics engine to enhance your game or animation idea?
    6. How much time can you spend on writing the game or animation? You need to write the game or animation and then test it. Try to manage your time wisely.
    7. How long will the game or animation last?
    8. What will be the player's goal and how will the game or animation end?

Building Your Game or Animation in GameMaker

  1. Create alternative solutions. Keeping your project requirements in mind, think about different ways that you could build your game or animation. Take a look at this Science Buddies document Create Alternative Solutions to guide your efforts.
    1. Think about different ways you could accomplish something in your game or animation. Is one simpler and still just as good? Would one solution change your original game or animation idea a little, but might end up making it better in the long run?
    2. Once you have developed a few solutions, analyze the solutions by making rough sketches and flow charts for each one. Refer to the Science Buddies Choose the Best Solution document to help you pick a working solution.
  2. Develop the solution Once you have created a set of requirements and a possible solution, it is time to open GameMaker and start working on building a sample video game or animation. After you are satisfied with the sample you create, move on to the actual programming.
    1. Build a sprite and an object and have them operate in a simple version of your game or animation. Remember to review your requirements so that you keep yourself focused on the task. For guidance, review the Science Buddies Prototyping document.
    2. Program your video game or animation and keep testing it as you work. When you have fulfilled a requirement or task, run the game or animation and test it out.
      1. Break the programming up into smaller tasks, so that the project is not overwhelming.
      2. Test the game or animation along the way so that you can 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 your game or animation, check to see that all of the project requirements are fulfilled.
  3. Test and redesign. Review the Science Buddies Test and Redesign document to help organize your work. Test your game or animation out on your family, your friends, and yourself. Take notes on what your players enjoyed and didn't enjoy about it. Use the feedback to improve your game or animation.

The Final Product: Presenting Your Game or Animation

  1. When presenting your game or animation at your science fair, try to bring in a computer. If you are not able to do so, take screenshots of your work, print them out, and mount them to a poster board.
  2. You should include the following items in your presentation:
    1. A list of your project requirements that guided your building of the video game or animation.
    2. The rough sketches or flow chart that describes how the game or animation works.
    3. An explanation of what you learned from your research and from creating a realistic video game or animation based on physics.
  3. If you would like to publish your game or animation for a wider audience to play, the Tips and Resources for Making Video and Computer Games page lists several places to do that.

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.


Variations

  • Delve deeper into the physics. Instead of using a physics engine or extension, see if you can use your GML or C++ programming skills to write some physics functions for your own physics engine.
  • If the right physics are not in a game or animation, the game world may seem unreal. To demonstrate and test this out, you can make a different version of your game or animation where the physics is not included in one or two features. How will this affect game play? Will your players notice the difference?
  • If you know another programming language, try incorporating what you learned about using physics engines into a game or animation created with that language.

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and 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

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
Female physicist working

Physicist

Physicists have a big goal in mind—to understand the nature of the entire universe and everything in it! To reach that goal, they observe and measure natural events seen on Earth and in the universe, and then develop theories, using mathematics, to explain why those phenomena occur. Physicists take on the challenge of explaining events that happen on the grandest scale imaginable to those that happen at the level of the smallest atomic particles. Their theories are then applied to human-scale projects to bring people new technologies, like computers, lasers, and fusion energy. 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

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