Computer programs can be broken down into two categories: This post explain what is the difference between a sequential program and an event-driven program?

What is the Difference between a Sequential Program and an Event-driven Program?

Sequential Driven programs work in a sequential fashion, starting from the beginning and ending at the end. The program starts with the initial parameters. Once the program has completed its work, it will output a result. Programs that calculate PI to 10,000 decimal points, slide shows or self-running demonstration programs are examples of such programs. A procedure driven program has a clear beginning where you input your parameters and a middle where computation takes place. Finally, there is an end where you get some output.

Interactive Event Driven Programs are available and respond to your input and work in the background constantly. An Event is anything you do that interacts with the program. An Event Driven program searches for and processes events as they happen. This is an Event Driven program. It waits until I type something. It displays the letters that I have typed and advances the cursor when I do. Any of the more than 100 functions I can do at any given time include bolding words, correcting my spelling, and so on. Event Driven programs don’t know what you will do next, they respond to your actions whenever you do them.

Events driven programs can be broken down into smaller, procedure-driven programs. The program transmits the required input to the procedures. These programs then compute and output the result. For example, the word processor has procedures for getting the correct letter from the keyboard. It also stores the letter in my document, displays it in the appropriate font and moves the cursor to the next position. After waiting for me to type, the main program goes through each step sequentially, and then waits until the next event.

Sequential Event Driven vs. Simultaneous Programs

These are the most common Event Driven Programs: Simultaneous and Sequential Event Driven

Sequential Event Driven Programs sit and wait until you do something. Then, they process each event one by one. My word processor is a Sequential Event Driven Program. It processes each event one at a while. Many Windows(tm), spreadsheets, drawing programs and Adventure type games are Sequential Event Driven applications. They are action, response, action, and reaction.

Simultaneous event driven programs can handle many different events at once. The program does not rely on the input of the user to drive it. Instead, the program processes the input and changes the system state.

Simultaneous event driven programs

Simultaneous event driven programs break down time into discrete “frames”. Each frame may contain many events, some of which can be independent and others that react to user actions. Once all events have been processed, the program’s “state”, which is what the user sees on their screen, is updated simultaneously. This makes everything appear to be happening simultaneously. Once the state has been updated, time moves to the next frame and is processed.

Simultaneous event driven programs are used in most Action-type computer games, such as Space Invaders and Counter Strike. The program generates and processes many events during each frame. These events include:

  • Resetting the Virtual Screen
  • Move bots/players around
  • Animation of bots/players
  • Moving and tracking shots
  • Processing collisions
  • When they hit something, or reach their range, they will take the shots
  • Blowing things up
  • Scaling 3d/models or sprites
  • Combining sprites/models and the background, and drawing them into a Virtual Screen
  • Wrapping sprites/sprites when they reach the screen edge
  • Animation of the info bar at top of screen
  • When necessary, update the scores
  • Sound effects are played.
  • Displaying game messages, Game over, Prepare to Enter and Player 2 etc.

All games check for input from players. It simultaneously reads the alphanumeric and ctrl, alt keys, shift keys, mouse movement/click, and shift keys. These user events can be processed simultaneously by the frame:

A lot is happening behind the scenes at any one time and the player has little control over it. Simultaneous event driven programming gives your characters some parameters. Then they are sent off, but you are not always able to see where. You check on their progress every once in a while, correct them if necessary, and then you let them go to do what they’re supposed to.

Similar Posts