Projectile Direction help?

crazygrouptrio

Active member
I have 2 shooting positions for my shoot script. It shoots correctly for the standing position but for the crouch position the projectile flies off diagonally. I have the source position set up correctly for the down position (as you can see the bullet spawns in the correct place at least) This is beyond my understanding I think... :?

Also my projectiles disappear at the screen edge, and for a scrolling platformer that is kind of a problem. I don't have much experience with scrolling games yet.

giphy.gif


Here is my shoot script:
Code:
	LDA gameHandler
	
	AND #%00100000
	BEQ canShoot
	JMP doneShooting
	
	
canShoot:
	LDX player1_object
	    CPX player1_object
   ; BNE +
    LDA gamepad
    AND #%00010000 ; if up is pressed
    BNE ++
    JMP +
    
    +
	LDA gamepad
	AND #%00100000 ; if down is pressed
    BNE ++
    JMP doneShooting
    
    ++
	
    CountObjects #%00000100, #$00   ;; count player weapon on screen
    LDA monsterCounter              ;; the variable used to count is monsterCounter
    CLC
    CMP #$01        ;; compare to 1
    BCC +       ;; if less than 1 on screen we can create a projectile
    RTS         ;; else we quit
    +
    ; Up was pressed
	


	
	;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines: 
	;;; check if already shooting (assuming the shoot action step is 05)
	GetCurrentActionType player1_object
	CMP #$06
	BNE notAlreadyShooting
	JMP wasAlreadyShooting 
notAlreadyShooting
	;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line: 
	;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
	ChangeObjectState #$05, #$02
	
	GetCurrentActionType player1_object
	CMP #$05
	BNE ++
    JMP doneShooting
	++
	
	;;; if you want your player stops when he's shooting, comment out the following lines:
	LDA Object_movement,x
	AND #%00001111
	STA Object_movement,x
	LDA #$00
	STA Object_h_speed_hi,x
	STA Object_h_speed_lo,x
	STA Object_v_speed_hi,x
	STA Object_v_speed_lo,x
	
;; if was already shooting
wasAlreadyShooting:

	LDA Object_movement,x
	AND #%00000111
	STA temp2
	TAY

	LDA Object_x_hi,x
	SEC 
	SBC #$08 ;; width of projectile 
	STA temp
	LDA Object_scroll,x
	SBC #$00
	STA temp3

	LDA temp
	;;; offset x for creation
	CLC
	ADC projOffsetTableX,y
	STA temp
	LDA temp3
	ADC #$00
	STA temp3

	LDA Object_y_hi,x
	CLC
	ADC projOffsetTableY,y
	sec
	sbc #$08 ;; height of projectile
	STA temp1	
	
	
    CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
  
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x
	
    ;PlaySound #SND_SHOOT
doneShooting:
	RTS
 

dale_coop

Moderator
Staff member
There's is an error with the Down-Left projectile direction in NESmaker.
To fix that, modifiy the "MainASM.asm" in your "Routines\Basic\" folder (if your ROOT is "Routines\Basic\"), around the end of the script, you will find:
Code:
directionTable:
	.db #%00110000, #%11110000, #%11000000, #%11100000, #%00100000, #%10100000, #%10000000, #%10100000
Change the last number for:
Code:
directionTable:
	.db #%00110000, #%11110000, #%11000000, #%11100000, #%00100000, #%10100000, #%10000000, #%10110000 ;; <<-- fixed the down-left
 

dale_coop

Moderator
Staff member
Ok..
You could try modifying your script, line 69, you have:
Code:
	STA temp2
Replace that line with:
Code:
	;;STA temp2
	CMP #%00000100
	BCC +
	LDA #FACE_LEFT
	STA temp2
	+
	LDA #FACE_RIGHT
	STA temp2
	++
It could work...
 

dale_coop

Moderator
Staff member
Ok... sorry... not easy without your settings/scripts...
Could you share your project? (I'd need the .MST file and the GraphicAssets and GameEngineData folders... zipped)
 

dale_coop

Moderator
Staff member
Oh wait, I see a mistake in my code...
Try this:
Code:
	;;STA temp2
	CMP #%00000100
	BCC +
	LDA #FACE_LEFT
	STA temp2
	JMP ++
	+
	LDA #FACE_RIGHT
	STA temp2
	++

I added a "JMP ++"
 

crazygrouptrio

Active member
Hmm that does fix the direction but when crouching the projectile still comes from the standing position and not the lower one.
 

dale_coop

Moderator
Staff member
OK...
In the B_GunStance.asm script, replaace the:
Code:
	LDA Object_movement,x
	AND #%00000111
	STA temp2
	TAY

With:
Code:
	LDA Object_movement,x
	AND #%00000111
	;;STA temp2
	TAY
	CMP #%00000100
	BCC +
	LDA #FACE_LEFT
	STA temp2
	JMP ++
	+
	LDA #FACE_RIGHT
	STA temp2
	++

Almost same as I wrote before... just the "TAY" is not at the same place ;)
(and it's important for the projectile source offset)
 
Top Bottom