So, the first power-up in the list (element 0 in the list) is placed at the coordinates of the twentieth ( (0+1)*20) position in the spaceship’s history, the second power-up at the fourtieth position, and so on. In Python, using enumerate when iterating through a list allows us to get the power-up’s position in the list, which can then be used to determine which position in the player’s position history to use. To achieve this effect, a power-up’s position is determined by its position in the power-ups list, with the first power-up in the list taking up a position nearest to the player. In our Gradius-like example, we need each of these objects to follow the player’s spaceship in a line, as if moving together in a single-file queue. Plotting the spaceship’s position history.Įach frame of the game, this position list is used to place each of the power-ups. Although not necessary, the following code can be added to allow you to see a selection (in this case every fifth) of these previous positions: We only need to know the spaceship’s recent position history, so the list is also truncated to only contain the 100 most recent positions. Each time the player’s position changes, the new position is added to the front of the list (as the new first element). The player’s position history will be a list of previous positions, stored as a list of (x,y) tuples. Instead, we can use list comprehension to create the power-ups: As we’ll be iterating through the power-ups stored in a list, there’s no need to create a separate variable for each. ![]() Storing the power-ups in a list allows us to perform a simple calculation on a power-up to determine its position, as you’ll see later. The first thing to do is to create a spaceship and a list of ‘power-up’ objects. As always, I’ll be using Python and Pygame to recreate this effect, and I’ll be making use of a spaceship image created by ‘pitrizzo’ from. There are a few different ways of recreating Gradius’ sprite-following, but in this article, I’ll show you a simple implementation that uses the player’s ‘position history’ to place other following items on the screen. One of the most memorable of its power-ups was the Option - a small, drone-like blob that followed the player’s ship and effectively doubled its firepower.īy collecting more power-ups, it was possible to gather a cluster of death-dealing Options, which obediently moved wherever the player moved. Gradiusįirst released by Konami in 1985, Gradius pushed the boundaries of the shoot-’em-up genre with its varied level design, dramatic boss fights, and innovative power-up system. ![]() Options first appeared in 1985’s Gradius, but became a mainstay of numerous sequels and spin-offs, including the Salamander and Parodius series of games.
0 Comments
Leave a Reply. |