Create Projectile doesn't work in platform module?

WolfMerrik

New member
dale_coop said:
Yeah... nice script! Thanks to you.

It is turning into a nice (framework of a) script because of all of us! ;)

Thats what makes a community driven code project so awesome!
 

MrGodman

New member
i'm following this thread in real time putting the code together as i read the posts. I have to say you've helped me see (a little bit) how asm works. thanks everybody in this thread.
 

WolfMerrik

New member
MrGodman said:
i'm following this thread in real time putting the code together as i read the posts. I have to say you've helped me see (a little bit) how asm works. thanks everybody in this thread.

Thats great to hear!
I started learning bits of it from reading others code, although didn't really start learning till I just dove in.
Try it! if you mess something up, you just learn to never do that again lol
 
I think one of the main things I struggle with is what are the temps are referencing, and whenever there's a print out of "#%00000111" just doesn't make sense to me.

I have the projectiles firing, but they're not respecting my facing direction. And I look at this:

Code:
gotDirForShoot:
LDA temp3
TAY
LDA DirectionMovementTable,y
ORA temp3
STA temp3

Try as I might, I have no idea how to parse that.


EDIT: Commented that whole bit out, and the game didn't seem to miss it. Not sure what's going on now.
 

WolfMerrik

New member
The directional movement table PROBABLY isnt being used in this module, and was left over code from the adventure module (I can't check now, but I will)
You can always use the player's direction to launch the projectile?
 
So I had one of my programmer friends help me debug the problem. It took him a bit to understand what was going on, but the fact he got there is pretty amazing to me.

I(he) solved the problem, with some trouble shooting steps.

Basically, figured out the bullet was being spawned with Action Step 0 via Create Object, because changing the 00 gave my bullets some funny behavior. Knowing it was my action step that was the problem, it was easy to figure out from there that it was the fact I had "Ignore Main Physics" checked that was causing me so much trouble. Poor guy had to parse the entire code before getting to that last bit to help me with the problem.

I did learn a little, at least.
 
Code:
LDX player1_object
    LDA #$00
    STA preventShooting
    LDA Object_movement,x
    AND #%00000111
    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
LDA preventShooting
BNE +
ChangeObjectState #$03, #$08

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

LDA #$01
STA preventShooting
+
RTS

I'm still having a hard time figuring out where in the code its saying where the projectile is spawning from and how I can change it to where I want. Currently its spawning up high from my player and I want it to spawn from the eye of my Eye-Bot
 

dale_coop

Moderator
Staff member
You need to change the value on the ADC line and the SBC line, to change the position of the projectile created.
 
How exactly are those number affecting it? I've tried a bunch of different hex values and I can only seem to get it to move left or right, it wont move below the top of my players head.
 

dale_coop

Moderator
Staff member
If you want to change its position vertically, you need to affect the object_y_hi
For example, replace:
Code:
LDA Object_y_hi,x
STA temp1
By:
Code:
LDA Object_y_hi,x
SBC #$08
STA temp1
 

Lord Sharpie

New member
So is there a working projectile script I could see? I know you guys in here have figured out a bunch of stuff for it, but I'm having a hard time piecing what you've done back together to make it work in my own project. Was just curious if anyone had an example of what a complete functioning projectile script looked like. The "shootweapon" script in the Platform Module goes nowhere, does nothing, and I'm getting lost trying to get it to work... I'm just trying to get a basic Mega Man-style gun working (left and right directions only, maybe a charged-shot functionality, too)...
 

ildalla83

New member
I followed your suggestions in this thread, but I cannot build a correct movement for shooting with my character.
Is possible to have a simple tutorial to create a shooting character step by step?
tnx
 

dale_coop

Moderator
Staff member
Create your player's shooting animations, assign it to the "Action step 3" (don't forget to set an animation speed, and a "GoToFirst" for the "End of animation").
Create your projectile: the script uses the "Melee" object, set it as "player weapon", with a speed and acceleration. Also, set Edge And Solid object collision to "Destroy Me", a bounding box.
Then, use the ShootWeapon.asm script (assign it to the "Press" "A" button). Don't forget to comment the lines related to "preventShooting" (means comment lines 27, 28 and lines 35, 36), in the script.

if you need to adjust the position of the projectile...
For example, replace, vertically, you need to affect the object_y_hi, replacing:
Code:
LDA Object_y_hi,x
STA temp1
with:
Code:
LDA Object_y_hi,x
SEC
SBC #$08  ;; height pixels higher
STA temp1
Or with:
Code:
LDA Object_y_hi,x
CLC
ADC #$08  ;; height pixels lower
STA temp1
 

ildalla83

New member
dale_coop said:
Create your player's shooting animations, assign it to the "Action step 3" (don't forget to set an animation speed, and a "GoToFirst" for the "End of animation").
Create your projectile: the script uses the "Melee" object, set it as "player weapon", with a speed and acceleration. Also, set Edge And Solid object collision to "Destroy Me", a bounding box.
Then, use the ShootWeapon.asm script (assign it to the "Press" "A" button). Don't forget to comment the lines related to "preventShooting" (means comment lines 27, 28 and lines 35, 36), in the script.

if you need to adjust the position of the projectile...
For example, replace, vertically, you need to affect the object_y_hi, replacing:
Code:
LDA Object_y_hi,x
STA temp1
with:
Code:
LDA Object_y_hi,x
SEC
SBC #$08  ;; height pixels higher
STA temp1
Or with:
Code:
LDA Object_y_hi,x
CLC
ADC #$08  ;; height pixels lower
STA temp1

Tnx for the tutorial, but:
  • If I delete lines related to "preventShooting", it cannot work... I used "LDA #$00" and "STA preventShooting" on top of the script.
  • This code tutorial is perfect for idle shooting, but I also want to shoot in movement (run and jump). How can I do that?
  • If I run the game in Test mode and I try to shoot without previus movement, it create a fix projectile in the top-left corner of my character... how can avoid this situation?
 

dale_coop

Moderator
Staff member
You will not be able to have shooting animation and the jump/run animation.
(of course, you can have projectile while running or jumping... but not your specific player shooting animation)

To allow projectile while running/jumping...
Replace:
Code:
BNE +
 
 ChangeObjectState #$03, #$08

  CreateObject temp,temp1,#$01, #$00
By:
Code:
BNE +

 GetCurrentActionType player1_object
 CMP #$01
 BEQ continueShooting
 CMP #$02
 BEQ continueShooting 
 
 ChangeObjectState #$03, #$08

continueShooting:
  CreateObject temp,temp1,#$01, #$00

And for the shooting problem when no movement, at start...
Replace:
Code:
	LDA Object_movement,x
    AND #%00000111
    STA temp3
By:
Code:
	LDA Object_movement,x
    AND #%00000111
    ORA #%00000010	
    STA temp3
 

Nintend0Nerd

New member
I got it so that my character finally shoots a projectile. The only problem is that after he shoots he cannot shoot again. I can do it only once. Even if I move to a different screen. I'm not sure what's causing it.
 
Top Bottom