Projectiles fired before player moves have no movement

brockj

New member
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
 

dale_coop

Moderator
Staff member
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:
	FaceDirection player1_object, #%00000010	;;FACE_RIGHT
Somewhere, at the end of the "initLoad.asm" script ?
 

brockj

New member
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:
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?
 
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.
 

dale_coop

Moderator
Staff member
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:
 LDA Object_movement,x
 AND #%00001111  
 ORA #%00000010  ;;modififed to be sure to have LEFT or at least RIGHT
 STA Object_movement,x
 
dale_coop said:
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:
 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...
 

dale_coop

Moderator
Staff member
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.
 

jorotroid

Member
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:
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:
LDA #%00000010
STA Object_movement,x

Hope someone finds this useful.
 

dale_coop

Moderator
Staff member
Nice, jorotroid!
It IS useful. Yeah will add this line to my platformer game.
Thank you, man
 
Top Bottom