Make a Combat System for Playdate Pulp

Very new to this. I feel there is probably an easy answer to this.

I did the SquidGod tutorial (the link above) for how to have a sword on Pulp.
I want to have my character find a sword first, then have that ability.
How can do that?

In the attack script, you just need to have it check if you have picked up the sword first. If you made the sword as an item tile, the script might be something like this:

(assuming you have A as the attack button)

on confirm do
if swords>0 then
(your attack script)
end
end

It doesn’t work. Can you take a look and help me please?

you have to have "if swords==1 then" inside the confirm event.

Thanks.

I missed another detail that prevented it from working.

The devil is in the details. lol.

It works though.

I appreciate your help

Hi! In this tutorial player gets damage when enemy tile overlaps player tile. Does anyone know how to make player gets damage when enemy tile does not overlap player tile instead gives damage when it's before player tile?

Would love to know this as well. I also took the bones for my enemy script and attack from SquidGod. The enemy can disappear underneath the player. The only clue enemy is still there is the attack damage and i want an elegant way to prevent this. If i can figure something out i will post it.

1 Like

The key change needs to be in the code added at 4:54 in the video. Lines 26-29 move the enemy to the new position, and lines 31-39 check for damage.

In this case, you could do the damage check (lines 31-39) first, and then avoid moving the enemy if it would go onto the player. For example:

// Add a new variable just to track if the enemy moved on to the player
moveEnemy = 1
if newEnemyX==event.px then
  if newEnemyY==event.py then
    damage = 1
    tell event.player to 
      call "damagePlayer"
    end
    // Stop the enemy from moving
    moveEnemy = 0
  end
end

if moveEnemy==1 then
 // Now move the enemy if we didn't hit the player
  swap "white"
  tell newEnemyX,newEnemyY to
    swap "enemy"
  end
end

I haven't watched the video in full though, so not sure if I'm causing any new bugs :wink:

3 Likes