Projectile and Solid Tile Collision Glitches [Partially Solved]

offparkway

Active member
Coming across a weird problem in an adventure module game.

I can swap players, and they each have their own projectile. Seems to work just fine, but if I swap players and attack the SECOND enemy placed on the screen, more often than not that enemy will either start walking through solid tiles and cause problems... OR it will die and drop an item, but I can't pick up the item.

The problem never seems to occur with Monster 1, only Monster 2.

And the weirdest part: this only occurs after swapping player objects. If I use the default player with the default projectile, everything works fine.

I've tried so many things (changing projectile properties, removing recoil, re-placing monsters, using different types of monsters, etc), and nothing seems to make a difference.

So to sum up: Game runs fine with default player and default projectile. When I swap to another player object (with it's own projectile object), the game SEEMS to run just fine, but Monster 2 (the 2nd monster placed on a screen) acts all funky. Never Monster 1.
 
Last edited:

baardbi

Well-known member
It's really hard to say without looking at any code. But if I had to guess, it sounds like somewhere in the code the X register gets corrupted. So for example if you're creating an object and would like the X register to be the same both before and after the object is created you use the stack like this:

TXA
PHA

CreateObject .....

PLA
TAX

I would recommend double checking the player select code and the shoot projectile code to see if there's a chance the X register gets corrupted in any of those scripts.
 

tbizzle

Well-known member
Do any of your objects have 8 slots in the HUD? I had the weirdest glitching in my game, then one day I changed myScore from 8 places to 7 and all the bullshit stopped. It's a long shot but check the HUD slots, also all your update Hud element macros in the code. Could be something just needs better organized.
 

offparkway

Active member
It's really hard to say without looking at any code. But if I had to guess, it sounds like somewhere in the code the X register gets corrupted. So for example if you're creating an object and would like the X register to be the same both before and after the object is created you use the stack like this:

TXA
PHA

CreateObject .....

PLA
TAX

I would recommend double checking the player select code and the shoot projectile code to see if there's a chance the X register gets corrupted in any of those scripts.
This is definitely a possibility. It’s the only thing I could think of when I went to bed that might explain the weirdness. It’s like 2/10 times, monster 2 will destroy and drop an item as intended. The other 8 times, it will drop the item but the item gets “baked” into the screen (can’t touch it, and pick it up).
 

offparkway

Active member
Do any of your objects have 8 slots in the HUD? I had the weirdest glitching in my game, then one day I changed myScore from 8 places to 7 and all the bullshit stopped. It's a long shot but check the HUD slots, also all your update Hud element macros in the code. Could be something just needs better organized.
My HUD is a mix of madness. I use both elements & sprites, as well as some other manually-added text and stuff. I know what you’re referring to, and I’ve had to adjust for that a few times (it gets super wonky if you use 8/8 sometimes). I’ll re-look at it, and it’s a valid guess!
 

offparkway

Active member
It's really hard to say without looking at any code. But if I had to guess, it sounds like somewhere in the code the X register gets corrupted. So for example if you're creating an object and would like the X register to be the same both before and after the object is created you use the stack like this:

TXA
PHA

CreateObject .....

PLA
TAX

I would recommend double checking the player select code and the shoot projectile code to see if there's a chance the X register gets corrupted in any of those scripts.
Ok as I was going through my shoot projectile code, I forgot that I had a portion in there to limit the number of projectiles on the screen to 1 at a time. I changed the limit to 2, and so far I can't get the droppable item problem to happen again. But now with more projectiles on the screen, the game slows down. Also, Monster 2 still walked through a solid tile and caused all sorts of tile collision issues (my player could also walk through solid tiles suddenly).

here is my SHOOT PROJECTILE code, in case you see something odd that I don't:
Code:
   LDA tempPlayer
    CMP #11 ;; under water
    BNE +continueNormal ;;is not checked
        JMP canNotShoot:
    +continueNormal
    


     LDA weaponsUnlocked
     BNE +canCreateWeapon
       LDY weaponChoice
       LDA weaponChoiceTableProj,y
       AND weaponsUnlocked
       BNE +canCreateWeapon
           RTS
    +canCreateWeapon
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;END UNLOCKABLE WEAPONS
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  

;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.
;;; assumes myAmmo is in hud element 8.


    ;LDA myAmmo
    ;BNE canShoot
    ;    JMP canNotShoot
    ;canShoot:
    ;; there is ammo here.
    ;DEC myAmmo
    ;UpdateHudElement #$03 ;; change this to which element shows myAmmo.
    
    TXA
    STA temp ;; assumes the object that we want is in x.
    
    GetActionStep temp
      
    CMP #$02 ;;attack
    BNE +canAttack
    RTS
+canAttack



;;;;;Limit Projectiles;;;;;;;;
;CountObjects #%00000100, #$00 ;;; counts projectiles and limits
;CMP #$01 ;;limits projectiles to 1 at a time
;BCC +
;RTS
;+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;; Limit Object Type ;;;;;;;;;
    CountObjectType #3 ;;; rock
    CMP #1
    BCC +doShoot
        RTS
    +doShoot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ChangeActionStep temp, #$02 ;; assumes that "attack" is in action 2
    ;arg0 = what object?
    ;arg1 = what behavior?
    StopMoving temp, #$FF, #$00   
    
    TXA
    PHA
    TYA
    PHA

        LDX player1_object
        LDA Object_x_hi,x
            CLC
            ADC #$04
        STA tempA
        LDA Object_y_hi,x
            CLC
            ADC #$06
        STA tempB
        LDA Object_direction,x
        AND #%00000111
        STA tempC
        
        
        ;LDA weaponObjectTableProj,y
        ;STA tempD
                
        PlaySound #sfx_throw       
        CreateObject tempA, tempB, currentWeapon, #$00  ;;; #$01 for rock, 03 for frisbee
            ;;; x, y, object, starting action.
            ;;; and now with that object, copy the player's
            ;;; direction and start it moving that way.
            LDA tempC
            STA Object_direction,x
            TAY
            LDA DirectionTableOrdered,y
            STA temp1
            TXA
            STA temp
            StartMoving temp, temp1
    PLA
    TAY
    PLA
    TAX
    

canNotShoot:
    RTS
    
    weaponChoiceTableProj:
    .db #%00000001, #%00000010, #%00000100, #%00001000
    .db #%00010000, #%00100000, #%01000000, #%10000000
    
    
    weaponObjectTableProj:
    .db #$01, #$03, #$03, #$03, #$03, #$03, #$03, #$03

and here is my SWAP PLAYER (and corresponding weapon) code:

Code:
    LDA tempPlayer
    CMP #11 ;; under water
    BNE +continueNormal ;;is not checked
        JMP +skip_player_input
    +continueNormal

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  LDA haveDill ;;did you unlock Dill?
  BNE +
  RTS
  +
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TXA
PHA
;; first, we will store every placement informations about the player

LDX player1_object
LDA Object_x_hi,x ;; the current horizontal position
    ; CLC
    ; ADC #$04
STA tempA
LDA Object_y_hi,x ;; the current vertical position
    ; CLC
    ; ADC #$04
STA tempB
     LDA Object_direction,x ;; the current facing and movements
    ; AND #%00000111
     STA tempC

;; now, depending of the current object used by the player:
;; we can switch to the new object, or switch back the normal one

LDA Object_type,x
BNE changeIntoNormal
    LDA #15 ;; <-- HERE ! the new player object to transform into - DILL
    STA tempPlayer
        LDA #$03 ;; Frisbee
        STA currentWeapon
        WEAPON_SPRITE_0 = #$75
    JMP continueChangePlayerInto
changeIntoNormal:
    LDA #00 ;; the normal player object - JIM
    STA tempPlayer
        LDA #$01 ;; Rock
        STA currentWeapon
        WEAPON_SPRITE_0 = #$74 ;;was 75
continueChangePlayerInto:

DestroyObject ;; we destroy the current object
CreateObject tempA, tempB, tempPlayer, #$00 ;; and create the new one
PlaySound #sfx_swap


TXA
STA player1_object ;; store that new created object in the Player 1 var
STA camObject
    ; LDA tempC ;; set back the player directions
    ; STA Object_direction,x
PLA
TAX

+skip_player_input
doneSwitchingPlayer2:   
    RTS
 

baardbi

Well-known member
I looked at your code and even tried it in my Adventure test game. I couldn't recreate the problem. Do you have a lot of other custom code in your game? Specifically in files like gameTimer, doDrawSprites, doHandleObjects, doSpritePreDraw, doSpritePostDraw or anything like that.

View: https://youtu.be/qf14sngP1vw
 

offparkway

Active member
I looked at your code and even tried it in my Adventure test game. I couldn't recreate the problem. Do you have a lot of other custom code in your game? Specifically in files like gameTimer, doDrawSprites, doHandleObjects, doSpritePreDraw, doSpritePostDraw or anything like that.

View: https://youtu.be/qf14sngP1vw
I do have a lot of custom code. The game is basically finished, I just discovered these issues on my first real trial run.

So update: my default player attack had a timer of 3. The swapped player attack had a timer of 2. I changed it to 3 so they had identical settings, and I have not been able to recreate the droppables glitch since. That might’ve fixed it!

But, I found that in certain places on certain screens (in certain columns) my player will suddenly still be able to freely walk over solid tiles and off the screen if I shoot and wiggle through them. So that part is still a problem.
 
Last edited:

baardbi

Well-known member
I do have a lot of custom code. The game is basically finished, I just discovered these issues on my first real trial run.

So update: my default player attack had a timer of 3. The swapped player attack had a timer of 2. I changed it to 3 so they had identical settings, and I have not been able to recreate the droppables glitch since. That might’ve fixed it!

But, I found that in certain places on certain screens (in certain columns) my player will suddenly still be able to freely walk over solid tiles and off the screen if I shoot and wiggle through them. So that part is still a problem.
Interesting. I'll take another look at this later today. I'll let you know if I find something.
 

offparkway

Active member
Interesting. I'll take another look at this later today. I'll let you know if I find something.
I appreciate it! I think the issue with droppable objects is fixed, but I can’t for the life of me figure out why my player can wiggle through solid tiles on some screens. I posted a video of it on the FB page.
 

baardbi

Well-known member
I appreciate it! I think the issue with droppable objects is fixed, but I can’t for the life of me figure out why my player can wiggle through solid tiles on some screens. I posted a video of it on the FB page.
I see. I'm not a member of the Facebook group anymore. I deleted all my social media accounts. But from what you have mentioned here, I'm starting to think that maybe it has something to do with the monster hurt or pickup script. I did some more testing today, but so far I'm not getting the error in my test game. I'm using a default Adventure module setup from the official tutorials plus your projectile and swap script. Could you post the monsterHurt and pickup script?

By the way. You can probably enable your limit projectile code again. I don't think that has anything to do with this.

Also, if we can't find any problems with the monsterHurt or pickup script we should probably take a look at the Dill and underwater stuff. I'm guessing you have some custom code to handle those things as well.
 

offparkway

Active member
I see. I'm not a member of the Facebook group anymore. I deleted all my social media accounts. But from what you have mentioned here, I'm starting to think that maybe it has something to do with the monster hurt or pickup script. I did some more testing today, but so far I'm not getting the error in my test game. I'm using a default Adventure module setup from the official tutorials plus your projectile and swap script. Could you post the monsterHurt and pickup script?

By the way. You can probably enable your limit projectile code again. I don't think that has anything to do with this.

Also, if we can't find any problems with the monsterHurt or pickup script we should probably take a look at the Dill and underwater stuff. I'm guessing you have some custom code to handle those things as well.
Good call on the water part… you can enter the water and snorkel around, but you can only move (no attack), so I’ll test it but I might be ok there.

I did enable the limit projectiles again and I can still break through the solid tiles in one specific spot. It seems to only affect one particular column of screens near the edge, so if you’re not using the same column as I am then you probably won’t find the glitch.

Joe replied and he thinks it’s an edge/seam issue even though there’s no scrolling. But he’s out of ideas as well without looking at the game itself.

I appreciate the effort! I’m gonna look at the screen load stuff and see if I can find anything. Otherwise I’ll just figure out a workaround. 😁
 
Top Bottom