top of page
Search

Spiders and Knights

  • seanmcgarry65
  • Mar 3, 2023
  • 2 min read

This week, two new enemies were added; the Tektite, and the Darknut.


The Tektite is a basic enemy that uses slightly more advanced movement code. Instead of walking around, the Tektite jumps left and right.


When the Tektite starts jumping, it sets the jumping variable to true, then waits between two and three seconds before changing to its jumping animation.


It then moves in an arching motion to the left or right, which is described in the code by using the custom movement behavior to accelerate at its speed towards its current position plus a pre-determined horizontal and vertical variable, setting the overall speed of that motion to its speed, and then waiting 0.5 seconds.


The custom movement is then stopped, followed by being told once again to accelerate at its speed towards its current position plus the same pre-determined horizontal variable, but -minus- the vertical variable this time.


Once that's completed, it waits another 0.5 seconds, then stops the custom movement behavior. Once it comes to a stop, the Tektite sets itself back to the idle animation, sets the jumping variable to false, and then flips the direction it will jump when it's told to jump again.


The Darknut is a tougher enemy which uses its shield to block attacks, making fighting it much more tricky than other enemies.



The above code sets the Darknut to be invincible only if the player is not attacking it from behind. If the player attacks from another angle, the Darknut's invincibility variable and the player's shield-blocked variable are both set to true.


If the player hits the Darknut with their sword while the Darknut is invincible, the player and the Darknut both have their knockback behavior enabled and are set to fly away from each other. After waiting 0.2 seconds, the Darknut's knockback behavior is disabled again.


If on the other hand, the player hits the Darknut with an arrow while it's invincible, the arrow is destroyed, and only the Darknut's knockback behavior is triggered, pushing the Darknut away from the player. Otherwise, it plays out exactly the same as if the player had hit the Darknut with their sword.


When the player is knocked back by hitting the Darknut, the code checks to see whether they've been knocked back a certain distance and if their shield-blocked variable is set to true. If both of those conditions are met, the hitflash effect is disabled, the knockback behavior is disabled, the knockback distance traveled is set to 0 again, and both the player's invincibility and shield-blocked variables are set to false.


Like the Moblin and the Stalfos, the Darknut has code that changes its animation depending on which way it's moving.


If you'd like to play the game in its current state, you can do so by following the link below.



 
 
 

Recent Posts

See All

Comentarios


bottom of page