Week 3


5: Player battling NPC

Adding Player Attack

  • Edit player script to add ability to attack
  • When spacebar pressed, play animation “attackDown”
  • Play game to see animation looping
  • When animation has looped, play animation “walkDown”
  • Play game to see animation stop
  • Broadcast “player attack” so NPC can receive this message

 

6: NPC taking damage

Adding NPC damage animation

  • Edit NPC script so it can receive message
  • When I receive “player attack”
  • Duplicate distance checker blocks (if distance from myself to player < 200)
  • Create new function named “damaged”
  • In damaged function, play animation “hitDown”
  • Play test, see animation keeps looping
  • When animation “hitDown” has looped, play animation “walkDown” playtest
  • After animation starts playing, set alpha to 0.5
  • In 500 ms set alpha to 1

 

7: NPC battling the player

NPC attacking player

  • On the NPC script
  • When touched get toucher
  • If toucher has tag player
  • New function “attack”
  • In function definition: broadcast NPC attack
  • Play animation attackDown
  • When animation attackDown has looped, play animation walkDown

 

8: Player's health in interface

Player health variable and textfield

  • Create number variable for Health, and textfield to display health
  • When level starts, set number health to 100
  • Create new textfield with text HP
  • Set font colour of textfield
  • Playtest

Snapping health textfield to camera

  • Constantly,
  • Set x position of instance textfield to camera x
  • Set y position of instance textfield to camera y
  • Playtest

Player receives attacks and animates

  • When I receive “NPC attack”
  • Play animation “hitDown”
  • Set alpha to 0.5
  • 500 ms, set alpha to 1
  • When hitDown has looped, play walkDown
  • Playtest

Player takes health damage

  • When hitDown has looped, set number health to number health - 10
  • Set text of textfield to
  • (try to drag number health in, won’t work)
  • Create text with
  • Number health
  • Text block “ HP”
  • Playtest

 

9: Restart when player dies

Player death

  • If health <= 0
  • Restart level
  • playtest

 

⚡ Bonus Activities ⚡


Bonus 3.1: NPCs with different strengths and weaknesses using Public Variables

 

Bonus 3.2: Variable NPC and Player damage with message values

 

results matching ""

    No results matching ""