Projectiles fired before player moves have no movement

Post Reply
brockj
Posts: 9
Joined: Sun Sep 09, 2018 10:35 pm

Projectiles fired before player moves have no movement

Post by brockj » Tue Sep 18, 2018 2:38 am

Not sure if this is the right place or not, but here goes. A projectile fired before pressing left or right on the keyboard causes the projectile to have no movement.

I am working on a modification of the platform module and have been making very good progress. But this 'bug' has been giving me fits. Perhaps the issue is that I am using the a_create_projectile script from the adventure tutorial, but when I fire a projectile right after launching, the projectile is created, but it has no movement. If I press left or right, from that point everything works great. I was thinking the easiest solution would be to assign a default direction/movement based on starting position, which would immediately be overwritten upon pressing left or right. Unfortunately, I am not sure how to do that. I am still learning a lot about the tool and some of the initial configurations.

Thanks in advance,
Joe
User avatar
dale_coop
Posts: 5371
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Projectiles fired before player moves have no movement

Post by dale_coop » Tue Sep 18, 2018 7:52 am

It's because the player is initiliazed at startup facing down (#$00?). In a platformer game it should be better it to be left or right...
You could maybe call:

Code: Select all

	FaceDirection player1_object, #%00000010	;;FACE_RIGHT
Somewhere, at the end of the "initLoad.asm" script ?
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
brockj
Posts: 9
Joined: Sun Sep 09, 2018 10:35 pm

Re: Projectiles fired before player moves have no movement

Post by brockj » Tue Sep 18, 2018 11:22 am

Coop,
Thanks for the reply. I gave that a shot, but it didn't seem to change anything. It was helpful to know that it was loading the player facing down though. I went back and took a look at the a_create_projectile.asm script, going again line by line.

Code: Select all

notAlreadyShooting
 ;;; don't attack if already attacking.
 ;;; do we have to check for hurt here?
 ;;;;; Here, we WOULD create melee
 ChangeObjectState #$02, #$02
 LDA Object_movement,x
 ;AND #%00001111  ;;;original line
 ORA #%00000010  ;;modififed to make projectile launch at first launch
 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
By commenting out the AND #%00001111 and replacing it with ORA #%00000010 it worked, although I am concerned it is a bit sloppy. My understanding is that should assume the player facing right, my fear is that would cause issues when moving left, but from my initial testing it doesn't seem to. Any concerns you can see that this code would cause?
User avatar
Convoy_Avenger
Posts: 101
Joined: Tue Aug 14, 2018 1:42 am

Re: Projectiles fired before player moves have no movement

Post by Convoy_Avenger » Tue Sep 18, 2018 11:52 am

I'm also having this problem, but haven't tried to fix it yet. I'm using Dales shooting script, so my line to change might look different, but I'll give this a go when I get home tonight.
User avatar
dale_coop
Posts: 5371
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Projectiles fired before player moves have no movement

Post by dale_coop » Tue Sep 18, 2018 1:47 pm

Good job, brockj adding "ORA #%00000010" will work because LEFT and RIGHT are both using this bit.
But small advice, you should keep the "AND #%00001111", like this would be better:

Code: Select all

 LDA Object_movement,x
 AND #%00001111  
 ORA #%00000010  ;;modififed to be sure to have LEFT or at least RIGHT
 STA Object_movement,x
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
Convoy_Avenger
Posts: 101
Joined: Tue Aug 14, 2018 1:42 am

Re: Projectiles fired before player moves have no movement

Post by Convoy_Avenger » Tue Sep 18, 2018 10:52 pm

dale_coop wrote:
Tue Sep 18, 2018 1:47 pm
Good job, brockj adding "ORA #%00000010" will work because LEFT and RIGHT are both using this bit.
But small advice, you should keep the "AND #%00001111", like this would be better:

Code: Select all

 LDA Object_movement,x
 AND #%00001111  
 ORA #%00000010  ;;modififed to be sure to have LEFT or at least RIGHT
 STA Object_movement,x
Using your CreateProjectileWIthMovement script. Where would be a sensible place to put this in there? I've tried a couple of places I thought would make sense, but not fully understanding what the ORA is doing, maybe I'm using it wrong...
User avatar
dale_coop
Posts: 5371
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Projectiles fired before player moves have no movement

Post by dale_coop » Wed Sep 19, 2018 6:04 am

The « ORA XXX » will « add » the value to the result of the « AND YYY ». In order to be sure that the result of the binary operation contains, at least, the value XXX.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
jorotroid
Posts: 265
Joined: Wed Aug 08, 2018 7:48 pm
Location: California
Contact:

Re: Projectiles fired before player moves have no movement

Post by jorotroid » Thu Oct 04, 2018 1:33 am

Hello all, I thought that I might add my way of dealing with this issue. I was about to start a new thread, but then found this one.

There is a specific spot in the code that creates the player, so you can easily add a couple of lines after that to adjust which way you want the player to first face. In the HandleStateChanges.asm script in the Routines/System folder around line 49, you should see some code like this.

Code: Select all

CreateObject continuePositionX, #continuePositionY, #$00, #$00 ;; change this to name?
TXA
STA player1_object
After that, simply add these two lines to get the player to start off facing right.

Code: Select all

LDA #%00000010
STA Object_movement,x
Hope someone finds this useful.
User avatar
dale_coop
Posts: 5371
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Projectiles fired before player moves have no movement

Post by dale_coop » Thu Oct 04, 2018 6:27 am

Nice, jorotroid!
It IS useful. Yeah will add this line to my platformer game.
Thank you, man
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
Post Reply