breakable blocks with sprite weapon

dale_coop

Moderator
Staff member
I saw your reply on the FB post... hummm...
Without any object collision it will be difficult to get the tile script executed.
(When your player is in front of the block and you use the sprite weapon, if you don’t move the player, there is no collision with the block tile... the sprite is just « drawn » next to the player object)

Have you considered to update to an object based melee weapon?
 

dale_coop

Moderator
Staff member
Or maybe modify the handle sprite weapon script to check under the drawn sprite, what tile type is... and if the breakable tile, remove it.?

Needs some tests
 

digit2600

Member
object based melee would be a pain in the ass as pretty much my whole code revolves around sprite based now... not to mention, there are a lot of different weapons to pick up...
 

dale_coop

Moderator
Staff member
Could tell me what module you are using.. Could you share your current BreakableBlock script? Also, which collision (id) are you using for the breakable tile type?
 

dale_coop

Moderator
Staff member
Ok... let's say the breakable tile type is #$0E (Tile Collision 14).

Your BreakableBlock.asm script assigned to your "Tile Collision 14" should be:
Code:
	LDA #TILE_SOLID
	STA tile_solidity
	
	;; if you want it solid, declare it at the end
	LDA Object_type,x
	CMP #OBJECT_PLAYER_PROJECTILE ;; is a projectile?  Change this is you want to use a different object #.
	BNE dontBreakThisBlock
	
	ChangeTileAtCollision #$00, underStomp
	PlaySound #SFX_BREAKABLE_BLOCK
	
dontBreakThisBlock:
(breaks the blocks with projectiles object in this case, but you could check for others objects if you have different ones).

Now for the Sprite weapon... modify the script assigned to the "Handle Sprite Weapon" in the "Project Settings > Script Settings", at the end, just after the
"skipSpriteWeaponCheck" line (it might be currently the last line of your script), add this block of code:
Code:
	;; CHECK FOR Breakable Blocks collisions
	GetCurrentActionType player1_object
	CLC
	CMP #$03	;; player currently attacking?
	BEQ +
	JMP skipSpriteWeaponCheckBreakableTiles
	+
	LDA selfRight
	SEC
	SBC selfLeft
	LSR
	ADC selfLeft
	STA tileX
	LDA selfBottom
	SEC
	SBC selfTop
	LSR
	ADC selfTop
	STA tileY
	JSR GetTileAtPosition
	LDA Object_scroll,x
	AND #%00000001
	BNE +
	LDA collisionTable,y
	JMP ++
	+
	LDA collisionTable2,y
	++
	CLC
	CMP #$0E ;; <-- HERE: the breakable tile type (for this example, I use the 14)
	BNE skipSpriteWeaponCheckBreakableTiles
	ChangeTileAtCollision #$00, underStomp
	PlaySound #SFX_BREAKABLE_BLOCK
skipSpriteWeaponCheckBreakableTiles:

This code checks if the drawn weapon (sprite) collides with a breakable tile (cf the comment "HERE" at the end for the tile type comparison). I used the type 14 for my test, so I check against #$0E.
If collision, the code executes the same code than the breakable tile script (the same ChangTtileAtCollision and the PlaySound).

I hope it will help your project.
 

digit2600

Member
Thanks dale, I'll try it out in the morning, sorry I didnt get back sooner, been all sorts of times up the past few days. I kinda got my breakable blocks working, but not perfect. I'll see if this helps.
 
digit2600 said:
Thanks dale, I'll try it out in the morning, sorry I didnt get back sooner, been all sorts of times up the past few days. I kinda got my breakable blocks working, but not perfect. I'll see if this helps.

How did you get your block to work. I am trying to make a Melee Breakable Block with Sprite Based weapons? I used the code in this thread with no success.
 
Top Bottom