Jump to content

  • Log In with Google      Sign In   
  • Create Account





A C64 Game - Step 68

Posted by Endurion, in C64 14 September 2012 · 966 views

Added a first version of Sams dark force, making it visible. It's not looking quite what I wanted it, but it is getting there.

Attached Image

To make things faster for removal of the beam we calc the required length and direction of the beam:

;redraw black beam
		  ldx PARAM6
		
		  ldy SPRITE_CHAR_POS_Y,x
		  dey
		  sty SAM_FORCE_START_Y
		  lda SCREEN_LINE_OFFSET_TABLE_LO,y
		  sta ZEROPAGE_POINTER_1
		  sta ZEROPAGE_POINTER_2
		  lda SCREEN_LINE_OFFSET_TABLE_HI,y
		  sta ZEROPAGE_POINTER_1 + 1
		  clc
		  adc #( ( SCREEN_COLOR - SCREEN_CHAR ) >> 8 )
		  sta ZEROPAGE_POINTER_2 + 1
		
		  ldy SPRITE_CHAR_POS_X,x
		  lda SPRITE_DIRECTION,x
		  sta PARAM1
		
		  lda #0
		  sta SAM_FORCE_LENGTH
		
		  ldx SPRITE_HELD
		  dex

-
		  lda #253
		  sta (ZEROPAGE_POINTER_1),y
		  lda #6
		  sta (ZEROPAGE_POINTER_2),y
		
		  inc SAM_FORCE_LENGTH
		
		  lda PARAM1
		  bne ++
		
		  iny
		  jmp +
		
++
		  dey
		
+		
		  tya
		  cmp SPRITE_CHAR_POS_X,x
		  bne -
		
		  ;store for later removal
		  ldx PARAM6
		  lda PARAM1
		  bne +
		
		  ;going right
		  lda SPRITE_CHAR_POS_X,x
		  sta SAM_FORCE_START_X
		  jmp ++
		
		
+
		  ;going left
		  sty SAM_FORCE_START_X
		  inc SAM_FORCE_START_X
		
++		
		  ldy SPRITE_HELD
		  dey

The beam needs to be removed once Sam stops pressing the fire button or he or his enemy dies. Aren't we glad that we already have a back buffer we can use to restore the background properly?

;restore play field from force beam		
!zone RemoveForceBeam		
RemoveForceBeam		
		  ldy SAM_FORCE_START_Y
		
		  lda SCREEN_LINE_OFFSET_TABLE_LO,y
		  sta ZEROPAGE_POINTER_1
		  sta ZEROPAGE_POINTER_2
		  sta ZEROPAGE_POINTER_3
		  sta ZEROPAGE_POINTER_4
		  lda SCREEN_LINE_OFFSET_TABLE_HI,y
		  sta ZEROPAGE_POINTER_1 + 1
		  clc
		  adc #( ( SCREEN_COLOR - SCREEN_CHAR ) & 0xff00 ) >> 8
		  sta ZEROPAGE_POINTER_2 + 1
		  sec
		  sbc #( ( SCREEN_COLOR - SCREEN_BACK_CHAR ) & 0xff00 ) >> 8
		  sta ZEROPAGE_POINTER_3 + 1
		  sec
		  sbc #( ( SCREEN_BACK_CHAR - SCREEN_BACK_COLOR ) & 0xff00 ) >> 8
		  sta ZEROPAGE_POINTER_4 + 1
		
		  ldy SAM_FORCE_START_X
		
-		
		  lda (ZEROPAGE_POINTER_3),y
		  sta (ZEROPAGE_POINTER_1),y
		  lda (ZEROPAGE_POINTER_4),y
		  sta (ZEROPAGE_POINTER_2),y
		
		  iny
		  dec SAM_FORCE_LENGTH
		  bne -
		
		  rts


So when Sam dies we modify existing code to:

		  lda SPRITE_HELD
		  beq +

		  jsr RemoveForceBeam
		  lda #0
		  sta SPRITE_HELD
+


Voilá! Carnage made more visible ;)


Previous Step Next Step

Attached Files






Are you going to be making more games like this after?
I'm already doing so, see Joe Gunn or Soulless :)

Also, on a lemon64 thread Smila (the graphician) put a few screenshots of soon to be worked on projects like Catnipped and Hyperion.
All those however are not done with code and tutorial steps like Supernatural.
Yeah :) The graphic and music are pure gold.

The game itself is quite simple technically and pretty similar to the code here ;)
Soulless is a superb looking game!!! I love the music too!

December 2014 »

S M T W T F S
 123456
78910111213
14151617181920
21 22 2324252627
28293031   
PARTNERS