Mario Game Tutorial with JavaScript and HTML Canvas

Поділитися
Вставка
  • Опубліковано 14 тра 2024
  • Get the rest of the game early at: chriscourses.com/mario-game-c...
    Make your own animations with the Deekay Tool: aescripts.com/deekay-tool/
    Creating a sidescroller type Mario game requires a bit of knowledge related to physics, collision detection, and sprite animation. It can be quite tricky at first, but once you understand the basics, you can set up some full-fledged levels which anyone can play.
    This tutorial will teach you everything you need to know in regards to developing a fully functional Mario-type game with just HTML5 canvas and vanilla JS.
    Canvas Boilerplate: github.com/christopher4lis/ca...
    Image Assets: drive.google.com/drive/folder...
    0:00 - Project setup
    5:49 - Player creation
    12:20 - Gravity
    20:40 - Player movement
    35:43 - Platforms
    43:42 - Scroll the background
    53:46 - Win scenario
    56:38 - Image platforms
    1:14:09 - Parallax scroll
    1:24:12 - Death Pits
    1:29:46 - Level creation
    1:40:49 - Fine tuning
    1:42:56 - Sprite creation

КОМЕНТАРІ • 393

  • @franciscobarbosa956
    @franciscobarbosa956 2 роки тому +10

    Was looking to do something like this in this weekend, thank you Chris!

  • @TheLegendOfNiko
    @TheLegendOfNiko Рік тому +1

    Purchasing your course now brother. There is literally nowhere else that teaches you how to do this. Thanks man!

  • @muhzungoo5963
    @muhzungoo5963 2 роки тому +1

    Oh maaan, I've been waiting for this!! Thanks Chris, looks dope

  • @amaldash3394
    @amaldash3394 2 роки тому +8

    Excellent way to learn how to download the game without any inconvenience, very easy to follow the steps you indicate 👍

  • @TheLightofScience
    @TheLightofScience Рік тому +3

    This is one of the best tutorial I've ever seen, thank you so much for your hard work

  • @adeyemiadeyanju2247
    @adeyemiadeyanju2247 Рік тому +1

    I have been following and watching the playlist you created for HTML 5 canvas and I just pause here and say a big Thank you for this content Chris, I’m learning soo much ❤
    Even tho I know ThreeJs, learning concepts like collision detection was a real step up for me, God bless you man

  • @ricomclellanjr4042
    @ricomclellanjr4042 2 роки тому +27

    You've definitely made coding fun for me. Please keep making these games and you're a great instructor.

  • @ireenehabeeb2223
    @ireenehabeeb2223 2 роки тому +55

    Didn't know there is so much you can do with HTML5 Canvas + JS. Its powerful. Thanks for the video Chris

    • @vincentgallagher_
      @vincentgallagher_ 2 роки тому

      Can we fill in love?

    • @tonywu3554
      @tonywu3554 Рік тому

      @@vincentgallagher_ I must say Chris deserves way more subscribers his videos are super helpful.

  • @losrobbosful
    @losrobbosful Рік тому +11

    I reaaaally love how you scale up the complexity of the game very very cautious and carefully, introducing concepts with as much depth as necessary instead of just dropping concepts in randomly.
    That makes your tuts really outstanding.
    Hope you will also do more on BabylonJS again :D

  • @minfoodtravels
    @minfoodtravels Рік тому

    chris is a great teacher, I learned so much from how to use the things ive learned from courses and such in objects and functions etc

  • @alzaresh
    @alzaresh 7 місяців тому

    You're fast and you're informative. Really enjoying your content.

  • @thegeos568
    @thegeos568 6 місяців тому

    I've just found your channel and love it and your tutorials. Big thank you for making this content 🙂

  • @lukashenrique4295
    @lukashenrique4295 2 роки тому +7

    thx for yet another excelent tutorial! I'm loving your lessons, programming has been fun once again ^^ tip, for death pits u could just reset player Y and X position back to 0, 20 to get back where u started on the screen. and reset objects to their positions so the entire screen gets realocated to their original position, too. reset objects first, or else your player could land on another death pit and fall into a loop depending how u designed the level. it fits all kinds of levels this way.

  • @Cho1279624
    @Cho1279624 2 роки тому +1

    I am waiting for this kind of video, thank you!

  • @yaseenahmad6170
    @yaseenahmad6170 2 роки тому +52

    Chris! your voice is so relaxing when I wasn't falling asleep I just watched your tutorial and in the next 5 mins, I fell asleep lol. anyway, good job I really love the way you teach.

    • @ChrisCourses
      @ChrisCourses  2 роки тому +25

      Hahah thanks man, I remember my first few vids I released I actually had a few people complaining about my voice. Glad to hear perception has changed over the past few years 😆

    • @XILikeTrainsX
      @XILikeTrainsX 2 роки тому +3

      @@ChrisCourses your voice is strange.
      JK. As a rather good
      programmer this is still informative because we can see some techniques which are not learned yet or spot an improvement of our own code. Thanks for that! :)

    • @Solomonwo
      @Solomonwo 2 роки тому +1

      No

    • @Solomonwo
      @Solomonwo 2 роки тому

      @@XILikeTrainsX yss

    • @hilairesevn9499
      @hilairesevn9499 2 роки тому

      You have financial worries and you want to make a loan. Contact We offer financial loan from 4000 € to 100000 € with an interest rate of 1.5%. The hard for reimbursement of the maximum loan is 160months. Interested contact us

  • @wilwad
    @wilwad 2 роки тому

    Have been following your canvas game tutorials so I can make games for my daughter and also get her interested in programming. Thank you Chris

    • @yoguy515
      @yoguy515 2 роки тому

      do u how to deploy it?

  • @ItsVeronikaBeezy
    @ItsVeronikaBeezy 2 роки тому

    i appreciate this , best canvas tutorial out there!

  • @frodion
    @frodion 8 місяців тому

    One of the best tutorials for javascript game development. It's a lot of fun to follow along your tutorials.

  • @sheikhyawar2628
    @sheikhyawar2628 2 роки тому +1

    A great tutorial from a great instructor.

  • @3dforming
    @3dforming 2 роки тому +48

    Little tweak to add the effect of 'friction' to the player:
    if(keys.right.pressed) {
    player.velocity.x = 5;
    } else if(keys.left.pressed) {
    player.velocity.x = -5;
    } else {
    player.velocity.x *= 0.9;
    }

    • @ruairidhgrass3479
      @ruairidhgrass3479 Рік тому +3

      My player just runs off the screen if you do this!

    • @Dev-PauloEd
      @Dev-PauloEd Рік тому

      Dude, that was a really good one! Thanks, i was trying to do this but i couldn't... Awesome! 😄

  • @glaisonlimadospassos5581
    @glaisonlimadospassos5581 2 роки тому +6

    Seus vídeos me ajudaram muito, obrigado pelo excelente trabalho!

  • @85vaska
    @85vaska 2 роки тому

    Hey Chris. I think this is more that good tutorial. Thanks.

  • @muhammadasyrafi9550
    @muhammadasyrafi9550 2 роки тому +21

    Great tutorial! Thank you so much! It helps me kickstart my Javascript learning journey. Just want to add a little tweak I did on my attempt.
    If you hold the "UP" key, it will make your "player" kind of flying.
    I added *if (event.repeat) { return }* to prevent holding the *UP* key sending the player flying.
    It goes something like this:
    addEventListener('keyDown', ({ keyCode }) => {
    switch (keyCode) {
    case 38:
    if (event.repeat) { return }
    player.velocity.y += -20
    break
    }
    })
    note: I bind the key *UP* instead of *W* hence the *case 38*

    • @filbertlimm
      @filbertlimm 2 роки тому

      thankyou!! This was really helpful, I also realized that mistake!! salam dari indo juga :)

    • @MuskyDoge
      @MuskyDoge 2 роки тому +2

      That fixed the problem for holding UP but what about for tapping up? Must be something with setTimeout?

    • @ruairidhgrass3479
      @ruairidhgrass3479 Рік тому

      @@MuskyDoge did you find a fix for this?

    • @ruairidhgrass3479
      @ruairidhgrass3479 Рік тому +1

      Found a fix for the double, triple quadruple jump issue!
      I created a new condition on the Player class called 'onPlatform' and set it to true by default. This condition will return true if the player is touching a platform and false if the player if not touching a platform. To do this I wrote a small conditional within the player.update() function which goes like this:
      this.velocity.y !== 0 ? this.onPlatform = false : this.onPlatform = true
      Then in the addEventListener case statement for "keyDown" I amended the "w" case like so:
      case "w":
      case " ":
      case "ArrowUp":
      player.onPlatform === true ?
      player.velocity.y -= 15
      : null
      break;
      No the player wont be allowed to take more than one jump :D

    • @MuskyDoge
      @MuskyDoge Рік тому

      @@ruairidhgrass3479 if (player.velocity.y === 0) {
      player.velocity.y -= 25
      }
      spent hours trying to solve that lol

  • @andersoncdz1
    @andersoncdz1 2 роки тому +6

    Your videos are amazing. I loved your channel's content, the game videos in special. Please don't stop making videos, please (:

    • @ChrisCourses
      @ChrisCourses  2 роки тому +6

      Thanks Anderson, that means a lot to me. Have more game videos on the way, thinking about doing Pacman next. Really appreciate your support 🙌

    • @andersoncdz1
      @andersoncdz1 2 роки тому

      @@ChrisCourses , pacman would be an amazing tutorial, it was a game that I loved playing when I was a child. How about a side scrolling space ship game? I like the background moving effect, or a top down view game like pokemon or the old RPG games from super famicon. Thanks a lot for your reply.

  • @naveenpisher6928
    @naveenpisher6928 2 роки тому +1

    Hey You Man, Just Stunning. How you are explaining like a machine!!!!!!!! AWESOMEEEE Thank you!

  • @ravarador
    @ravarador Рік тому +11

    The only programming tutorial I've watched from start to finish without taking a break! Very fun tutorial!

  • @differenceParsley
    @differenceParsley 2 роки тому +2

    Great tutorial, including refactoring as a part of the process instead of skipping through made this whole project doable for a web dev noob like me. All of my previous experience was in hardware oriented projects using Arduino/C++ or RPi/python. This was a perfect introduction to JS.
    Almost finished re-skinning the game with my own image assets but got hung up working with Deekay Tool, I'll get there eventually, zero experience with AE probably isn't helping.
    Subbed! Link to your courses?

  • @idukpayealex
    @idukpayealex 2 роки тому +5

    wow, you really put a lot of work in your videos I hope you have more subscriber

  • @codingaddiction5224
    @codingaddiction5224 11 місяців тому

    A video from TOTAL scratch on the subject... Just a A-WE-SOME idea ! I subscribe, this video is a masterpiece :)

  • @josephcieplak8920
    @josephcieplak8920 2 роки тому +1

    We're waiting for the 2 part!

  • @brendanmulligan8640
    @brendanmulligan8640 2 роки тому

    How in the world do people know how to fix this stuff!? Legends, you're all legends

  • @erwinyulianto5407
    @erwinyulianto5407 2 роки тому +7

    Now I can teach my son a fun programming, thank you Chris!

    • @mahaali89
      @mahaali89 2 роки тому +2

      You are a great dad!

  • @milena9356
    @milena9356 9 місяців тому +4

    for anyone who had problems when he starts the server
    at first you have to know that he runs the code on git bash, that was my first mistake. After that I had several errors after "npm start", but to you solve it (if it's the same as mine) i had to run ' export NODE_OPTIONS="--openssl-legacy-provider" ' and to make sure that the environment variable has been set, you can run ' echo $NODE_OPTIONS ' , if you see ' --openssl-legacy-provider ' its ok and you can run 'npm start' again
    *dont forget that you have to run all these codes in mario-game-server folder, and they're valid for windows

  • @jgvlc
    @jgvlc 2 роки тому

    Thank you very much, excellent content, I wish you much success!

  • @anand_dudi
    @anand_dudi 2 роки тому

    Only youtube where i started my three js journey so thankyou ..and thanks for this one too

  • @kimrosvol6205
    @kimrosvol6205 Рік тому +7

    not sure if this is mentioned but "keyCode" is deprecated. New solution:
    document.addEventListener('keydown', (event) => {
    console.log(event.key)
    switch (event.key){
    case 'a' :
    break
    case 's':
    break
    case 'd':
    player.velocity.x += 1
    break
    case 'w':
    player.velocity.y -= 20
    break
    case 'ArrowLeft' :
    break
    case 'ArrowDown':
    break
    case 'ArrowRight':
    player.velocity.x += 1
    break
    case 'ArrowUp':
    player.velocity.y -= 20
    break
    }
    })

  • @SandeepKumar-my7pk
    @SandeepKumar-my7pk Рік тому +1

    great work brother ❤

  • @babyman8046
    @babyman8046 2 роки тому

    My brother we are very thank for you because you are a good coder and voluntarism

  • @squeegeul2.033
    @squeegeul2.033 2 роки тому +3

    i want more of these video they make me learn so much its amazing

    • @ChrisCourses
      @ChrisCourses  2 роки тому +2

      I got another coming this week, will be teaching how to make a dope version of Space Invaders

    • @ikdamagnificent8387
      @ikdamagnificent8387 2 роки тому

      @@ChrisCourses how much for a game like this?

  • @user-uv5py8zi1w
    @user-uv5py8zi1w 2 роки тому

    Amazing. Thank you a million

  • @cardo720
    @cardo720 5 місяців тому

    You are amazing Bro. You have done it all. Thank you soo much

  • @lioramar8465
    @lioramar8465 2 роки тому

    Thanks a lot! very informative🤓

  • @Sleet-user
    @Sleet-user 2 роки тому

    I know (almost) no html and no javascript, this helped me a lot

  • @user-px4fg9ow8j
    @user-px4fg9ow8j 7 місяців тому

    this design concept help a lot THX!!

  • @grzegorzlorenc1762
    @grzegorzlorenc1762 2 місяці тому

    Great course :) Thanks very much :)

  • @Mind--Blow
    @Mind--Blow 11 місяців тому

    hey Chris thanks for the video i have made it very good one

  • @brayanlima3108
    @brayanlima3108 Рік тому

    production. Thanks again!

  • @liLi-lg8xv
    @liLi-lg8xv 2 роки тому +1

    Great stuff!!!

  • @aryapatni6252
    @aryapatni6252 2 роки тому

    Hey dude your voice is great and relaxing

  • @GameVideos159
    @GameVideos159 2 роки тому

    Amazing video!!! ;) Really good job...I enjoy as will be write code and learn development a games :)

  • @dbroche
    @dbroche 2 роки тому

    Super great tut for beginners Chris! I learned a lot - - however - - definitely not production ready. I'm sure you get into all of that during the paid course though. Great job!

    • @yoguy515
      @yoguy515 2 роки тому

      do u know how to deploy it?

    • @dbroche
      @dbroche 2 роки тому

      @@yoguy515 watch until the end and you’ll learn how to deploy to #Netlify

    • @yoguy515
      @yoguy515 2 роки тому

      @@dbroche bro there is nothing..can u add timestamp?

    • @MuskyDoge
      @MuskyDoge 2 роки тому

      @@yoguy515 You build. "npx webpack --config webpack.config.js" will make a dist folder. If you upload everything from the dist to a host it will allow it to run.

  • @sejieinzbern1596
    @sejieinzbern1596 Рік тому

    this channel is awesome

  • @elClubdelas7Cifras
    @elClubdelas7Cifras 2 роки тому

    wow, just finished the video and did it my self following your instruction.
    Quick recommendation: please use more than 1-2 sheets. Its much more organized if you use a separate sheet for classes, another for global variables and another for the game code.

    • @nickjohngray
      @nickjohngray Рік тому

      could do, but that in a example like this, will make this more complicated

  • @strizelentwickler9451
    @strizelentwickler9451 2 роки тому

    Thank you very much. Great job!!!!!!

  • @anmogashoa
    @anmogashoa 2 роки тому

    loved this one Chris. Found the collisions code extremely helpful for the game I am working on. Have one question though, after calling the init restart game function when an enemy gobbles the player, how do I make sure it isn't called over and over when a player powers up and supposed to go through an enemy?.. Thanks again

  • @MightyKingKala
    @MightyKingKala 2 роки тому +1

    Thank you for this video

  • @CallousCoder
    @CallousCoder Рік тому

    I wrote this in assembly in the C64 last year. As a round up to my C64 assembly course. But I still need to make the video.

  • @imthekingiam4506
    @imthekingiam4506 Рік тому

    LOVE U FOR TUTORIAL VERY VERY GOODDDD
    💫❤

  • @mallawahirosh8920
    @mallawahirosh8920 2 роки тому +1

    great tutorial

  • @mohamedlamhamdi5244
    @mohamedlamhamdi5244 2 роки тому

    thank you for the content

  • @alexandretodorovic5950
    @alexandretodorovic5950 2 роки тому +2

    Did it from the start, but i wish you could show us a another way to use the canvas, without local serveur. Great video

    • @bennydaniel93
      @bennydaniel93 2 роки тому

      @yammo yam man i'm struggling whit this 🤣 i have Visual Studio Code and Live Server installed but the "import" statement doesn't work, please if you see this give me a hand whit the CreateImage() function 🙏

    • @bennydaniel93
      @bennydaniel93 2 роки тому

      @yammo yam thank you for time bro! i'll try that function now. To follow the video i was copying one after other to make it run haha
      edit: IT REALLY WORKS!

    • @TiagoMSantos28
      @TiagoMSantos28 Рік тому

      @@bennydaniel93 hey! i´m having the same problem. can you help me? i'd be extremely grateful :)

  • @nini-ic7is
    @nini-ic7is 2 роки тому

    amazing stuff

  • @the_kid777
    @the_kid777 5 місяців тому

    Just thank you. Thank you.

  • @kemokemo9914
    @kemokemo9914 2 роки тому

    Amazing video

  • @mrnabby4178
    @mrnabby4178 8 місяців тому

    Gonna build this soon

  • @mydevcarrer6003
    @mydevcarrer6003 2 роки тому

    Your course is so excited. But only one thing I really wonder that how to create a control flow to code step by step? Can you share you experience ?

  • @charlesvu8019
    @charlesvu8019 2 роки тому

    So amzing, Make more games pls

  • @Bartnick81
    @Bartnick81 Рік тому

    Awesome, thanks

  • @Coding_Asmr_PraDev
    @Coding_Asmr_PraDev 2 роки тому +18

    Your videos are delayed but the quality of content is just like never seen before on entire youtoob

  • @gektorix
    @gektorix 2 роки тому +18

    Working with collisions was interesting and allowed me to play around with the values. But the topic of using sprites was a bit confusing and requires a separate theoretical breakdown. You need to put theoretical elements and a bit of history into courses as you did before.
    The main problem for beginners is the inability to set up a local server. An up-to-date guide is needed.

    • @bryanpotts3602
      @bryanpotts3602 11 місяців тому

      You don’t need that you can just do the new Image() and put the source

  • @killroy1986
    @killroy1986 2 роки тому +4

    Hey Chris! Great content, thank you so much, I learned a lot. A question... I'm wondering, even though it's just a 2d platformer, ideally, would it make sense to implement a game like this in webgl using matrices? Or it's just simply overkill? Not for learning purposes, I'm just wondering if that would be the best way since as you improve as a game dev, you might want to add a lot of special effects, particles stuff like that.
    Alright, I know it's always "it depends" so I'd rephrase my question... If you were about to write a very modern 2d platformer with lots of moving stuff on the screen, would you use three.js or, unless it's 3d, the 2d rendering context is totally fine.
    Thank you in advance!

  • @siddhantkhare2775
    @siddhantkhare2775 2 роки тому +1

    Really very great explaination.....
    Btw, Love from India Bro.....🇮🇳🇮🇳🇮🇳

  • @dotgaepark5206
    @dotgaepark5206 Рік тому

    Love ur vid and checkList 🤟🏼🤟🏼

  •  2 роки тому

    congratulations for the tutorial. in the full video do you provide subtitles in Portuguese? I am Brazilian. Thank's

  • @bowler28
    @bowler28 2 роки тому +2

    23:49 Why do we look for the keyCode? Can't we just use the key or the code property? It would be clearer to read, that's for sure. I don't mean to call you out or anything. This is my first time programming any website so I just want to know why. Is it faster to compare ints than strings?

  • @muderer6029
    @muderer6029 2 роки тому +6

    hey @Chris Courses at 24:20 - you destructured the keydown event into "keyCode" such as addEventListener('keydown', ({keyCode}) => { console.log(keyCode)}. But the warning says, "KeyCode was deprecated ". I searched for it and then found they recommend 'key' or 'code' instead of 'keyCode'. How can you use the 'keyCode' in your text editor?

    • @tejageddam3283
      @tejageddam3283 Рік тому

      Same issue was found by me 🥲🥲 i want another solution which is working for wasd keycodes 👍

    • @Fishamble
      @Fishamble Рік тому

      @@tejageddam3283 Just use key in place of keycode
      addEventListener('keydown',({key})=>{
      then
      case 'a' instead of case 65 etc

  • @user-ku3pg9bt1t
    @user-ku3pg9bt1t 2 місяці тому

    Thanks very much :)

  • @crazydevil3090
    @crazydevil3090 Рік тому

    Love u dude

  • @ol1175
    @ol1175 Рік тому

    Chris It’s amazing !!! I’m a web dev , however it’s interesting to create 2D game. Can you pls recommend a tutorial/course for completely beginner in 2D js games?
    Cheers

  • @RyderYeh
    @RyderYeh Рік тому

    Hi Chris! Do you know how to download the git? I didn't get that right. Thank you! Awesome amazing tutorial btw!

  • @bhuku1250
    @bhuku1250 2 роки тому

    Thanks bro

  • @dedhen
    @dedhen 2 роки тому

    that's awesome

  • @KingKakashi45
    @KingKakashi45 2 роки тому +1

    You are the best

  • @NotoriousGarbagePerson
    @NotoriousGarbagePerson Рік тому

    im a bit of a begginner, so i have some questions. in 13:50 he creates the update function. is it a function or something else? its not stored as a var/const and doesnt have the word function in the declartation. is it something else or just a way of writing functions i havenst seen before. also the html page had nothing but a canvas tag and it still functioned propperly. do you not need the html/head/body tags?

  • @gakpapa3073
    @gakpapa3073 2 роки тому

    Nice game you bro 👍🏻

  • @MisterWealth
    @MisterWealth 2 роки тому +1

    I love this channel and thank you so much for the help making these. I do want to ask though.. When starting out, I've been trying programming on and off mostly OFF for about 2 years.. Minimal effort. I keep putting it off because it just seems like impossible, like how do I even know what to do. I understand the basics and what they can do, but when tf do I implement things, how do I know what TO implement etc.. I just feel like a stupid poop head.

    • @ChrisCourses
      @ChrisCourses  2 роки тому +1

      If can definitely be tough seeing people breeze through things when you’re struggling. Only reason I’m able to is because I’ve been programming as a profession for 8 years now. When you do something every day, eventually it becomes second nature, but I can attest, it’s not easy to get to that point when you’re struggling at first because it’s just not as fun. It all comes down to a desire to learn a little bit each day, then keep doing it every day until you feel confident with your skills. Hope that helps answer your question a little bit, appreciate your comment and thanks for watching 🙌

  • @tobarbaro
    @tobarbaro 2 роки тому

    Thanks for this tutorial, I loved it. I have a question. How many objects I can process and render on screen before it starts to lag?

    • @nickjohngray
      @nickjohngray Рік тому

      that depends on how powerful the machine is that is running the code

  • @patrickconrad2874
    @patrickconrad2874 2 роки тому

    So keyCode is depricated. Not sure if he mentions this in the video later on. Will there be any weird side effects if I just use the code property? I guess I'll need to account for other language keyboards but idk if that is an issue with keyCode still too.

  • @benjamineng6047
    @benjamineng6047 2 роки тому +5

    At 59:14, Chris talks about it being much easier with the live server-extension in vs code, but he doesn't say how to use it. Could anyone help me with a link to a tutorial perhaps or any tip whatsover? Thanks! By the way, great video!

    • @gektorix
      @gektorix 2 роки тому

      The best solution is to configure WebPack and implement projects on a local server.
      Here is a link to a great channel video. The author is very detailed and shows all the installation and configuration steps.
      ua-cam.com/video/9c3dBhvtt6o/v-deo.html&ab_channel=SteveGriffith-Prof3ssorSt3v3
      There is also a guide on Chris's channel, but it is very outdated and not suitable for WebPack 5

    • @gauribanga6885
      @gauribanga6885 Рік тому

      Just download the live server extension in vs code. Then you can go to your page and click on start live server.

    • @tejageddam3283
      @tejageddam3283 Рік тому

      Same issue is here if you get any video or idea please share with me also 🙂🙂

    • @tejageddam3283
      @tejageddam3283 Рік тому

      I did the same thing I just click on go live button and it created localhost server but nothing is rendering the page gone blank

    • @tejageddam3283
      @tejageddam3283 Рік тому

      In console it shows only"live reload enabled"and nothing happens

  • @tanavposwal
    @tanavposwal 2 роки тому +3

    Thats what i needed.

  • @tim.e.l
    @tim.e.l 2 роки тому +2

    Why do you use an import statement for the image file source instead of just using a string const. What is the import statement doing exactly? I've never seen it done that way before which is why I am asking.
    Great video btw. Thanks

    • @ChrisCourses
      @ChrisCourses  2 роки тому

      Haha wow, I’ve been developing with modules for so long that I forgot you could just pass through the image name as a string. You could honestly just skip the way I imported things completely-I import images the way I did since certain frameworks require it and I’m just used to it within my client work. Great catch on this 👍

    • @DopEZTam
      @DopEZTam 2 роки тому

      @@ChrisCourses Hi Chris, could you make more videos like this since they are really helpful and entertaining. Thanks for the great content

    • @ChrisCourses
      @ChrisCourses  2 роки тому

      @@DopEZTam yeah I got another coming this week, thinking it should be out on Wednesday.

    • @parthsundarka4388
      @parthsundarka4388 2 роки тому

      Could you please elaborate or send the code snippet, I am a little confused.
      Thanks

  • @Cho1279624
    @Cho1279624 2 роки тому +1

    24:20 - you destructured the keydown event into "keyCode" such as addEventListener('keydown', ({keyCode}) => { console.log(keyCode)}. But the warning says, "KeyCode was deprecated ". I searched for it and then found they recommend 'key' or 'code' instead of 'keyCode'. How can you use the 'keyCode' in your text editor?

    • @andricode
      @andricode 2 роки тому +1

      Deprecated means still available but has stopped recieving support, if it has any error it wont be fixed

  • @bianchinimattia7778
    @bianchinimattia7778 2 роки тому

    Hi Chris, thank you so much for this video, is helping me with a school project, but i am having issues with importing the images, I have tried everything that is said in the video and also other things, but it just does not work, i heard that with vs code i shouldn't need anything, but i never used it, so i don't know how to avoid the problem. Is there any other way to import images in a js script? or am i doing something wrong?

    • @ChrisCourses
      @ChrisCourses  2 роки тому +1

      Check out the tutorial I just released on Space Invaders, there's a section in there where I import the images in a more traditional method that shouldn't require any import statements like used within this video. The section you're looking for should be "Create a player" within that video - that should definitely get you up and running here as well.
      Lmk if you get that working.

    • @bianchinimattia7778
      @bianchinimattia7778 2 роки тому

      ​@@ChrisCourses Thank you so much , it worded, now I can use images in my program without getting any errors. Thank you!

    • @sejalvasan
      @sejalvasan 2 роки тому

      @@bianchinimattia7778 could you please share a code snippet, I’m facing the same issue that you were facing earlier

    • @nickjohngray
      @nickjohngray Рік тому

      @@sejalvasan check my comment above and how to simply import using an object object and setting the src prop

  • @arunbohra4346
    @arunbohra4346 Рік тому

    Instead of using that boilerplate for server we can also use live-server from npm

  • @nickjohngray
    @nickjohngray Рік тому +10

    nice one! BTW images can be imported and set without running some server, like: const spriteWalkRight = new Image();
    spriteWalkRight.src = 'player2.png'; ( and just put images in root directory )

    • @dodoing7554
      @dodoing7554 Рік тому

      so help full
      no come image like in torilas but when applay this it's bhoom

    • @lapapa2108
      @lapapa2108 Рік тому

      how do I do that?? :(

    • @nickjohngray
      @nickjohngray Рік тому

      @@dodoing7554 what i dont get you?

    • @dodoing7554
      @dodoing7554 Рік тому

      @@lapapa2108 you do i dodin't that

    • @dodoing7554
      @dodoing7554 Рік тому

      @@nickjohngray your idea

  • @jaisarita
    @jaisarita 2 роки тому +1

    Hii Chris, first of all thanks for the great content. I am facing a problem that my canvas is always taking an extra space towards right and bottom even after setting canvas.width = innerWidth and canvas.height = innerHeight. This is resulting in scrollbars for side and down. How can I fit my canvas exact to my window size.

    • @vez87
      @vez87 2 роки тому

      Did you set the margin to 0 on the style tag?

    • @jaisarita
      @jaisarita 2 роки тому

      @@vez87 Hii Verity, thanks for your reply. I solved my problem just now by using css.
      html, body {
      margin:0;
      width:100%;
      height:100%;
      }
      It took me 4 months to solve this. 😂

    • @jaisarita
      @jaisarita 2 роки тому +1

      @@vez87 Hi I got one more error. While switching to canvas boilerplate I got error saying :
      ' Failed to load module script: Expected a Javascript module script but the server platform.png:1 responded with a MIME type of "image/png” '
      I googled it but didn't got solution. Can you please help me 🥲

  • @Abhishekkumar-qo9ev
    @Abhishekkumar-qo9ev 2 роки тому

    can you also elaborate on how u can deploy this project?

  • @caiomalheiros4996
    @caiomalheiros4996 2 роки тому

    Obrigado pelo vídeo

  • @kaushiknagella06
    @kaushiknagella06 Рік тому

    @chris courses so I tried they same method for the images and for some weird reason if I set the height and width equal to the image height and width and collision detection goes off and I can’t stand on the platform

  • @rajdeepchandra9807
    @rajdeepchandra9807 2 роки тому

    Can you also share which plugin is giving those intellisense?