There are many kinds of computer games, where you can solve puzzles, run things, jump, drive a car or play sports
Computer games work by defining a task that you have to do, and when you have completed one task, you can move on to a new task
When you make a game, you can define tasks and set rules, and you can also make a computer game using code
Images are a very important part of a computer game, and the shape of the game can help us determine whether it is for children or adults
You need algorithms in a computer game. Algorithms will determine the rules of the game and how we can win prizes or lose points
Computer games are built using code, so you'll need to write some
The basic structure of all games is the same; Built around a game loop, a game loop is a piece of code that runs tens to hundreds of times per second and tells the device what to draw on the screen
With very few exceptions, all games are organized this way. Want to make a game? You will need to type curl game
Assuming you're a healthy adult, your heart beats sixty to 100 times a minute. A computer's heartbeat is an eternity, and processor cycles are measured in billions per second
Computers are really fast, running at time scales that are outside of everyday human experience
The human eye and brain perceive images individually if only 10 to 12 are displayed per second. Start displaying images at a faster rate and the brain no longer sees the individual images but begins to perceive them as a continuous animation
Games often talk about frames per second too, but the games
don't have a movie, so where do the images come from
Like we said, computers are fast and while the previous frame is displayed, the computer quickly creates the next image
It's like the thing that paints with a paintbrush so fast you don't even notice it
The canvas that is drawn is called a frameset, and you can think of this as a large grid of pixels appearing on your screen
Now we have a general feeling that the games are more like the movies and show a lot of images to give a sense of the action
The subtleties of how the update function is called and how it tells the frame buffer to update are often handled by libraries such as SDL and OpenGL or an engine such as Unity or Unreal
The basic idea is that when this refresh loop runs, it refreshes the image on the screen. The game calls this loop 30 or 60 times per second
If the update tries to do too much, the game will feel sluggish because the refresh rate will not be stable
Games are more than just graphics, graphics are expensive and any game takes up to 60% of the frame time on graphics alone, which means the rest of the game needs to fit in the rest
This means that if the game is running at 60fps, there are only 0.005 seconds to deal with everything else in the game
The game only needs to refresh the screen every 12 seconds to trick the brain into seeing continuous motion but it is more normal to use 30 or 60 frames per second
The higher the frame rate, the smoother the animation appears and the more comprehensively the brain is satisfied with it