⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Saturday, November 8, 2025

Code Mario in JavaScript with Kaboom.js!

 

0:00

hey everyone and welcome to this tutorial in which i'm going to show you how to build mario using javascript but

0:07

more specifically a javascript library designed especially to make javascript game development a

0:13

whole lot easier i'm talking about kabum js now if you watch free code camp you

0:19

would have seen i've actually made a course a kaboom js in it i also make a

0:25

game of mario however it is made in the replit environment um if you haven't seen the replica

0:31

environment it is a replica it is an environment uh that actually has been pre-configured

0:37

for kaboom and it has some really cool features like you can make the sprites directly in the ide so you can literally

0:44

draw them uh and some other cool stuff too however for this tutorial i'm going to be showing you how to use kaboom j as

0:50

completely from scratch in your code editor of choice so for this video i'm

0:56

going to be using uh vs code uh even though that might be changing soon

1:01

uh so yeah let's do it i hope you're ready by the end of the tutorial you

1:07

will have a game that looks like this we are only gonna be building two levels

1:12

uh because i do think that once you have two you really do have the knowledge to go on and go forth and make as many as you wish

1:20

so what are we waiting for as always please do give me that like and that sub as this really is the way that i can

1:27

carry on to create more content for everyone here so let's do it

1:35

okay now it's time to build some mario once again in this game we're going to

1:41

have two levels so let's get to it once you have the knowledge to build these two levels you

1:47

are more than free to carry on and keep creating more and more levels for your mario game or any game that you

1:54

wish so let's get started i have started by just making an index.html and game.js

2:02

file so the index.html file just has some standard boilerplate please feel free to take

2:10

this we have the title and that's really uh going to show up in the tab of our

2:16

browser um we are going to head over to kaboom and just grab this script

2:24

right here so this one like so and just paste it at the bottom of our file

2:32

we next need to link the javascript file so the games.js file now we

2:39

could in theory so similarly to here just have two

2:45

script tags so one script tag like so and then put all of our kaboom

2:53

js code in here or we could just link directly to the game.js file to keep our

3:00

javascript separate so it's up to you i'm gonna choose to keep it separate so i'm just going to

3:08

link it by getting the file name like so as it's in the root of my project i just

3:14

have to grab the file name great

3:20

let's carry on before we move on i can actually apply some styling in

3:25

here so this is the equivalent for those of you who know about css this is the equivalent of me just doing a

3:32

style in here and i just want the body itself to have a margin of zero to get rid of the

3:39

white border and i'm also going to prevent it from scrolling by putting overflow hidden

3:47

okay so there we go that's just a tiny bit of styling i'm not gonna start my own style sheet

3:53

for it because it is just that but of course if you'd rather do that that is totally

3:58

up to you oops we need to put that in the header

4:04

so good thing that i noticed that let's put that in the header

4:12

okay i'm just gonna format this a little bit nicer before we move on

4:21

cool so now let's head over to our game.js file and this is where the magic is

4:28

going to happen okay we're going to initialize kaboom just like so we're going to get our

4:34

curly braces i'm going to put global as true and then i'm going to put full

4:40

screen as true as well like so and give it a scale of one and put debug

4:48

as true so we can see when something goes wrong and try and debug it great

4:55

the next thing we want to do is add our game scenes so i'm going to use scene like so let's call it game and i'm going

5:02

to pass it through a level and a score but for now i'm not going to i'm just going to leave it like that

5:07

and then let's start okay so let's go control copy path and just

5:16

post it in our browser just like so now let's just make the

5:22

background black so this will give me blue actually so if i

5:28

refresh this that will be blue and if i want it to be black that will give me a black background

5:35

like so okay so now let's carry on

5:42

the next thing i want to do is uh start off with some layers and these layers so let's get on an

5:48

array i'm gonna have a background let's also have the object layer

5:53

as a default and then the ui layer and because it's a default i just need to put object here

6:00

like so now let's get to drawing out our maps so for that we're

6:06

gonna have to you guessed it load in some sprites so just up here is where i'm gonna be

6:13

doing that load sprite and let's get to it so let's move over to

6:20

our imager page this is where i'm going to store all my images you are more than welcome to

6:26

take them of course if you want to please feel free to also make your own that is half the fun so

6:34

let's go ahead and find a coin

6:41

so here are my mario brothers brothers ones that is the coin i made these ones a bit smaller

6:48

just because the game is a bit bigger so these are going to be 20 by 20 pixels

6:53

each but i'm going to show you how you can scale it up if you wish so let's do load sprite uh let's do

7:00

coin and let's just get i'm going to make this the route so

7:07

delete that and just use this like so and we can load the route

7:15

so essentially that is the whole path i'm loading the root and then we have this little uh extra bit to get to our

7:23

coin so we've got a coin what else do we need um well we need an evil

7:31

shroom for sure so let's get an evil shroom there we go

7:39

let's get shareable link let's copy that and i'm just going to paste it here like

7:45

so there we go we've got our evil shroom

7:52

let's load sprite uh this time let's get a

7:58

brick let's find a brick so here we go

8:05

get shareable links i'm going to copy that i'm just simply going to paste it like

8:10

so

8:18

we've got our brick now let's get a block so once again

8:26

let's find our blocks this is a block a shareable link copy

8:34

that and just paste it in here

8:46

let's get mario so once again let's find our little

8:52

mario

8:59

get shareable link copy just paste it in here

9:09

there we go we've got a mario now let's get a mushroom

9:32

copy the link paste in the link for a mushroom

9:41

now let's get a surprise block surprise

9:49

let's also have an unboxed so i'm just gonna do a few of these now like an

9:56

unboxed block and then i'm just gonna have pipe top

10:04

left pipe top right

10:12

pipe bottom left and pipe bottom

10:21

right okay great so let's go and get this now we

10:26

need the surprise it's this one get a shareable link copy

10:36

just paste that in here

10:41

now let's get the unboxed so once again i'm gonna get shareable link

10:46

copy paste that in here

10:54

let's get the pipe top left

11:00

get shareable link copy paste that here

11:11

let's get the pipe top right so that is this one get shareable link copy

11:26

let's get the pipe bottom left which is this one get shareable link

11:33

copy oops do that again copy

11:44

paste and get the pipe bottom right

11:53

control link and fantastic we are now ready to start making our

12:00

board so i'm just gonna make this smaller as we don't really need it for

12:05

now okay so now let's actually create our game board

12:10

i'm going to call it a map like so and i am just simply going to create a

12:17

map so let's make it one let's make a few of these and then let's

12:25

maybe start with the bottom one first so i'm just going to go like this and then let's have the floor

12:34

a few of these and then let's have like a

12:42

way that you can fall down and i'm just going to space these out so

12:48

essentially these equal signs are going to equal the bottom of my um game

12:56

and these are going to be the constraints of my game and then let's just put some

13:03

commas here this will all make sense in a bit of

13:09

course if you've watched the zelda tutorial then you already know what is happening here now i need to actually

13:18

assign this equal sign a sprite so let's do that here

13:24

once again just like we did in zelda i'm going to say level config and let's open up some curly

13:31

braces like so and then let's say that every sprite on my board is going to have a width of 20

13:37

pixels and a height of 20 pixels

13:42

now let's define each object as a list of components so we already know we've got an equal

13:48

sign on there and i want my equal sign to essentially be the sprite of block

13:56

so you'll recognize the block from above here we go the block that we imported

14:02

for us to use in our javascript file and then let's make it solid so we

14:07

need to write solid like so and let's add it to the game

14:15

level so const game level

14:20

equals ad level that is a kaboom method and then let's just pass through

14:26

the uh first level so let's pass through the map and then the level config

14:42

great so now if we go back here and refresh

14:48

there we go there is our mario game started even though this

14:55

isn't the one i wanted let's change block to

15:07

this one right here so get shareable link copy that and i'm just going to remove

15:13

block and change it because that is the unboxed one that i got wrong um

15:20

i want this to be a block that looks like this instead please

15:28

so now let's go back to here and there we go that is looking great we can of course

15:34

zoom in if we think this is too small or i can use scale to in order to make everything

15:42

bigger okay so it's totally up to you how you would like to do that i'll keep

15:48

it like this for now but i might make it a little bit smaller as we carry on coding so we've got the bottom

15:56

blocks what else do we want to add well let's make the uh dollar sign let's make this a

16:04

coin i think that should be fun so let's make the coin

16:11

two three around here

16:17

we'll put a little coin here and then let's perhaps also have some

16:24

more blocks up here so i want to block up here and then i also want a mushroom here so i think that's what i

16:32

wanted a mushroom and then another block and then

16:38

let's make another coin here and then another block and then i'm also gonna

16:45

have some evil shrooms so on the bottom level i'm going to have a shroom here

16:51

and a little shroom just right

16:57

here great now while i'm at it i'm also going to

17:04

have my uh pipe here so that is going to be the bottom of the pipe and i'm also

17:09

going to have the top of the pipe like so okay so now let's actually

17:16

tie this up so it looks more like a grid and now let's start assigning values to

17:22

all of these so sprite we said this one we want this to be a

17:28

coin um so that looks good i don't want to make the coin solid

17:34

let's also we wanted this to be a surprise block so sprite

17:45

surprise and this surprise is gonna have

17:51

a coin so let's make this solid like so and then

17:57

let's call this coin so price

18:02

cool so we've got a coin surprise let's have another surprise and this time this is going to be a

18:08

mushroom surprise so like so and then just call this

18:13

give the tag of mush room surprise

18:22

okay next let's have an unboxed

18:31

so i'm just going to add the unboxed for now even though we won't use it yet um so sprite

18:40

unboxed like so and then also let's make it solid

18:49

what else do we need is the pipes so [Music] let's make this

18:57

pipe

19:03

left make it solid and then

19:12

pipe right solid again and then let's have pipe top

19:22

left because that's what i've called it pipe

19:27

top left and then bottom left pipe

19:37

bottom right

19:45

and then we also need pipe top right so let's do that here pipe top

19:53

right and let's see how that looks so now refresh and there we go now these are looking a

20:01

bit big so i can also scale that in here i could use scale 0.5

20:08

to make sure that they are the same size as everything else in our game so that is

20:14

just another trick if something is too big for your game

20:22

okay you can do any scaling of images right in here

20:28

so there we go cool i think the last thing we need to do is add some evil mushrooms before we start adding pacman

20:37

um so let's go ahead and do that the evil mushrooms well i said they

20:44

were this on our game board this little hat so let's put evil what do we call

20:51

lit evil shroom

20:58

let's make it solid and we don't want to scale it as we are happy with it as it is and then i'm actually also

21:06

going to add a mushroom for now even though you won't see it on here let's make the mushroom for the

21:11

future a hash tag like so and just say mush

21:19

okay cute okay so i think the next thing for

21:27

us to do now is to go about adding mario so

21:34

const player and i'm going to use the kaboom method of add i'm going to open

21:41

up our array i'm going to use sprite to add mario to um our game board so i've

21:50

assigned this all to the const player so we can use it in our javascript later on so there we go and now

21:58

i want to actually give it a position on our board so at like a starting

22:04

position so i'm just going to do pause and then pass through 30 and 0 like so now i actually could make

22:13

mario for gravity just by passing through body like this okay and i'm gonna do origin

22:21

bot as well just to get rid of any funny things when we use body

22:28

so just make sure to do that so there he goes he is falling

22:35

onto the blocks because the blocks are solid so stopped so whoo

22:42

there we go now let's actually make our pac-man move

22:47

by attaching him to keyboard events so i'm going to go back here and

22:53

actually perhaps let's add these score first so let's do that

22:58

so i am going to add the score like this i am simply going to use add to

23:05

add some text so let's um just use whatever the

23:12

score is as the text and then let's position it on our grid

23:18

so i'm going to position it in the left hand corner and then i'm going to add it to

23:23

the ui layer okay because we have stuff this is the everything at the moment is on the

23:28

object layer as the default this is the first time i'm actually using the layers and i want to add this

23:34

to the ui layer okay so it's not going to interfere with anything that's happening in our game essentially and the next

23:41

thing i want to do is just add a value of score

23:49

cool i'm actually going to save this as something so let's save this as a score label so

23:54

we can pass it on to the uh next levels as well

24:00

like so cool and i'm also going to add some text

24:06

uh so let's do add

24:13

add text just so we can see what level we are

24:18

actually on it doesn't really matter for now because we don't have any levels we just have the one so i'm just

24:24

going to put tests like so and give it a position of again just put

24:32

it close to the score is not defined oops i knew that so

24:40

um for now i'm just going to put test again

24:47

test okay so there we go

24:54

that's all i have done for now great now the next thing i said i want

25:01

to do is actually attach event listeners to our player so let's do it okay

25:09

so for this i'm going to use key down so that is a kaboom method key down and then if

25:16

i press the left so the keyboard with the left arrow on my keyboard well i want this to happen

25:22

so let's write a function so we pass through the first parameter is left for the left arrow on our

25:28

keyboard and the second parameter is a function and that is what we want to happen essentially if we press

25:34

left i'm going to grab the player i'm going to use move to move our player at a speed

25:41

so let's just space we want the speed to be 120 that is the x-axis as the y-axis

25:48

i can even say this as const move speed just to make our lives easier

25:56

so i'm going to put move speed and of course because we're going left i'm going to put a minus so if

26:03

i do the same for key down right and get rid of the minus we should

26:09

be able to move right and left and while we're here i'm just going to do jumping as well so let's do key press

26:16

this time and then space so whenever i press the

26:21

space bar and what do i want to happen well let's write a function

26:28

so if this time because we do use the body

26:34

component i can use if player is grounded like so and only if the player is grounded

26:42

well then we can make the player jump and let's have a jump force

26:50

so const jump force um

26:57

i'm just going to make this 10 for now and i'm actually going to move this up to the top of our file because it makes sense too

27:05

so i'm going to put it up here and click save now let's see so i can go left i can go

27:11

right and if i press space bar oh well nothing happens i actually think

27:20

our junk force is too small so let's just do 360.

27:26

there we go so just enough to jump but not enough to jump onto the next one

27:32

without getting big let's solve how to do that next

27:43

okay so i'm actually just gonna do it up here

27:49

write a function big there's a timer here as well

27:55

um and currently let is big it's gonna be false

28:02

i'm going to return

28:07

updates if is big

28:16

well i want timer and this is delta time

28:25

this is a kaboom method once again if i show you what that is it

28:31

is the delta time since the last frame

28:38

and if timer is smaller than or equal to zero so if our times run out we wanna

28:45

make mario small again so if we had a pass

28:51

through this as a component onto mario this should apply all of this to mario or in fact any um

28:59

sprite that we wish so [Music]

29:06

it's big return it's big and then

29:15

small lithify this scale equals

29:24

vac one timer equals zero and then put

29:40

is big back to false okay so we've got smaller phi now we

29:47

need bigger five big five and well you guessed it it's basically all

29:54

of this but we need to make him bigger um

30:00

so let's make it by two timer equals new time and as big is

30:08

true and whatever we pass through into big phi is going to be the time

30:16

okay so now that i have that i'm just gonna

30:23

like i said put the component on mario like so so i'm literally just

30:29

grabbing what we wrote and putting it on

30:34

mario okay cool now

30:41

what do we want next i think let's actually get some mushrooms sprouting

30:48

so let's go ahead and do that now so right under here

30:56

um i want to grow a mushroom so we're going to grab the player and if

31:02

the player head bumps

31:07

um i'm gonna pass through an object if the object that he head bumps so if

31:15

object is coin sir

31:20

prize so anything with the tag of coin surprise well

31:29

then i'm gonna grab the game level and i'm going to spawn i want to spawn

31:41

a coin because it's a coin surprise he's bumping something with a surprise but

31:46

it's got the tag coin surprise so we want a coin to show up

31:52

so let's spawn a corn coin spawn a coin um and then let's put the coin next so

32:00

we're gonna grab the object that we just bumped heads with and then we're gonna put the coin above

32:05

it so this is how you would do that and then i'm gonna destroy the actual

32:11

object that we head bumped with like so okay

32:16

so that is it let's try that so this is this has got the tag coin

32:22

surprise i think so anyway oh there we go that one did cool

32:27

so great the we destroyed the object and we've got a coin spawning now i actually want to

32:34

add the unboxed uh sprite so once again i'm going to grab the game

32:40

level and use spawn but this time to spawn something else i want to spawn the

32:47

unboxed

32:53

and make it a grid position just zero so uh i guess to replace the block that we

33:02

got rid of so it's cool right

33:11

okay and then we also need one for the mushroom so i'm just gonna copy this if

33:18

object is mushroom surprise well you've guessed it

33:25

let's spawn a mushroom

33:30

so spawn a mushroom destroy the objects and also change it to unboxed so now

33:38

[Music] cool now let's make the mushroom move

33:44

so let's do that now i am going to use action for this

33:52

so i'm going to grab anything with a tag of mushroom um just make sure that it has a tag of

33:59

mushroom first and i'm also going to give it actually

34:05

let's do that later i'll show you why so i'm going to grab anything with the tag of mushroom

34:11

and the pastry m for mushroom and i want to grab the mushroom and remove that

34:17

mushroom and i'm going to move that mushroom uh around the y-axis 10.

34:23

okay so it's going to go to the right 10. so now there we go so it's moving our mushroom

34:30

is moving it's moving and you'd expect it to drop but it just carries on going because we

34:36

need to add gravity so i can do that by just adding body

34:42

here okay so i've added the body component

34:48

so now boom it's moving it's moving it's moving

34:56

it's moving and

35:02

cool so now i want um mario to grow if he eats the mushroom

35:14

so i'm just gonna do that below here i reckon uh let's grab the player and if the

35:20

player collides i'm gonna use the could be a method of collides with a mushroom

35:28

let's pass m for mushroom again i'm gonna destroy the mushroom so

35:34

destroy m for mushroom and i need to biggify the place i'm

35:39

gonna grab player and then we wrote bigger fire member and we also passed away times whatever i passed through into

35:45

here that's how long it's gonna be big four so let's say six seconds okay

35:52

so let's do that i also when i'm here i'm just going to grab the player and play a collides with a coin so anything

35:59

with the tag of coin just make sure yeah let's give this a coin tag

36:09

and play a college with a coin so let's pass through c for coin

36:16

well i want to destroy the coin yeah that's right destroy the coin um

36:23

but then we also want to grab the score score label score liable

36:29

um and just increase the value by once use the increment operator and then also display it for us right so

36:35

score label text equals score label

36:42

value okay let's check it out

36:48

[Music] so there we go oh yes not a number fine

36:53

that's because um we need to fix what we wrote before and let's just check that he gets bigger

37:00

oh okay so mario does get bigger i also want him to jump higher if he

37:06

gets bigger so we can get on the next level so let's do that

37:15

okay so we've got a jump force i also want a something that is this needs to be a

37:22

let as we're going to change it a current jump

37:28

force and for now that is just going to be the jump force okay but we're going to change that and

37:34

i want a big jump force a constant big jump force and let's make the big jump

37:42

force 550. i'm just gonna move that just it's meter great

37:50

um and do let no this is fine for now okay so when he

37:57

gets bigger let's get the current jump force

38:06

is big if is big then i want the current jump force to be

38:14

big jump force

38:22

actually we should do this here so if smallify and then

38:32

it's a smaller five we just want the jump force the bigger five we want the big jump

38:37

force so let's try that again let's make the mushroom move faster because i think it's moving a bit

38:44

slowly for me for my liking for now especially when we're building the game

38:49

we can just move it back to whatever we want later okay so now

38:56

okay no no he's not very jumping okay so that's

39:02

not right what did i do here let's have a look at this again okay i am actually gonna move this back

39:07

up here see if that works

39:14

so once again just get the mushroom

39:26

hmm why is it not changing ah that's because we need it to jump at

39:32

the current jump force okay because we're changing the current jump force

39:38

that is our changing variable um we just had this standard junk force before

39:43

so let's see it now okay and that is much better

39:51

and there we go great let's carry on

40:01

okay let's make our little guys move

40:09

so here if a player collides with anything with the tag

40:15

dangerous well whatever is dangerous let's pass that into our function

40:22

um and let's do we'll go to a loose scene shall we

40:31

so go to a loose scene and let's just pass

40:38

through these score so we can see what the final score is like so so now we need to

40:45

actually write a loose scene so let's make it outside of this scene scene lose

40:53

and i'm going to pass through the destruction score like so

41:00

add text

41:06

sorry add text so we open up the array we add the text score then we get

41:14

origin we can make it center center so i'm just going to use center

41:21

and then i'm going to put position um get the width

41:28

divide by 2 and then also the height so height and

41:36

divide by two okay so if we collide with one of them we lose let's actually make them move as

41:42

well so we need to actually assign a dangerous tag to the evil mushroom so let's do that

41:50

now so if we collide with them we go to the lose scene

41:55

great let's actually make them move however so

42:05

action and i grab anything with the din duress tag

42:12

and i'm just going to move it so d move and

42:18

we do we have an enemy speed let's just move them 20. um we want to go left there so minus 20

42:25

let's put const enemy speed 20

42:33

minus 20. okay

42:42

cool so now if we collide there we go you go to the losing scene it's saying

42:50

tests because we need to change this to be the score this is going to be the

42:59

score and let's just leave the level for now because our score is not defined because we did

43:06

not pass it through into the game score zero we're going to start off with

43:13

the score of being zero and then we also need to pass it into

43:18

the game itself so score

43:26

there we go so now let's get one point and then let's show that one point where we die brilliant

43:34

we are doing well um we also want to kill them if we jump on them so

43:41

let's do that now i'm gonna put const is jumping is true

44:06

now if player is grounded

44:14

then we want is jumping to be true as we apply the

44:21

jump and then let's also [Music]

44:28

do it here get the player um and then i'm just going to check that

44:34

if the player so if player is grounded again

44:42

at any time if the player is grounded

44:51

then we want is jumping to be false okay

45:01

now let's go to dealing with the collisions so if it collides but actually if the

45:08

player is jumping then we destroy

45:16

the dangerous thing but if it's not jumping then we lose so that makes sense else

45:25

there we go cool and i think another thing we can

45:33

do let's have full death because obviously if he falls down

45:39

in here then simon's a constant variable

45:44

ah that shouldn't be const my fault this is violet okay so now let's actually tackle the

45:52

death um death form so let's just put something uh let's call it fall death actually

46:00

we'll call it whatever we want and the full depth is going to be 400.

46:09

okay great now if the player falls down in here

46:16

we want it to be a game over so i'm just gonna do that where should

46:22

we do it let's do it here we can do it wherever we want i'm gonna choose to put it here so

46:28

action runs every frame second by the way so that is why it's a handy one to use

46:34

we're essentially checking something every frame second um inside the camera

46:39

position to be the player position at all times so that is something cool we can

46:45

do now if player position y

46:57

is greater than or equal to full death well then we go to the loose scene

47:05

so go to the lose scene and then take the score with you

47:11

score label

47:17

value so let's try it out shall we refresh so now you can see the camera's

47:24

actually following the user which is quite cool as well and edge okay so we did the camera movement

47:32

thanks to camera position player position just so you know i think that is quite

47:38

cool now the next thing you want to do is go to the next level so let's do that

47:45

so right in here i'm going to do if the player collides with anything with the

47:53

pipe tag well then what do i want to happen let's write our function and find out

48:00

um if it collides with that and the key press and i press key press

48:08

down so you can do key down you can do key press that part is totally

48:13

up to you whichever one you prefer the key down is literally pressing down and a key presses just a key press on your key board

48:22

so if i key press down well then i want to go to the next

48:32

level go game

48:37

um and then i need to pass through the score with me so i'm simply going to do like a label

48:43

like that value of course and i also want to pass through the next level

48:50

so um let's put level and i'm just going to

48:57

get whatever the level is plus one okay so that is how i would do that so

49:04

that means again that i need to start off with the level of the game being zero and then i need to pass that

49:11

through into the current game so i'm gonna go level and score

49:17

so now we have passed through zero to the first level of the game our first level is

49:23

zero so now if i want to show that here well i could just put level but then it'll say level zero and that

49:29

doesn't make sense i'd rather it's a level one just for the viewer and i'm just going to put this in

49:34

a pass in to make sure that it's in number two so let's try that let's refresh

49:43

oh why is it not showing add text level

49:48

oops there we go okay so there we go level one

49:56

it's sort of overlapping so maybe let's do some moving around um let's see if that's better

50:05

okay so we've got zero points and we're level one we're actually level zero because we password one to the viewer it says level

50:12

one um and then if we go to the next level well obviously there is no next level at the moment uh destroy is not defined

50:20

i've obviously misspelled destroy somewhere

50:38

okay so now let's go destroy destroy if i go here and i press

50:47

down well there's currently no level to go to but we also need to put tags on the

50:54

pipe top left so i'm going to put the pipe tag

51:02

i'm also going to pipe tag on here so it only affects the top two pipes

51:08

and let's try it again

51:13

go down and at the moment it's just taking me to the same level but that is because we need to

51:21

write a new level so let's do that now okay

51:30

so and then when we have one map let's have maps and make this an array

51:37

of maps so we're going to have two levels for now please of course feel free to add all

51:44

your own levels um add as many as you wish

51:49

for now we're just gonna have the two so there's our first map which means

51:56

when i'm adding levels i'm gonna get the maps array and then pass through whatever level it is so as we

52:04

know the first level is zero which means i'm going to go into the array and get the first item from my array

52:10

because we've passed through a zero into array that's what happens okay so that's a bit of array work for you from javascript

52:18

so here is my first map let's create our second

52:27

so at the moment they look the same but i'm just gonna load in some more sprites so just like

52:34

we did here i'm gonna load in some blue sprites this time to make the next

52:39

level so i'm gonna call this blue block

52:47

i'm gonna have blue brick i'm gonna have blue steel

52:55

and i'm gonna have blue evil shroom and i'm also gonna have

53:01

a blue sir price and once again i'm gonna go to my imager

53:08

and find them so here is my blue block this is gonna be interesting because they are different

53:13

sizes so i'm going to show you how to do that that is my blue block

53:21

delete that was that my blue brick um maybe that's a brick this looks like

53:28

a blue steel from funeral zoolander um it's not the

53:33

same blue steel sadly so that is my blue steel

53:43

here is my blue evil shroom

53:57

this must be which one would this be hmm

54:02

blue brick yeah that makes sense that's my blue brick

54:08

and then we just need the blue surprise so i'm going to get sharp or link copy

54:14

that and then just paste it here and we are lucky because most of the logic has

54:20

already been done for us so that is really handy um so let's just go ahead and add all those

54:28

in here too so i'm gonna copy that and now we have

54:35

the blue block

54:43

let's make this an exclamation we don't need a tag or mushroom so we're just gonna

54:50

have the blue block like so i'm gonna scale it so it's the same size as the others so

54:57

i'm just gonna put a scale 0.5 so that is our blue block we also have a

55:03

blue brick um and let's make that a

55:10

pound sign we also have an evil shroom let's make

55:16

that a z blue evil shroom

55:22

um and again let's give it the tag of dangerous so that's the cool part about these tags

55:28

we are reusing a lot of the logic we have already uh written so that is good

55:34

and then let's also make a blue surprise or price uh and this is gonna be

55:42

a coin surprise quite a surprise

55:49

and then of course we have blue steel

55:54

um that is not dangerous so we don't need that and then let's give it an x

56:01

so now let's use all of this to style our game

56:08

so this time i'm just going to put bricks on the side of the walls so just

56:15

like so

56:21

and on the other side too

56:31

and then this is all gonna be exclamations it's all the way to the end this time

56:39

and this time i'm just gonna have two three four five six

56:48

let's have some evil mushrooms

56:53

let's put z and z and then let's also have a pipe but let's put it

57:00

at the end here like so

57:06

and then let's have some

57:12

steel climbing things like so

57:22

one two three four one

57:28

two three four and then just

57:33

one two

57:46

so it's just hours of fun making these um little games uh you can make

57:52

the grids as big or as tall as small as you what so there we go

58:00

now let's check it out so we're passing the levels

58:12

okay so [Music]

58:17

let's go down and there we go we are now on level two with zero coins so that has worked

58:25

now let's try kill these poor oh we got killed so everything's working

58:30

fine once again let's go to the next level true and here we are

58:38

so this is all looking great i mean i'm really proud um

58:47

awesome and of course we don't have another level once again just like we do the zelda icon loop so

58:54

where are the levels

59:05

right here so that the level if i do modulus

59:11

maps length it will keep looping over and over and

59:18

over again so there we have it um of course

59:24

there is so much more you can do with this game i've just provided you with the basics

59:29

so you can get going and create more and more mario games

59:34

just like you did with link you can change the sprite of mario so perhaps if he's jumping you can have him

59:40

going like that um if you want to learn how to do that please look at the zelda game all you have to do is change the sprite

59:47

also you can have him when he's moving changing a sprite and so on and so on so there really is

59:52

a lot to do in this awesome game okay well i hope i provided you

60:00

with the knowledge to go forth and create your own not only uh mario and zelda and

60:07

space invaders but so so many others and please please do share them with us i for one would

60:14

absolutely love to see your finished games how you have styled them how you've made them your own so

60:19

yeah i'd really appreciate that

No comments:

Post a Comment