Jump to content

  • Log In with Google      Sign In   
  • Create Account

New Old Things

A C64 Game - Step 93

Posted by , in C64 30 March 2013 - - - - - - · 1,111 views

An addon to make the other bosses a bit stronger against Sam. Now you need to re-grab the boss after every hit you place.
Previously Sam only had to stand there and keep fire pressed. Hardly a challenge Posted Image

Attached Image

First of all, a new enemy type is added. Normal enemies stay type 1, bosses are now type 3.

Most changes are in the FireSam routine. Add in the PLAYER_FIRE_RELEASED check:
.FireSam

		  ldy PLAYER_JOYSTICK_PORT,x

		  lda JOYSTICK_PORT_II,y

		  and #$10

		  beq +

		 

		  ;not fire pressed

		  lda #1

		  sta PLAYER_FIRE_RELEASED,x

		  jmp .SamNotFirePushed

		 

+		 

		  lda #1

		  sta PLAYER_FIRE_PRESSED_TIME,x

		 

		  stx PARAM6

		 

		  lda SPRITE_HELD

		  bne .NoFireReleasedCheck

		 

		  jsr SamUseForce

		  beq .NoEnemyHeld

		 

		  ldx CURRENT_INDEX

		  lda PLAYER_FIRE_RELEASED,x

		  bne +

		  jmp .SamNotFirePushed

+		 

		  lda #0

		  sta PLAYER_FIRE_RELEASED,x
.NoFireReleasedCheck

In the enemy hurt routine we check if a boss was hurt (by checking the type). If it is, release the enemy from the force grip:
		  ;enemy was hurt

		  ldy SPRITE_HELD

		  dey

		  lda SPRITE_ACTIVE,y

		  tay

		  lda IS_TYPE_ENEMY,y

		  cmp #3

		  ;if boss, auto-release

		  bne +

		 

		  lda #0

		  sta PLAYER_FIRE_RELEASED,x

		  jmp .SamNotFirePushed

		 

+


Have fun!



Previous Step Next Step

Attached Files




A C64 Game - Step 92

Posted by , in C64 23 March 2013 - - - - - - · 1,138 views

Poor Sam was left out again. Now he can kill the boss too.

Attached Image

Since the boss is a special beast you wouldn't want Sam just to stand there and kill him without any reaction.

We add a new variable BOSS_HELD, similar to the SPRITE_HELD value.
So if SAM hurts the enemy, and it's the boss, the boss is released from Sam's grip:
		  dec SPRITE_HP,x
		  beq .EnemyKilled

		 

		  ;enemy was hurt

		  lda BOSS_HELD

		  beq .EnemyWasHurt

		 

		  ;release if end boss

		  jmp .SamNotFirePushed

BOSS_HELD is set to 1 if Sam has the boss in his force grip. We check if the sprite caught is the last boss or one of his parts:
.EnemyHit		 

		  ;enemy hit!

		  stx SPRITE_HELD

		  ldy SPRITE_HELD

		  inc SPRITE_HELD

		 

		  lda SPRITE_ACTIVE,y

		  cmp #TYPE_BOSS7

		  beq .HoldingBoss

		  cmp #TYPE_BOSS_PART

		  beq .HoldingBoss

		  jmp .NotHoldingBoss

		 

.HoldingBoss		 

		  sty BOSS_HELD

		  inc BOSS_HELD

.NotHoldingBoss


Therefore we also need to clear the bit in case the enemy or Sam is killed:
!zone KillEnemy

KillEnemy

		  ;is the enemy currently held?

		  ldy SPRITE_HELD

		  dey

		  sty PARAM4

		  cpx PARAM4

		  bne .WasNotHeld

		 

		  lda #0

		  sta SPRITE_HELD

		  sta BOSS_HELD

Obviously the boss should not move when being caught, so in BehaviourBoss7 we add an early bail out:
.NoHitBack

		  lda BOSS_HELD

		  beq +

		 

		  rts


+


The step also adds a few bug fixes, as in the boss not auto-moving the bats he spawned (as if they were body parts).

Have fun!


Previous Step Next Step

Attached Files




A C64 Game - Step 91

Posted by , in C64 16 March 2013 - - - - - - · 1,280 views

Aaaand the torso gets to fight back too, not only sit put.


Attached Image


Time to reuse existing code again. The torso will spit out bats just like the last two bossed did. SPRITE_MODE_POS is used to stop the attacking mode and revert back to movement.

A contains the number of boss parts killed (so 4 = 2 legs plus 2 arms):
		  cmp #4

		  bne +
		  ;attack with bats

		  lda SPRITE_CHAR_POS_X,x

		  sta PARAM1

		  lda SPRITE_CHAR_POS_Y,x

		  clc

		  adc #4

		  sta PARAM2

		  inc PARAM2

		  stx PARAM10

		 

		  jsr GenerateRandomNumber

		  and #$01

		  beq .NoBatLeft
		  jsr FindEmptySpriteSlot

		  beq ++

		 

		  lda #TYPE_BAT_ATTACKING

		  sta PARAM3

		  jsr SpawnObject

		  lda #0

		  sta SPRITE_DIRECTION,x

.NoBatLeft

		  jsr GenerateRandomNumber

		  and #$01

		  beq .NoBatRight
		  jsr FindEmptySpriteSlot

		  beq ++
		  jsr SpawnObject

		  lda #1

		  sta SPRITE_DIRECTION,x

++		 

.NoBatRight

		  ldx CURRENT_INDEX

		 

		  lda SPRITE_MODE_POS,x

		  cmp #20

		  bne +++

				   

		  dec SPRITE_STATE,x

		  lda #0

		  sta SPRITE_MODE_POS,x

+++

		  rts


+

That's all there is for this step Posted Image


Previous Step Next Step

Attached Files




A C64 Game - Step 90

Posted by , in C64 09 March 2013 - - - - - - · 1,036 views

And the boss got a bit more lively (visually), it was quite stiff previously. Moving body parts and the head screams (also visually) when getting hurt.

Attached Image


The boss helper code is enhanced by a routine doing circling movements:


jsr GenerateRandomNumber
and #$03
bne .DoY

inc SPRITE_MOVE_POS,x
lda SPRITE_MOVE_POS,x
and #$0f
sta SPRITE_MOVE_POS,x
ldy SPRITE_MOVE_POS,x
lda BOSS_DELTA_TABLE_X,y
beq .DoY
sta PARAM1

bmi .Left

.Right
jsr MoveSpriteRight
dec PARAM1
bne .Right
jmp .DoY

.Left
jsr MoveSpriteLeft
inc PARAM1
bne .Left

.DoY
jsr GenerateRandomNumber
and #$03
bne .Done
inc SPRITE_MOVE_POS_Y,x
lda SPRITE_MOVE_POS_Y,x
and #$0f
sta SPRITE_MOVE_POS_Y,x
ldy SPRITE_MOVE_POS_Y,x
lda BOSS_DELTA_TABLE_Y,y
beq .Done
sta PARAM1

bmi .Up

.Down
jsr MoveSpriteDown
dec PARAM1
bne .Down
jmp .Done

.Up
jsr MoveSpriteUp
inc PARAM1
bne .Up

.Done
rts


Plus a rather simple swinging table:
BOSS_DELTA_TABLE_X
!byte 0, 1, 0, 1, 1, 0, 1, 0
BOSS_DELTA_TABLE_Y
!byte 0, $ff, 0, $ff, $ff, 0, $ff, 0
!byte 0, 1, 0, 1, 1, 0, 1, 0


To make the boss' head scream we adjust its hurt routine:

;------------------------------------------------------------
;hit behaviour getting hurt
;------------------------------------------------------------
!zone HitBehaviourBoss7
HitBehaviourBoss7
lda #SPRITE_BOSS_HEAD_HURT
sta SPRITE_POINTER_BASE,x
jmp HitBehaviourHurt



Previous Step Next Step

Attached Files




A C64 Game - Step 89

Posted by , in C64 02 March 2013 - - - - - - · 1,039 views

Now you can kill the last part. Beware, it will fight back though!


Attached Image


All kind of changes are added to the boss 7 behaviour routine, as it now gets a new state. First of all, handle getting hit
;------------------------------------------------------------
;boss #7
;state = 0, 128 -> random movements
;state = 129 -> attack with beams
;------------------------------------------------------------
!zone BehaviourBoss7
BehaviourBoss7
BOSS_MOVE_SPEED = 1
          lda SPRITE_HITBACK,x
          beq .NoHitBack

          dec SPRITE_HITBACK,x
          
          ldy SPRITE_HITBACK,x
          lda BOSS_FLASH_TABLE,y
          sta VIC_SPRITE_COLOR,x
          
          cpy #0
          bne .NoHitBack
          
          ;make vulnerable again
          lda #0
          sta SPRITE_STATE,x
          lda #2
          sta VIC_SPRITE_COLOR,x
        
.NoHitBack        

          lda SPRITE_STATE,x
          beq .RandomMovements
          cmp #1
          beq +
          cmp #129
          beq +
          jmp .RandomMovements
          
+          
In AttackWithBeams we add a special case when all body parts have been destroyed:
          lda BOSS_PARTS_KILLED
          cmp #5
          bne +
          jmp FinalAttack
          
+          

FinalAttack is the meat of the new part. Shooting a beam and rotating it over the screen! (Subtly reusing existing beam helper routines)
!zone FinalAttack
.BeamStep1
          ;left arm
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM3
          lda #0
          sta PARAM1
          lda SPRITE_CHAR_POS_X,x
          sta PARAM2
          ldy #0
          jsr CheckIsPlayerCollidingWithYPosH
          ldy #1
          jsr CheckIsPlayerCollidingWithYPosH
          

          ldy #BEAM_TYPE_DARK
          lda BEAM_CHAR_H,y
          sta PARAM1
          lda #1
          sta PARAM2
          lda #0
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          lda SPRITE_CHAR_POS_X,x
          sec
          sbc #2
          sta PARAM5
          jsr DrawBeamHSegment
          rts
          
.BeamStep1End
          ;remove beam
          lda #0
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          lda #39
          sta PARAM5
          jsr RestoreBeamHSegment
          jsr RedrawItems
          rts


.BeamStep2

          lda SPRITE_CHAR_POS_Y,x
          sta PARAM2
          lda SPRITE_CHAR_POS_X,x
          sta PARAM1
          ldy #0
          jsr CheckIsPlayerCollidingWithDiagonalLLUR
          ldy #1
          jsr CheckIsPlayerCollidingWithDiagonalLLUR

          ldy #3
          lda BEAM_CHAR_NESW,y
          sta PARAM1
          lda #1
          sta PARAM2
          lda SPRITE_CHAR_POS_X,x
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          jsr DrawBeamDiagonalLLUR
          rts
          
.BeamStep2End
          lda SPRITE_CHAR_POS_X,x
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          jsr RestoreBeamDiagonalLLUR
          jsr RedrawItems
          rts

FinalAttack
          ;mode 5, 6 = left
          ;     7, 8 = diagonal left down
          ;     9, 10 = down
          ;     11, 12 = diagonal right down
          ;     13, 14 = right
          
          lda SPRITE_MODE_POS,x
          cmp #5
          bne +
          jmp .BeamStep1
+          
          cmp #6
          beq .BeamStep1End
          cmp #7
          beq .BeamStep2
          cmp #8
          beq .BeamStep2End
          cmp #9
          beq .BeamStep3
          cmp #10
          beq .BeamStep3End
          cmp #11
          beq .BeamStep4
          cmp #12
          bne +
          jmp .BeamStep4End
+          
          cmp #13
          bne +
          jmp .BeamStep5
+          
          cmp #14
          bne +
          ; .BeamStep5End
          jmp .BeamStep1End
+
          cmp #15
          bne +

          lda #0
          sta SPRITE_MODE_POS,x
          sta SPRITE_STATE,x
+          
          rts

.BeamStep3

          ;does player hit beam?
          ldy #0
          jsr CheckIsPlayerCollidingWithBeamV
          ldy #1
          jsr CheckIsPlayerCollidingWithBeamV

          ldy #BEAM_TYPE_DARK
          lda BEAM_CHAR_H,y
          sta PARAM1
          lda BEAM_CHAR_V,y
          sta PARAM2
          lda #1
          sta PARAM3

          lda SPRITE_CHAR_POS_X,x
          sta PARAM4
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM5
          stx PARAM6
          jsr DrawBeamV
          rts
          
.BeamStep3End
          lda SPRITE_CHAR_POS_X,x
          sta PARAM4
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM5

          jsr RestoreBeamHV
          jsr RedrawItems
          rts
          


.BeamStep4
          lda SPRITE_CHAR_POS_X,x
          sta PARAM1
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM2
          ldy #0
          jsr CheckIsPlayerCollidingWithDiagonalULLR
          ldy #1
          jsr CheckIsPlayerCollidingWithDiagonalULLR

          ldy #3
          lda BEAM_CHAR_NWSE,y
          sta PARAM1
          lda #1
          sta PARAM2
          lda SPRITE_CHAR_POS_X,x
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          jsr DrawBeamDiagonalULLR

          rts
          
.BeamStep4End
          lda SPRITE_CHAR_POS_X,x
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          jsr RestoreBeamDiagonalULLR
          jsr RedrawItems
          rts


.BeamStep5

          ;right arm
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM3
          lda SPRITE_CHAR_POS_X,x
          sta PARAM1
          lda #39
          sta PARAM2
          
          ldy #0
          jsr CheckIsPlayerCollidingWithYPosH
          ldy #1
          jsr CheckIsPlayerCollidingWithYPosH

          ldy #BEAM_TYPE_DARK
          lda BEAM_CHAR_H,y
          sta PARAM1
          lda #1
          sta PARAM2
          lda SPRITE_CHAR_POS_X,x
          sta PARAM3
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM4
          lda #39
          sta PARAM5
          jsr DrawBeamHSegment
          rts
Have fun and look out!


Previous Step Next Step

Attached Files







March 2013 »

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31