Video Thumbnail

Sign up for a plan to instantly unlock all premium lessons.

UNLOCK LESSON

Premium Features

Download Video

Create an enemy

Here we'll create our first enemy: a small, red square that'll soon blossom into what we know today as "the goomba." Creating an enemy is not that complicated, all we have to do is create a separate class, code it so the instantiated object moves on its own, then add the necessary collision detection with our player.

We'll refactor our code along the way, creating functions to help make our conditionals as clean as possible.

Comments

Want to participate?

Create a free Chris Courses account to begin

Login
MILLAREMARK420 posted 2 years ago
hi Chris..
0
MILLAREMARK420 posted 2 years ago
Hello Chris.. I just want to ask how to not double jump, i dont like my game  jump even though the character still in the air!  and not shoot fireflower continoustly if i long press the space button. i like to shoot one at a time! can you help me please thank you in advance....
0
V
Vierus posted 2 years ago

Hey Mark, I had the same issue with the jumping and I can definitely help with that. So in your player class with the constructors, you'll add a this.jumps =0;, and a this.maxJumps = 1; then in your window.AddEventListener with the keydown, under your jump case, you'll add if(player.jumps < player.maxJumps){ player.velocity.y = -10; playerjumps++;}

Good luck with the other part!

1
MILLAREMARK420 posted 2 years ago
Hello Chris. my name is Mark... i just want to ask how to not double jump, i dont like my game  jump even though the character still in the air!  and not shoot fireflower continoustly if i long press the space button. i like to shoot one at a time! can you help me please... thank you in advance....
0

Providing the lift to launch your development career

© 2026 Chris Courses. All rights reserved.