Subway Surfers Made with Javascript?

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

ความคิดเห็น • 150

  • @jerryhoffmann7635
    @jerryhoffmann7635 3 ปีที่แล้ว +3

    here is the javascript code
    document.addEventListener("keydown", event => {
    if(event.key==="ArrowLeft"){moveLeft();}
    if(event.key==="ArrowRight"){moveRight();}
    });
    var character = document.getElementById("character");
    function moveLeft(){
    let left = parseInt(window.getComputedStyle(character).getPropertyValue("left"));
    left -= 100;
    if(left>=0){
    character.style.left = left + "px";
    }
    }
    function moveRight(){
    let left = parseInt(window.getComputedStyle(character).getPropertyValue("left"));
    left += 100;
    if(left {
    var random = Math.floor(Math.random() * 3);
    left = random * 100;
    block.style.left = left + "px";
    counter++;
    });
    setInterval(function(){
    var characterLeft = parseInt(window.getComputedStyle(character).getPropertyValue("left"));
    var blockLeft = parseInt(window.getComputedStyle(block).getPropertyValue("left"));
    var blockTop = parseInt(window.getComputedStyle(block).getPropertyValue("top"));
    if(characterLeft==blockLeft && blockTop300){
    alert("Game over. Score: " + counter);
    block.style.animation = "none";
    }
    },1);
    document.getElementById("right").addEventListener("touchstart", moveRight);
    document.getElementById("left").addEventListener("touchstart", moveLeft);

  • @mariemehab9595
    @mariemehab9595 4 ปีที่แล้ว +31

    You could have just added "overflow:hidden" to the game div so that the block doesn't appear when it goes out of it, nice video though.
    It helped me alot keep going ;)

    • @koalaongenshin
      @koalaongenshin 3 ปีที่แล้ว +2

      i tried this but the box still goes past the border but if it worked for you thats cool! :D

  • @wangariwangai2049
    @wangariwangai2049 4 ปีที่แล้ว +2

    Completely loved it.;.actually ended up playing the game for close to 20 times (sue me; i was idle).;; relatively new at coding but your videos give me motivation to learn more

  • @NegarDev
    @NegarDev 4 ปีที่แล้ว +7

    Great video!
    Just a suggestion, for hiding the black block out of your game frame you can set "overflow: hidden;" to your game div.

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว +4

      I knew I was being dumb.... haha good call

    • @codein7764
      @codein7764 2 ปีที่แล้ว

      You are not dumb bro! , Maybe you r good as a backEnd

  • @lucafly8847
    @lucafly8847 4 ปีที่แล้ว +22

    thank you for making so many simple projects it has really helped me

  • @jaymahen3618
    @jaymahen3618 2 ปีที่แล้ว +1

    slide animation is not working and the charracter and the block is not showing in the border

  • @knightplayzz7937
    @knightplayzz7937 3 ปีที่แล้ว +2

    For everyone listen here go to gamediv in style.css type "overflow:hidden".
    If you die to late and when te block is gone and you move to there and still die listen.
    At 6:30 you see blockTop300 remove the digits and paste
    blockTop200 NP

  • @sumukhakb2701
    @sumukhakb2701 4 ปีที่แล้ว +4

    Please make more game tutorial like this....not fast coding type tutorial.... because in this tutorial you explain very well(I understand these types of vid)

  • @CosmicMaanz
    @CosmicMaanz 2 ปีที่แล้ว

    Don't listen to the haters. That was a game. I appreciate you teaching people how to make JS games. That dinosaur game is a game, When a beginner programmer makes a game it doesn't has to be the next GTA game, it can be really basic as long as the beginner programmer learns from their mistakes and then makes a non basic game

  • @derekaldrich4887
    @derekaldrich4887 4 ปีที่แล้ว +3

    You are the best person ever on TH-cam

  • @progthecode9894
    @progthecode9894 3 ปีที่แล้ว

    3:33 the best way i will say it's 'overflow: hidden;'. I like your tutorials because they are good for beginners and people can do whatever they want with the code!👑

    • @KnifeCircus
      @KnifeCircus  3 ปีที่แล้ว +1

      ya im dumb lol

    • @progthecode9894
      @progthecode9894 3 ปีที่แล้ว

      @@KnifeCircus no i think people can improve that self.👍

  • @GeekyMino
    @GeekyMino 3 ปีที่แล้ว +5

    Great way of presenting! Awesome video, keep up the good work.

  • @newsjuice7404
    @newsjuice7404 2 ปีที่แล้ว

    These simple projects beginners friendly & huge help thanks a lot

  • @kushagrak.7272
    @kushagrak.7272 4 ปีที่แล้ว +5

    Hey, can you also write the link to the files so that we can download the game files and then start them on our browsers?

    • @davisnoah347
      @davisnoah347 3 ปีที่แล้ว

      CTRL + S on the webpage saves the webpage. This works for every web page I've ever tried it on.

  • @connorguymon3523
    @connorguymon3523 3 ปีที่แล้ว +1

    My right arrow did not work

    • @clarkbassem7319
      @clarkbassem7319 3 ปีที่แล้ว +1

      Dont change all left word to right change only moveLeft to moveRight and left -= 100; to left += 100;

  • @abderrahimmouheb4932
    @abderrahimmouheb4932 4 ปีที่แล้ว +1

    In the minute 4:01 I think that we can just use overflow:hidden in the game div to prevent the block to outside from its parent, this is more easy than using new white block

  • @rebouncer
    @rebouncer 4 ปีที่แล้ว +1

    can you please tell me me why my code is not working. I looked all of your tutorials how to make dinosaur game, flappy bird and many more non of them work. TELL ME!!!!!!!!!!!!!

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว

      send me pictures of your code on instagram or twitter and i can help!

  • @norus_
    @norus_ 3 ปีที่แล้ว

    In case of the block, you should add to the game id an overflow: hidden; Though, I love your content! Continue to post videos it helps me to learn a lot!!

  • @ttrk8768
    @ttrk8768 2 ปีที่แล้ว

    Thank you bro for making this simple javaScript game. It's run perfectly..😍

  • @ayushraj1224
    @ayushraj1224 4 ปีที่แล้ว +2

    Which type of text editor or brawsoe you used for coding???
    Please reply......🤪🤪

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว +2

      Ayush Raj I use brackets.io

  • @mrdraynay
    @mrdraynay 4 ปีที่แล้ว

    Bro this is a service to the people.

  • @fartpuma6290
    @fartpuma6290 3 ปีที่แล้ว

    My character doesn’t move when I click the arrows, and I’ve copied the code word for word

  • @adastd4709
    @adastd4709 4 ปีที่แล้ว

    Instead of having a white div to hide the the block you can go to the css property of the #game and add overflow hidden
    Edit: just noticed someone had this idea sorry

  • @robertefremov9380
    @robertefremov9380 2 ปีที่แล้ว

    Finally, I can play a game with 0 (1) ping!

  • @itsnotAZ
    @itsnotAZ 2 ปีที่แล้ว

    But isn't the original Subway Surfers made with JavaScript and Unity?

  • @atharvamhaske5806
    @atharvamhaske5806 3 ปีที่แล้ว

    I am having issue that the block is getting any random position but it is supposed to be taking a space of 100px pls tell me how to fix it

  • @axewbotx
    @axewbotx 3 ปีที่แล้ว

    where did you learn all this can you pls tell me i wanna know

  • @mohitkale6879
    @mohitkale6879 4 ปีที่แล้ว +1

    You make gaming look so easy :) Just subscribed your channel, waiting for new videos.

  • @ArmadaCrew22
    @ArmadaCrew22 2 ปีที่แล้ว

    Thank you very much for this 🙏🏾🙏🏾🙏🏾💪🏾💪🏾💪🏾

  • @nirgarnaga7206
    @nirgarnaga7206 2 ปีที่แล้ว

    did you use visual studio code for that?

  • @icccricket1171
    @icccricket1171 2 ปีที่แล้ว

    How to strong front end web development
    My skill is week
    So please help me
    What way I get

  • @VirtualPiano1
    @VirtualPiano1 2 ปีที่แล้ว

    This is cool for us beginners. Thank you for these videos 😊

  • @israelonimowo6115
    @israelonimowo6115 ปีที่แล้ว

    How do we add sprint aniamtion to it
    to make it look cool

  • @bacon8353
    @bacon8353 4 ปีที่แล้ว +1

    I remember this guy from his chirstmas vids

  • @begreen2809
    @begreen2809 3 ปีที่แล้ว

    Thank you. Only problem is that sometimes when you're typing the code, it gets cut off and I can't read it

  • @yashkapoor2377
    @yashkapoor2377 3 ปีที่แล้ว

    But.i have a prob in my.project when i run after the random thing it shows cant read property event listener of none

  • @ilkinhuseynov9011
    @ilkinhuseynov9011 3 ปีที่แล้ว

    how did you put your web in google?

  • @that_one_bottom_less_sea_guy
    @that_one_bottom_less_sea_guy 11 หลายเดือนก่อน

    I like that he included the code for iOS

  • @DerAleksey
    @DerAleksey 3 ปีที่แล้ว

    Hi! Im interesting, why do you write code with id but no with class?

  • @computerscience1152
    @computerscience1152 3 ปีที่แล้ว +1

    Need more awesome tutorials!!😁

  • @ginius-heart879
    @ginius-heart879 2 ปีที่แล้ว

    Bro...
    please create a big Game...
    We need more prectice.....on js...
    It's really excites me.
    ..

  • @bhavlamba6458
    @bhavlamba6458 4 ปีที่แล้ว +1

    My block appears in the wrong position, how do I fix this?

    • @burakk9110
      @burakk9110 4 ปีที่แล้ว

      same

    • @danielames957
      @danielames957 2 ปีที่แล้ว

      Try changing the top of your block. See if that works

  • @hanikhan1942
    @hanikhan1942 3 ปีที่แล้ว

    Which app did you use

  • @yourmusic6552
    @yourmusic6552 2 ปีที่แล้ว

    Hello, how can I create the word hunt?

  • @abderrahimmouheb4932
    @abderrahimmouheb4932 4 ปีที่แล้ว +1

    Good work broo and thanks a lot, but I think that you have some mistakes in your css code, when you used position:relative with character div
    , it takes his right positio correctly, but when you added the block div, the character had translated to the bottom with 100px,
    so if we want to correct this mistake we must add relativeposition to the parent div and the we must use the same values of left and top properties with character div but with the absolute position, it will be right

  • @komodo3554
    @komodo3554 4 ปีที่แล้ว +2

    Can you please once again show the whole coding.
    That would be gratefull

  • @scienceexplained4267
    @scienceexplained4267 4 ปีที่แล้ว +1

    It wasn't working

  • @vedantgajbhiye2527
    @vedantgajbhiye2527 4 ปีที่แล้ว

    Bro your video is just nice. But I stucked in a problem. My blocks and character are not appearing inside the game area. Block is coming in extreme right and character downside. And only one block of starting at left is only appearing and after the whole coding, three blocks are not appearing and character is also not bumping into block. My animation is also just opposite from you.... Bro just help me how to solve it!??.....

  • @verifiediconiacswag
    @verifiediconiacswag 4 ปีที่แล้ว

    Nice to see you again. 😎

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว

      Laney Perry Thanks for having me! 😄

  • @safwaanahrazem2521
    @safwaanahrazem2521 3 ปีที่แล้ว

    can u make a vid for how to install javascript

  • @abdulrehmanjavaid549
    @abdulrehmanjavaid549 3 ปีที่แล้ว +1

    00:12 lol i was like i clicked on the wrong video

  • @kenziebrown4683
    @kenziebrown4683 4 ปีที่แล้ว

    RICH HOMIE SHAWN 🤣 it’s Zoe’s cousin kenzie glad to see you’re still on TH-cam!!

  • @greencodeliz6049
    @greencodeliz6049 4 ปีที่แล้ว +1

    This is amazing! Make more videos!

  • @RAHUL19964
    @RAHUL19964 3 ปีที่แล้ว

    How to run this game on phone

  • @SpleefedXD
    @SpleefedXD 2 ปีที่แล้ว

    bro nice tutorial u go very fast

  • @nayanraval5359
    @nayanraval5359 4 ปีที่แล้ว +1

    Awesome bro !👌 Excellent..

  • @GhostlyGamerr
    @GhostlyGamerr 3 ปีที่แล้ว

    when he said what the function does
    I thought he said what the fuck does

  • @martinrodriguez3228
    @martinrodriguez3228 4 ปีที่แล้ว +2

    That was really interesting. Thanks for sharing!

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว

      Martín Rodríguez Thanks for watching!

  • @mohithguptakorangi1766
    @mohithguptakorangi1766 4 ปีที่แล้ว

    how to add some random time for some powers to spawn on the track??

  • @adnanahmed7708
    @adnanahmed7708 3 ปีที่แล้ว

    Good videos but I don't understand the hit detection though

  • @davronshogdarov2396
    @davronshogdarov2396 3 ปีที่แล้ว +1

    pls show full of code
    this is your mistake

  • @uimonk
    @uimonk 4 ปีที่แล้ว

    Please make like this small videos.
    for us like beginner. to catch up with javascript
    You are really awesome

  • @aerfudax1442
    @aerfudax1442 3 ปีที่แล้ว

    *_-Good?-_*

  • @Loschungos714
    @Loschungos714 11 หลายเดือนก่อน

    Can someone give me the full code please?

  • @majiosos
    @majiosos 3 ปีที่แล้ว

    It would be nice to do any of your games whit canvas, it awesome thanks for sharing!!

  • @mansteading9924
    @mansteading9924 3 ปีที่แล้ว +1

    var block = document.getElementById("block");
    block.addEventListener('animationiteration', () => {
    var random = Math.floor(Math.random() * 3);
    left = random * 100;
    block.style.left = left + "px";
    });
    idk what im doing wrong

    • @prakash_xyz69
      @prakash_xyz69 3 ปีที่แล้ว

      Same

    • @clarkbassem7319
      @clarkbassem7319 3 ปีที่แล้ว

      make sure You are desperate space between = and > must to be =>

  • @xcrfce
    @xcrfce 3 ปีที่แล้ว

    what application do you use to code ?

  • @ankitsharma.1s
    @ankitsharma.1s 4 ปีที่แล้ว +1

    thankyou... next time a 2d car game with simple js htms and css....make it easie to read

  • @kgaming7599
    @kgaming7599 4 ปีที่แล้ว

    Can you show us how to make 3D games with 3D divs? I saw an abandoned project that did this.. I wished it wasn't abandoned because I really wanna know how to make 3D div games :D
    Edit: Can you also make an in depth collision detection tutorial?

  • @brahmharsh24
    @brahmharsh24 4 ปีที่แล้ว

    Where is the cop?

  • @venomgaming248
    @venomgaming248 3 ปีที่แล้ว +1

    please do this also on jquery

  • @ifunayannamdi3422
    @ifunayannamdi3422 2 ปีที่แล้ว

    Link to source code

  • @sowjanyaemani1099
    @sowjanyaemani1099 4 ปีที่แล้ว

    Really nice one

  • @bilaljamal2519
    @bilaljamal2519 3 ปีที่แล้ว +1

    i watched the whole video and i made the game

  • @alexandern.h4167
    @alexandern.h4167 3 ปีที่แล้ว

    Good video man

  • @computerscience1152
    @computerscience1152 3 ปีที่แล้ว +1

    Awesome

  • @kirtishukla4870
    @kirtishukla4870 4 ปีที่แล้ว

    You must definitely try MINECRAFT usinv JS, HTML , etc.

  • @Ioq6969
    @Ioq6969 4 ปีที่แล้ว

    It's amazing bro 🤜

  • @____Daniel____
    @____Daniel____ 3 ปีที่แล้ว

    add score indications, more elvels, sound etc :D

  • @gauravmanghnani6634
    @gauravmanghnani6634 4 ปีที่แล้ว +1

    can you share your github account?

    • @soyuave
      @soyuave 4 ปีที่แล้ว

      Yeah hopefully maybe he'll do that to me too◉‿◉

  • @ellsonmendesYT
    @ellsonmendesYT 4 ปีที่แล้ว +1

    instead of placing a div below to cover it'd be simpler to set overflow hidden on the game div :)

  • @updog7445
    @updog7445 4 ปีที่แล้ว

    the index.html is blank wont work

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว

      send me a message on twitter or instagram! id love to help you!

  • @HELIIXX449
    @HELIIXX449 3 ปีที่แล้ว +1

    maannnn!! the character goes down when the obstacle came in

  • @htmlforeveryone109
    @htmlforeveryone109 3 ปีที่แล้ว

    A very nice game

  • @jerryhoffmann7635
    @jerryhoffmann7635 3 ปีที่แล้ว

    Nice video

  • @moneymike7608
    @moneymike7608 4 ปีที่แล้ว

    Oh snap Ohkay tee still in here stylecircus 😎🎪

    • @KnifeCircus
      @KnifeCircus  4 ปีที่แล้ว +1

      Michael Anthony oh damnnn you remember 🤣

    • @moneymike7608
      @moneymike7608 4 ปีที่แล้ว

      Ever end up getting that Supreme ball?

  • @ayushraj1224
    @ayushraj1224 4 ปีที่แล้ว

    Pleaee remake this game using mobile phone only.

  • @omarsherif6631
    @omarsherif6631 4 ปีที่แล้ว

    How can i use it on my phone???

  • @geektom8898
    @geektom8898 4 ปีที่แล้ว

    bro can you make a facebook instant games withe javascript

  • @teeranoptinoempremsilapa7731
    @teeranoptinoempremsilapa7731 2 ปีที่แล้ว

    Pls make minecraft using js

  • @ilkinhuseynov9011
    @ilkinhuseynov9011 3 ปีที่แล้ว

    thank you

  • @RonanTI
    @RonanTI 3 ปีที่แล้ว

    Nandraki.js use css,js,htm game

  • @raghav8172
    @raghav8172 4 ปีที่แล้ว

    Pl 3d version of it

  • @ENOVQ
    @ENOVQ 3 ปีที่แล้ว

    Find a perfect name for it it will be cool

  • @pariveshbadal6004
    @pariveshbadal6004 4 ปีที่แล้ว +1

    Hi, I have been learning quite a lot from your videos! I have been struggling quite a lot with the idea of increasing animation speed every 10seconds. I tried adding the code below at the bottom of js file.. it does increase the speed every 10 seconds but the change is async with animation.. it occurs randomly & not at the very top
    var animationDuration=1000;
    VariableSpeed=setInterval(()=>{
    block.style.animationDuration=animationDuration+"ms";
    animationDuration-=50;
    },10000)

    • @Wufyiofkes
      @Wufyiofkes 3 ปีที่แล้ว

      O yea, what you did would only make the animation 950ms every 10 seconds, not increase the speed every 10 seconds!

  • @walney2008
    @walney2008 3 ปีที่แล้ว

    please speak game style guitar flash ?

  • @aubs5179
    @aubs5179 4 ปีที่แล้ว

    thanks a lot

  • @askark4767
    @askark4767 2 ปีที่แล้ว

    hey knife circus the bagler the bagel will get you tonight your so scared

  • @_xoi.d_
    @_xoi.d_ 4 ปีที่แล้ว

    itds a nice game

  • @prashanthkumar0
    @prashanthkumar0 4 ปีที่แล้ว

    nice