mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 22:58:36 +00:00
4108f86177
* Changed database implementation. Removed static objects. * Fix Logs * Fix 40 errors from checkstyle plugin run. 139 left)) * Fix CacheStore errors from checkstyle plugin 107 left * Fix last errors in checkstyle. * Fix sonar issues * Fix issues in VALIDATE phase * Fix Bug with mongo connection. Used "Try with resources" * Add test * Added docker-compose for mongo db. MongoDb db work fixed. * Provided missing tests * Comments to start Application with mongo. * Fix some broken links * Remove extra space * Update filename * Fix some links in localization folders * Fix link * Update frontmatters * Work on patterns index page * Work on index page * Fixes according PR comments. Mainly Readme edits. * fix frontmatter * add missing png * Update pattern index.md * Add index.md for Chinese translation * update image paths * update circuit breaker image paths * Update image paths for localizations * add generated puml * Add missing image * Update img file extensions * Update the rest of the EN and ZH patterns to conform with the new website Co-authored-by: Victor Zalevskii <zvictormail@gmail.com>
34 lines
1.7 KiB
Markdown
34 lines
1.7 KiB
Markdown
---
|
||
title: Update Method
|
||
category: Behavioral
|
||
language: en
|
||
tags:
|
||
- Game programming
|
||
---
|
||
|
||
## Intent
|
||
Update method pattern simulates a collection of independent objects by telling each to process one frame of behavior at a time.
|
||
|
||
## Explanation
|
||
The game world maintains a collection of objects. Each object implements an update method that simulates one frame of the object’s behavior. Each frame, the game updates every object in the collection.
|
||
|
||
To learn more about how the game loop runs and when the update methods are invoked, please refer to Game Loop Pattern.
|
||
|
||
## Class diagram
|
||

|
||
|
||
## Applicability
|
||
If the Game Loop pattern is the best thing since sliced bread, then the Update Method pattern is its butter. A wide swath of games featuring live entities that the player interacts with use this pattern in some form or other. If the game has space marines, dragons, Martians, ghosts, or athletes, there’s a good chance it uses this pattern.
|
||
|
||
However, if the game is more abstract and the moving pieces are less like living actors and more like pieces on a chessboard, this pattern is often a poor fit. In a game like chess, you don’t need to simulate all of the pieces concurrently, and you probably don’t need to tell the pawns to update themselves every frame.
|
||
|
||
Update methods work well when:
|
||
|
||
- Your game has a number of objects or systems that need to run simultaneously.
|
||
- Each object’s behavior is mostly independent of the others.
|
||
- The objects need to be simulated over time.
|
||
|
||
## Credits
|
||
|
||
* [Game Programming Patterns - Update Method](http://gameprogrammingpatterns.com/update-method.html)
|