Create Projectile doesn't work in platform module?

DanielT1985

Member
DanielT1985 said:
dale_coop said:
Yes it’s exactly that ;)

So what about positioning the weapon? How can you do that in the shootWeapon.asm Script? Or is that even possible?

OH WAIT! I already found that you made a script to make it go lower to the player. I did that, But what about making it closer to the player?
 

DanielT1985

Member
dale_coop said:
Yes it’s exactly that ;)

So I got my character's projectile to me at the vertical position, but what about the horizontal position. When I shoot right, it's near the player but not near enough, and when I shoot left, it's far away from the player. I want it to me near my character to make it act like a fist. (The rock sprite is a placeholder, btw.)

SxwJOKo.gif
 

dale_coop

Moderator
Staff member
You need to add some code to adapt the horizontal position of the object that will be create (your weapon/projectile), depending of the facing position of your Player.
Take a look at my comments in this shootWeapon.asm script:
Code:
	LDX player1_object

	LDA Object_movement,x
	AND #%00000111
	STA temp3
	CMP #%000000010
	BNE notRightForProjShoot
	LDA Object_x_hi,x
	CLC
	ADC #$18		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing Right (a smaller value will make it closer)
	STA temp
	JMP gotDirForShoot
notRightForProjShoot:
	LDA Object_x_hi,x
	SEC
	SBC #$18		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing LEFT (a smaller value will make it closer... try a small value #$08 or #$09 or #$0A to see the result)
	STA temp
gotDirForShoot:
	LDA temp3
	TAY
	LDA DirectionMovementTable,y
	ORA temp3
	STA temp3

	LDA Object_y_hi,x
	STA temp1
	LDA preventShooting
	BNE +
	ChangeObjectState #$03, #$08

	CreateObject temp,temp1,#$01, #$00
	LDA temp3
	STA Object_movement,x

	LDA #$01
	STA preventShooting
	
+
	RTS
 

DanielT1985

Member
dale_coop said:
You need to add some code to adapt the horizontal position of the object that will be create (your weapon/projectile), depending of the facing position of your Player.
Take a look at my comments in this shootWeapon.asm script:
Code:
	LDX player1_object

	LDA Object_movement,x
	AND #%00000111
	STA temp3
	CMP #%000000010
	BNE notRightForProjShoot
	LDA Object_x_hi,x
	CLC
	ADC #$18		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing Right (a smaller value will make it closer)
	STA temp
	JMP gotDirForShoot
notRightForProjShoot:
	LDA Object_x_hi,x
	SEC
	SBC #$18		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing LEFT (a smaller value will make it closer... try a small value #$08 or #$09 or #$0A to see the result)
	STA temp
gotDirForShoot:
	LDA temp3
	TAY
	LDA DirectionMovementTable,y
	ORA temp3
	STA temp3

	LDA Object_y_hi,x
	STA temp1
	LDA preventShooting
	BNE +
	ChangeObjectState #$03, #$08

	CreateObject temp,temp1,#$01, #$00
	LDA temp3
	STA Object_movement,x

	LDA #$01
	STA preventShooting
	
+
	RTS

I replaced the code

Code:
    LDA Object_movement,x
    AND #%00000111
    ORA #%00000010  
    STA temp3
    CMP #%000000010
    BNE notRightForProjShoot
    LDA Object_x_hi,x
    CLC
    ADC #$18
    STA temp
    JMP gotDirForShoot
notRightForProjShoot:
    LDA Object_x_hi,x
    sec
    sbc #$18
    STA temp
gotDirForShoot:
    LDA temp3
    TAY
    LDA DirectionMovementTable,y
    ORA temp3
    STA temp3

With your code (fixed for my character):

Code:
	LDA Object_movement,x
	AND #%00000111
	STA temp3
	CMP #%000000010
	BNE notRightForProjShoot
	LDA Object_x_hi,x
	CLC
	ADC #$10		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing Right (a smaller value will make it closer)
	STA temp
	JMP gotDirForShoot
notRightForProjShoot:
	LDA Object_x_hi,x
	SEC
	SBC #$00		;;  <<---- HERE the horizontal offset value for the projectile/weapon when your player is facing LEFT (a smaller value will make it closer... try a small value #$08 or #$09 or #$0A to see the result)
	STA temp
gotDirForShoot:
	LDA temp3
	TAY
	LDA DirectionMovementTable,y
	ORA temp3
	STA temp3

And it worked. You're an absolute hero. I'm sorry if I sound a bit bothering, it's just I don't know a lot about the coding for these scripts and I needed some advice. I'll add you to the credits when my game gets done, as well as other members here in the NESMakers forums. Thank you so much.
 

DanielT1985

Member
dale_coop said:
Don’t worry, this community is made for that. Help each other.
I am glad if I could help you :)

It really is an honor.

Also, I managed to find a way to add sound to the projectile on my own, so I'm take steps, at least. Lol
But yeah, it really is an honor getting to talk to these amazing coders and music makers.
 

ZeGGamer1

New member
Hello.

I am trying to get projectiles to work, but i'm having some issues. When I try shooting a bullet, it always moves towards the left.

The only things I have changed with the code is adding this at the top of the shootWeapon.asm file
LDA #$00
STA preventShooting

and I created a preventShooting variable in the user variables section under project settings.

If somebody could please help me with this, that would be greatly appreciated.
 

ZeGGamer1

New member
Ok, so I fixed my issue which was that I turned on ignore main physics, but now when I shoot when I haven't moved during the game, I make a stationary bullet. This issue goes away once I move, but I don't know what is causing this problem?
 

dale_coop

Moderator
Staff member
I think it's because the player is facing down when the game starts... see this topic :
http://nesmakers.com/viewtopic.php?f=3&t=981
 
DanielT1985 said:
dale_coop said:
Yes it’s exactly that ;)

So I got my character's projectile to me at the vertical position, but what about the horizontal position. When I shoot right, it's near the player but not near enough, and when I shoot left, it's far away from the player. I want it to me near my character to make it act like a fist. (The rock sprite is a placeholder, btw.)

SxwJOKo.gif

Sweet animations!
How'd you get his hat to move slightly when he walks?
 

ZeGGamer1

New member
dale_coop said:
I think it's because the player is facing down when the game starts... see this topic :
http://nesmakers.com/viewtopic.php?f=3&t=981

Thanks, That fixed the issue. If only I could get the "Two bullets only" code working because the last time I tried doing that I messed everything up to the point of project destruction..
 

dale_coop

Moderator
Staff member
For the 2 projectiles limit, just make a backup (copy) of your NESMaker (just in case you don't success), and follow my topic:
http://nesmakers.com/viewtopic.php?p=6698#p6698
 

ZeGGamer1

New member
dale_coop said:
For the 2 projectiles limit, just make a backup (copy) of your NESMaker (just in case you don't success), and follow my topic:
http://nesmakers.com/viewtopic.php?p=6698#p6698

I tried that, and it did compile, but now I cant shoot at all. I don't know if it is something in the shooting script, but I don't know what it could be.
 

ZeGGamer1

New member
LDX player1_object

LDA limitProjectile
BNE canShootWeapon
JMP doneShooting
canShootWeapon:
LDA Object_movement,x
AND #%00000111
ORA #%00000010
STA temp3
CMP #%000000010
BNE notRightForProjShoot
LDA Object_x_hi,x
CLC
ADC #$18
STA temp
JMP gotDirForShoot
notRightForProjShoot:
LDA Object_x_hi,x
sec
sbc #$18
STA temp
gotDirForShoot:
LDA temp3
TAY
LDA DirectionMovementTable,y
ORA temp3
STA temp3

LDA Object_y_hi,x
STA temp1

GetCurrentActionType player1_object
CMP #$01
BEQ continueShooting
CMP #$02
BEQ continueShooting

ChangeObjectState #$03, #$08

continueShooting:
CreateObject temp,temp1,#$03, #$00
LDA temp3
STA Object_movement,x

DEC limitProjectile

doneShooting
RTS
 
Top Bottom