Ball-throwing mechanic

Post Reply
User avatar
Bucket Mouse
Posts: 339
Joined: Wed Mar 07, 2018 2:25 am

Ball-throwing mechanic

Post by Bucket Mouse » Thu Jun 27, 2019 8:32 am

Instead of a projectile, I want the player to throw a ball.

I'm taking the path of least resistance and using as much of the original code as I can, because I know nothing of how to manipulate the physics, or how to make an object one can pick up. So I'm turning the projectile into the ball.
The one difference between a ball and a normal projectile: After the ball is thrown and hits the enemy, it stays at the impact spot until the player touches it, where they automatically pick it back up.

As far as I can tell, the projectile code is handled entirely in two ASM files: a_create_projectile.asm and HandleHurtMonster.asm. Create Projectile does everything up to setting the projectile's path in motion.
HandleHurtMonster has one line of "DeactivateCurrentObject" at the very end, marked as making the projectile disappear. So all I have to do is comment that line out to make the ball stay on the screen.

Create Projectile should have a few lines at the beginning that check to see if the ball is already onscreen, and if it is, to skip the rest of the code. There may already be a solution there. Dale wrote a code in this topic (see link):
http://www.nesmakers.com/viewtopic.php?f=60&t=2749&p=17271
It's supposed to prevent the player from firing more than two projectiles onscreen. It could easily be modified to make the limit one instead.

What I have to figure out: how to re-collect the projectile. I can't figure out where you'd put the code for that -- in the walking cycle? And what is the projectile called anyway? In Dale's code it's "MonsterCounter" but that doesn't make any sense.

Code: Select all

LDX player1_object
	LDA (WHATEVER THE NAME OF THE PROJECTILE IS)
	BNE DoNotDestroyBall
	DeactivateCurrentObject
	
	DoNotDestroyBall: 
I'm not completely certain if this is how you check if the player and an object are in the same location. Does this look right to you?

Also:

It might be possible to have the ball react when it hits an enemy by creating an Action Step that would activate on contact with a monster, playing an animation of the ball bouncing onto the ground. It also might be possible to take the Recoil script and mirror it to make the ball bounce in the opposite direction. But I don't know if those things are possible in NESMaker right now.
Post Reply