Jump to content

April 2017 »

S M T W T F S
      1
2345678
9101112131415
16171819202122
232425 26 272829
30      
- - - - -

A C64 Game - Step 68



4: Adsense

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

Sep 19 2012 12:18 AM
Are you going to be making more games like this after?
Sep 21 2012 11:11 PM
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.
Sep 22 2012 09:36 AM
Yeah :) The graphic and music are pure gold.

The game itself is quite simple technically and pretty similar to the code here ;)
Sep 22 2012 03:32 PM
Soulless is a superb looking game!!! I love the music too!

Note: GameDev.net moderates comments.