ai
Seven simple ways for an enemy to move: chasing and fleeing, bouncing, wandering, following a set pattern, buzzing like a fly, switching between them at random, and swooping in a wave.
Controls
L1 and R1 choose the pattern. The directions move the player, in the patterns that have one. In attack and evade, holding circle attacks.
A port of the SCEE tutorial's chapter 8, its seven examples in one program, each a few lines of the kind most games' enemies were made of. Attack and evade step the enemy one pixel towards the player, or away, in each direction it is off by. Bounce reverses a speed at each edge of the screen. The random pattern moves one way until it meets an edge and then picks another at random. The set pattern reads its moves from a table, one a step, as a game would script an enemy's dive. The flies each move a random amount every frame, which reads as buzzing. The random states put the others behind a state the enemy changes now and then, the start of every game's state machine. And the wave swings an enemy from side to side by a sine of the frame count while it falls.
The sprites are the tutorial's own, from its SPRITES.TIM: the blue box is the player, the red box the enemy and the yellow one a fly.
Differences from the tutorial: the seven programs are one, chosen with L1 and R1; the set pattern moves every other frame where the tutorial waited an extra vertical blank inside its step; in the random states the enemy alone changes state, against a player the directions move, where the tutorial moved both boxes by turns; and the screen is 240 lines rather than 256.