.SpawnPlayer LDA #0 \ Spawn the player's robot (an object of type 0), JSR SpawnObject \ returning the object number of the new object in X \ and currentObject STX playerObject \ Set playerObject to the object number of the newly \ spawned object LDA #10 \ Set the player's energy level to 10 STA playerEnergy LDA landscapeZero \ If the landscape number is not 0000, jump to sply1 BNE sply1 LDA #8 \ Set (xTile, zTile) = (8, 17) STA xTile \ LDA #17 \ So the player always starts on this tile in the first STA zTile \ landscape JSR PlaceObjectOnTile \ Place object #X on the tile anchored at (xTile, zTile) JMP SpawnTrees \ Jump to SpawnTrees to add trees to the landscape and \ move towards playing the game .sply1 \ If we get here then this is not landscape 0000 LDA minEnemyAltitude \ Set A to the altitude of the lowest enemy on the \ landscape CMP #6 \ If A >= 6 then set A = 6 BCC sply2 \ LDA #6 \ So A = min(6, minEnemyAltitude) .sply2 \ By this point A contains an altitude that is no higher \ than any enemies and is no greater than 6 \ \ We can use this as a cap on the player's starting \ altitude to ensure that the player starts below all \ the enemies, and in the bottom half of the landscape \ (which ranges from altitude 1 to 11) JSR PlaceObjectBelow \ Attempt to place the player object on a tile that is \ below the maximum altitude specified in A (though we \ may end up placing the object higher than this) BCS sply1 \ If the call to PlaceObjectBelow sets the C flag then \ the object has not been successfully placed, so loop \ back to sply1 to keep trying, working through the \ landscape's sequence of seed numbers until we do \ manage to place the player on a tile \ Otherwise we have placed the player object on a tile, \ so now we fall through into SpawnTrees to add trees to \ the landscapeName: SpawnPlayer [Show more] Type: Subroutine Category: Landscape Summary: Add the player object to the landscape, ideally placing it below all the enemies and in the bottom half of the landscapeContext: See this subroutine in context in the source code References: This subroutine is called as follows: * FinishLandscape calls SpawnPlayer * PreviewLandscape calls SpawnPlayer
[X]
Subroutine PlaceObjectBelow (category: 3D objects)
Attempt to place an object on a tile that is below the maximum altitude specified in A
[X]
Subroutine PlaceObjectOnTile (category: 3D objects)
Place an object on a tile, putting it on top of any existing boulders or towers
[X]
Subroutine SpawnObject (category: 3D objects)
Add a new object of the specified type to the objectTypes table
[X]
Subroutine SpawnTrees (category: Landscape)
Add trees to the landscape, ideally placing them below all the enemies in the landscape
[X]
Variable landscapeZero in workspace Main variable workspace
A flag that is set depending on whether we are playing landscape 0000
[X]
Variable minEnemyAltitude in workspace Main variable workspace
The altitude of the lowest enemy on the landscape
[X]
Variable playerEnergy in workspace Main variable workspace
The player's energy level (in the range 0 to 63)
[X]
Variable playerObject in workspace Zero page
The number of the player object
[X]
Label sply1 is local to this routine
[X]
Label sply2 is local to this routine