How to make monster projectile come from a specific y coordinate

ezr0913

New member
I'm trying to figure out how to make an enemy projectile come from the top of the screen. I modified the shoot straight code, but I cant seem to make it so the projectile comes from a static location on the Y axis. I basically want it to look like it's coming from the sky regardless where the enemy monster is (on the y axis). I can only get it relative to its position.

Code:
   TXA
    STA tempx
    LDA Object_movement,x
    AND #%00000111
    STA temp3
    TAY
    LDA DirectionMovementTable,y
    ORA temp3
    STA temp3
    ;get offset
    

    LDA Object_x_hi,x
    CLC
    SBC #$15

    STA temp1
    
    LDA Object_y_hi,x
    CLC
    SBC #$20

    STA temp2
    
    LDA Object_scroll,x
    STA temp
    CreateObject temp1, temp2, #$04, #$00, temp
    
    LDA temp3
    STA Object_movement,x
    LDX tempx

Any help is greatly appreciated
 

Attachments

  • ezgif-3-ca2026ef679d.gif
    ezgif-3-ca2026ef679d.gif
    22.2 KB · Views: 295

jorotroid

Member
Instead of using that temp2 with the CreateObject Macro, but put in a number for the y position you want to spawn it at. So like the very top of the screen would be #$00. The bottom of your HUD should be #$20. You can also delete the bit of code that assigns a value to temp2 since you won't be using it.

So the CreateObject call should look like this: CreateObject temp1, #$20, #$04, #$00, temp
 

ezr0913

New member
Perfect! Thank you very much! It makes a lot of sense to me now. Thanks for the simple explanation :)

I think I have everything from the temp2 deleted. This is the current code. I hope I didn't delete anything important :D

Code:
    TXA
    STA tempx
    LDA Object_movement,x
    AND #%00000111
    STA temp3
    TAY
    LDA DirectionMovementTable,y
   ORA temp3
    STA temp3
   
    ;get offset
    

    LDA Object_x_hi,x
    CLC
    SBC #$15

    STA temp1
    
   
    LDA Object_scroll,x
    STA temp
    
    CreateObject temp1, #$30, #$04, #$00, temp
    
    LDA temp3
    STA Object_movement,x
    LDX tempx
 
Top Bottom