Create Projectile doesn't work in platform module?

Post Reply
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Create Projectile doesn't work in platform module?

Post by DanielT1985 » Sat Oct 06, 2018 11:16 pm

DanielT1985 wrote:
Sat Oct 06, 2018 8:41 pm
dale_coop wrote:
Sat Oct 06, 2018 2:29 pm
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?
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Create Projectile doesn't work in platform module?

Post by DanielT1985 » Thu Oct 18, 2018 10:19 pm

dale_coop wrote:
Sat Oct 06, 2018 2:29 pm
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.)

Image
User avatar
dale_coop
Posts: 1593
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Create Projectile doesn't work in platform module?

Post by dale_coop » Fri Oct 19, 2018 9:22 am

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: Select all

	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
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Create Projectile doesn't work in platform module?

Post by DanielT1985 » Fri Oct 19, 2018 5:29 pm

dale_coop wrote:
Fri Oct 19, 2018 9:22 am
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: Select all

	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: Select all

    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: Select all

	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.
User avatar
dale_coop
Posts: 1593
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Create Projectile doesn't work in platform module?

Post by dale_coop » Fri Oct 19, 2018 8:53 pm

Don’t worry, this community is made for that. Help each other.
I am glad if I could help you :)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Create Projectile doesn't work in platform module?

Post by DanielT1985 » Fri Oct 19, 2018 9:40 pm

dale_coop wrote:
Fri Oct 19, 2018 8:53 pm
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.
User avatar
ZeGGamer1
Posts: 42
Joined: Thu Nov 29, 2018 11:26 pm

Re: Create Projectile doesn't work in platform module?

Post by ZeGGamer1 » Fri Nov 30, 2018 12:48 am

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.
User avatar
ZeGGamer1
Posts: 42
Joined: Thu Nov 29, 2018 11:26 pm

Re: Create Projectile doesn't work in platform module?

Post by ZeGGamer1 » Fri Nov 30, 2018 1:11 am

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?
User avatar
dale_coop
Posts: 1593
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Create Projectile doesn't work in platform module?

Post by dale_coop » Fri Nov 30, 2018 7:05 am

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
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
Redherring32
Posts: 201
Joined: Sat Aug 11, 2018 2:48 pm
Location: Usa

Re: Create Projectile doesn't work in platform module?

Post by Redherring32 » Fri Nov 30, 2018 7:08 am

DanielT1985 wrote:
Thu Oct 18, 2018 10:19 pm
dale_coop wrote:
Sat Oct 06, 2018 2:29 pm
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.)

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