Desert

Game available in Itch.io.

Soruce code in Github.

Programming grid games in assembly for VIC-20.


Enemy types

There are two enemies: Ruk (another name for Roc, a mythological bird) who drops your life and a gigantic scorpion who damage the player and, If the player carries a flask, it breaks the flask.

Here you have the code for the Roc

  
;------------
Loc_Ruk

        jsr Loc_Empty

        ; If movement flag is set, no damage
        ldy #F_MOVEMENT
        jsr read_flag_y
        bne @Exit

        lda #str_ruk_attack
        jsr PRTSTR
        jsr CR

        lda life
        sec
        sbc #RUK_DAMAGE
        ; Less than 0 
        bcc Player_Is_Dead
        sta life
        jsr PrintLife

        ; Set movement flag
        ; So no more attacks until player moves
        ldy #F_MOVEMENT
        jsr set_flag_y

@Exit
        rts
  

Loc_Ruk checks if life drops bellows to zero and, in that case, jumps to Player_Is_Dead subroutine. This subroutine prints a message and restart the game.

Here you have the code for the scorpion. It is longer because it checks if player carries a flask.

  
;-------------
Loc_Scorpion
        jsr Loc_Empty

        ; If movement flag is set, no damage
        ldy #F_MOVEMENT
        jsr read_flag_y
        bne @Exit

        lda #str_scorpion_attack
        jsr PRTSTR
        jsr CR

        lda life
        sec
        sbc #SCORPION_DAMAGE
        
        bcc Player_Is_Dead
        sta life
        jsr PrintLife


        ; Set movement flag
        ; So no more attacks until player moves
        ldy #F_MOVEMENT
        jsr set_flag_y


        ; Destroy Flask if any
        ldy #F_FLASK
        jsr read_flag_y
        beq @Exit

        lda #str_broken_flask
        jsr PRTSTR
        
        ldy #F_FLASK
        jsr clear_flag_y
        ldy #F_FILL_FLASK
        jsr clear_flag_y
        

@Exit
        rts
  

Code us very similar to the precious enemy. You may think you to extract the repeated code. It would be a good exercise and saves memory.

A problem with flasks

There is one type of object that can be destroyed, the flasks.

If the player is carrying a flask and the player comes to a square where there is another flask, the game does not let him take it.

Changing this is not difficult. In Pursuing Tom Ram adventure, you have examples of how to do this. I have not corrected that to keep the Desert code small and simple. If player wants to waste her water going back to take a flask again, is her decision.

I have placed the scorpions (enemies that destroy flaks) away from the locs with flasks. I hope the player will not be tempted to go back.