{{htmlmetatags>metatag-robots=() metatag-title=(BEGIN GAMELOOP | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(Manual page for BEGIN GAMELOOP) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(BEGIN GAMELOOP | ugBASIC User Manual) metatag-og:description=(Manual page for BEGIN GAMELOOP) }} ====== ugBASIC User Manual ====== ===== BEGIN GAMELOOP ===== ===== SYNTAX ===== BEGIN GAMELOOP ==== PURPOSE ==== The command ''BEGIN GAMELOOP'' define the starting point of the game loop. A game loop is a fundamental concept in video game programming, especially in simple video games like those for 8-bit computers. Think of the game loop as the heartbeat of a video game: it is a continuous cycle of actions that are constantly repeated, giving life to the gaming experience. In simple terms, the game loop is an infinite loop in the game code that takes care of: updating the game state, checking user input (button presses, joystick movement), updating the position of objects on the screen, calculating collisions, managing enemy AI, and so on. The game loop is the place where drawing everything that needs to be displayed on the screen, based on the current state of the game. In some platforms, it will implictly "sync" the activity with the vertical blank, so the action inside the loop should be executed in a single "frame" of game. On an 8-bit computer, with limited resources, the game loop was often implemented in a very simple way, as an infinite loop. The ''BEGIN GAMELOOP''...''END GAMELOOP'' instructions create an infinite loop, so that the program would continue to execute the same instructions over and over again. Inside the loop, instructions were executed to update the game state, such as checking if a button had been pressed or if an enemy had moved. After updating the state, a routine was called to draw everything on the screen. The program would return to the beginning of the loop, ready for the next iteration. The game loop makes the game interactive, allowing the player to hit what is happening on the screen, continuously updating the state and redrawing the screen creates the illusion of movement and animation. A well-designed game loop ensures a smooth and responsive gameplay experience. ==== EXAMPLE ==== BEGIN GAMELOOP ==== ABBREVIATION ==== BeGl ==== AVAILABLE ON ==== * * Atari (400/800) * Atari XL/XE * Commodore 128 (MOS 8502) * Commodore 128 (Zilog Z80) * Commodore 64 * Commodore 64+REU * TRS-80 Color Computer * TRS-80 Color Computer 3 * ColecoVision * Amstrad CPC 664 * Dragon 32 * Dragon 64 * Thomson MO5 * Thomson MO5 * Olivetti Prodest PC128 * Commodore PLUS/4 * SEGA SC-3000 * SEGA SG-1000 * * VG-5000 * Commodore VIC-20 * ZX Spectrum 48 ==== ANY PROBLEM? ==== If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON BEGIN GAMELOOP|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]