From a young age, I always loved playing arcade games with my brother. We would get around 20 gold coins from the cashier and spend all of it on different games. Which is why for a midterm project, I have decided to make a small arcade game called Knighthood using sprites. I am using p5play library and incorporating it to p5js using cdn. For now, I have one character called knight who stay idle, walk, jump, and attack. Although I have not implemented it yet, I am planning to make the game seem as vintage as possible. Design wise, I am also planning to incorporate a background music and movement sounds as well. For instance, there will be sound when the knight attacks or when enemies die.
As for game logic, I am planning to make 3 types of difficulties so the number of enemies change alongside their life bar. As the user chooses the difficulty, the number of enemies with different life bars will be pre loaded and will spawn in random location is set interval and attack the character. the Character will die after 3 hits.
I believe that the challenging aspect of this project will be implementing the way in which the knight hits the enemies. The condition is that the enemy should be near the knight with the margin of 10 px and the key ‘K’ should be pressed. To mitigate this problem, I am planning making boolean variable is Attacking to check if the K key is pressed and if it is pressed, checks if the enemy is nearby and if they are, they will change animation to dead state and then vanish after few seconds. Another potential problem might be the interactive problem of indicating that the knight was hit. User has to know besides the health count that the knight has been hit. For this, I am thinking of implementing knock back effect for the knight when he is hit by an enemy.
function keyPressed() { if (keyCode === 66) { // 'B' key pressed, hide instructions showInstructions = false; } if (keyCode === 87) { mySprite.setSpeed(3, 270); mySprite.changeAnimation("walk"); setTimeout(() => { mySprite.changeAnimation("stand"); }, 500); } else if (keyCode === 83) { mySprite.setSpeed(3, 90); mySprite.changeAnimation("walk"); setTimeout(() => { mySprite.changeAnimation("stand"); }, 500); } else if (keyCode === 65) { mySprite.setSpeed(3, 180); mySprite.changeAnimation("walk"); setTimeout(() => { mySprite.changeAnimation("stand"); }, 500); } else if (keyCode === 68) { mySprite.setSpeed(3, 0); mySprite.changeAnimation("walk"); setTimeout(() => { mySprite.changeAnimation("stand"); }, 500); } else if (keyCode === 13) { mySprite.position.x = width / 2; mySprite.position.y = height -100; mySprite.setVelocity(0, 0); mySprite.changeAnimation("stand"); } else if (keyCode === 32 && !isJump) { mySprite.changeAnimation("jumping"); isJump = true; mySprite.velocity.y = -8; // Set a timeout to reset the jumping flag after a short duration setTimeout(() => { mySprite.velocity.y = +5; mySprite.changeAnimation("stand"); isJump = false; }, 500); // Adjust the duration as needed } else if (keyCode === 75 && !isAttack) { mySprite.changeAnimation("attack"); isAttack = true; setTimeout(() => { mySprite.changeAnimation("stand"); isAttack = false; }, 500) ; } }