Coding Challenge

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

Комментарии • 247

  • @franchello1105
    @franchello1105 5 лет назад +328

    20 minutes in and just realized this was angry birds and no flappy bird

    • @aryamankejriwal5959
      @aryamankejriwal5959 5 лет назад +2

      I know right? I thought it was flappy bird too for the first couple of seconds!😂

    • @elvsrbad2
      @elvsrbad2 5 лет назад +1

      He's done flappy bird in another video iirc

    • @aryamankejriwal5959
      @aryamankejriwal5959 5 лет назад +6

      elvsrbad2 yes, but he’s done sooooo many flappy bird videos that it wasn’t too much of a stretch for him to do another one😂

    • @toasty7408
      @toasty7408 5 лет назад

      Holy shit same lol

    • @konstanty8094
      @konstanty8094 5 лет назад

      "I'm gonna be ising matter.js physics engine" - a bit of overkill if you ask me

  • @CYXXYC
    @CYXXYC 5 лет назад +196

    "it already knows the name bird.js" when it was first file you already made

    • @xBrOwNeDoG
      @xBrOwNeDoG 5 лет назад +4

      Once he created bird.js it became a suggested name. Its only once he created the file that it showed.
      Edit: But I dont doubt that he has done this challenge off camera to make sure he can actually complete it.

    • @CYXXYC
      @CYXXYC 5 лет назад +5

      @@xBrOwNeDoG thats what i said lol

    • @xBrOwNeDoG
      @xBrOwNeDoG 5 лет назад

      @@CYXXYC lol I didnt think thats what you meant. All good though

    • @maximgasai1349
      @maximgasai1349 5 лет назад +3

      I laughed so hard at that moment

    • @bluhb
      @bluhb 5 лет назад +1

      It was literally the first file he created in this video. No doubt he has done this before to test, but that's not where the suggestion necessarily came from.

  • @Taterzz
    @Taterzz 4 года назад +9

    i don't even javascript but these videos definitely help me in terms of understanding how to properly break down an issue into a programmable solution. the jovial attitude just makes it more infectious.

  • @krimo4342
    @krimo4342 5 лет назад +10

    I think the best way for the bird to reach Max speed is to release after test if bird position has reached slingshot point position not just delaying it 100ms,
    PS: thx for matter.js explanation

  • @xTWiZTED
    @xTWiZTED 5 лет назад +6

    A solution to dettaching the slingshot would be comparing the circle's x (call it c) value to the slingshot's x (call it s) value. If c > s and mouseReleased, dettach the slingshot.

  • @abdulhadilababidi8052
    @abdulhadilababidi8052 5 лет назад +30

    41:24 such a weird kiss 😂
    you are the funnest tutor on RUclips
    Keep going!

  • @tejaswanama
    @tejaswanama 4 года назад +6

    I love very much the coding train channel. I learn whole javascript from this channel only.. I thank to this channel to makes me knowledgeable...❤❤

  • @KongBorup
    @KongBorup 5 лет назад +5

    IMO, a better approach would be to replace the setTimeout controlling the slingshot release with an if statement that checks if the bird has crossed the point on the x-axis where the slingshot is placed.

  • @morphman86
    @morphman86 5 лет назад +41

    I got a coding challenge for you.
    You have done a lot of the really, really classic games, and a few modern ones, but I don't think we have seen you make any mid-era classics yet. So my challenge would be Dr. Mario.
    For the uninitiated, you have a 8x32 grid. At random positions, 3-8 (depending on difficulty) "virus blocks" are placed. Your playing piece will start at the top middle and fall down. The pieces consist of 2 blocks of random colours. You may rotate the piece as it falls, just like in Tetris.
    Your mission is to match up 4 or more blocks of the same colour, where the "virus block" is part of that chain. Once you do, all blocks in that chain disappears. Once all viruses are gone, you have won. If a piece lands in a way so that one block ends up over the top of the screen, you have lost, just like in Tetris.
    If a piece land sideways with one block sticking out, and there is no block in the position right below it, the overhanging block will continue to fall, but you no longer have control over it, until it lands on top of another block or the floor.
    Good luck, fellow programmers!

    • @sadhlife
      @sadhlife 5 лет назад +1

      now i want to code bomberman in p5

    • @morphman86
      @morphman86 5 лет назад +1

      @@sadhlife Go ahead. It's all grid-based, so if you watch Coding Train's videos about grids, you'll be halfway there.

  • @simeydotme
    @simeydotme 5 лет назад +2

    So good. The style, attitude and communication are brilliant!

  • @adamulrich5011
    @adamulrich5011 5 лет назад +2

    Those libraries in your hands are simply OP. Keep it up!

  • @zhabiboss
    @zhabiboss 2 года назад +1

    Him: making a bird.js file
    Also him after 5 min: IT EXACTLY KNOWS WHAT I AM GONNA CREATE IN ADVANCE

  • @rukna3775
    @rukna3775 5 лет назад +4

    the editing at the end of the the video was pretty good and also unexpected.

  • @Thorou
    @Thorou 5 лет назад +17

    If you had written it in python, you could've used semicolons as the boxes.

  • @noahburget3323
    @noahburget3323 5 лет назад +1

    I always watch your videos for motivation in my own code. Thank you so much!

  • @SimpleCarGuy
    @SimpleCarGuy Год назад +1

    Amazing presenter, great personality, even better coder and yet, the worse box drawer (that’s proportional and square) I have ever seen!
    Love the vids!

  • @joogps
    @joogps 5 лет назад +4

    6:30 When he said that I imagined javascript reporting ''Error: Null Pointer Exception (I dunno what ur talkin about)"

  • @oscantes
    @oscantes 5 лет назад +1

    29:49 Yeah I might, and it would be to compare the x positions of the bird and the point that spring is attached to. When bird.pos.x is higher than that attach point, it would be released. And this way bird will be faster cause you won't be wasting the energy that's left in the spring like you do with the timeout thing.

  • @Robber7
    @Robber7 5 лет назад +1

    You could just check the birds X if its a bit greater than the connection point of the sling (the bird is on the right) it should release. So that way it will only release if it actually moves to the right of the sling. Could also check the speed as well. Like if speed > X and x > slingshot.X + 5 fly()

  •  5 лет назад +24

    Maybe you could release the bird when it’s position is at the slingshot?

    • @TimToolman
      @TimToolman 5 лет назад +2

      Pål Oliver Kristiansen agreed, either when the bird is at the slingshot constraint 0 point, or simpler when the x delta changes sign after release ( ie your bird went past the slingshot post)

    • @joogps
      @joogps 5 лет назад

      that’s exactly what I thought... looking forward to implement that tomorrow!

    • @robertlister5192
      @robertlister5192 5 лет назад

      @@joogps anyone get this working be trying this for a while would be much appreciated.

    • @robertlister5192
      @robertlister5192 5 лет назад

      @@joogps
      function mouseReleased() {
      console.log(balls.x)
      console.log(slingshot.sling.pointA.x)
      if (balls.x >= slingshot.sling.pointA.x){
      slingshot.fly();
      }
      }
      cant get it to work. Everything is the same I cant get it to spring forward before detaching the constraint it just drops as soon as i release.

    • @clprackers7093
      @clprackers7093 4 года назад

      Robert Lister you aren’t constantly checking the x positions... only once when the mouse is released

  • @lapetitemort1666
    @lapetitemort1666 5 лет назад +1

    i am learned English to watch your lessons. VERY NICE TANKS YOU!!!!!

    • @lapetitemort1666
      @lapetitemort1666 5 лет назад

      Aayush Pokharel oh, yes my level elementary but i am continue learning

  • @gid9551
    @gid9551 5 лет назад +4

    38:24 "Things have gone really off the rails here!"
    Heh.

  • @taba1950
    @taba1950 5 лет назад +1

    Missed the chance to call it birdbox challenge. great as always.

  • @Brahvim
    @Brahvim 3 года назад

    29:46 :D I had this idea in my mind while you were thinking:
    Let's assume that users are only going to pull the bird towards the left side. If that is the case, then if the bird's x-position is greater than that of pointA (..? ...or whatever is the starting point of the constraint is called!), then we destroy/remove/stop the constraint.
    Same thing if it's going backwards!
    Another idea I had while writing/typing (😂👍) literally the last line was to check for the length of the constraint. If the 'spring' of the slingshot/constraint has reached a certain radius from the point/has been extended to a certain length, we store the force gained, and then let go of the constraint...that is, delete it (just like you set it to null). Then we remove all existing forces from the bird (other than gravity of course!) and add the force stored in the last step, back into the body.
    Pretty sure I accidentally didn't write the last step correctly and my idea is not gonna work xD!
    But the first one has to work....99 point cardinally infinite 9's guarantee! (I feel so confused about the second method I specified that my brain is going haywire right now...like, what does 'guarantee' even mean!? >:O)
    ( _please send help_ )

  • @MaxPicAxe
    @MaxPicAxe 5 лет назад +3

    4:00 "oh look it like knows what I'm going to do in advance" xD

    • @XGSDEV
      @XGSDEV 5 дней назад

      And doesn't realize he already called it! lol

  • @Ubayla
    @Ubayla 5 лет назад

    I noticed the "rest length" really seems to be a "min length", because it pushes the object towards the length value. Obviously, that's not the desired behavior.
    It's especially noticeable at 27:01. All sorts of weird behavior because it's trying to keep the bird at least 100 units away from the pivot point.
    Was kinda surprised nobody in chat mentioned this.

  • @epicclutchers233
    @epicclutchers233 4 года назад

    I am a kid and i love watching this guys videos

  • @minionbay8982
    @minionbay8982 5 лет назад

    the coding train is the most subbed programming channel on RUclips

  • @vashupandey2212
    @vashupandey2212 4 года назад +1

    you ara a coding hero

  • @luismiguelgallegogomez8000
    @luismiguelgallegogomez8000 5 лет назад +1

    This really should be the "Crush the castle with Matter.js" coding challenge

  • @DaveBriccetti
    @DaveBriccetti 5 лет назад +1

    Great fun! I'm gonna try Matter with my students. And good to see you naturally using const now.

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Pretty soon I'll be pronouncing GIF with a soft g!

    • @DaveBriccetti
      @DaveBriccetti 5 лет назад

      @@TheCodingTrain Ha ha. If you did that I would be thrilled!

  • @jaackotorus5589
    @jaackotorus5589 5 лет назад

    this is why type="module" is useful, everyone is just tired over worrying over the order of scripts

  • @Garry-jj6jh
    @Garry-jj6jh 5 лет назад +3

    Thank you for giving us your knowledge and also being so positive😁. Keep up the good work

  • @Yufukfu
    @Yufukfu 5 лет назад +2

    Just release the bird when distance between the bird and the constraint is less than the initial length

  • @FalcoGer
    @FalcoGer 2 года назад

    whenever you copy and paste code, especially large parts such as at 15:10, it's time for pulling it out and making it it's own function, possibly a parent class member.

  • @nachosacco5871
    @nachosacco5871 5 лет назад +1

    That keyboard sound

  • @leandroaraujo4201
    @leandroaraujo4201 5 лет назад +3

    Wow 139 likes and 0 dislikes atm, btw nice video. It's a pity I've missed the stream

  • @Eniallator
    @Eniallator 5 лет назад

    To detach the bird at the right moment, you could also detect when the bird's x position is greater than the slingshot's x position and then when it is, trigger the detachment 🙂

    • @victorwei6053
      @victorwei6053 5 лет назад

      This method works great when the slingshot is fully charged, but not very effective when slingshot is not very pulled back.

    • @Eniallator
      @Eniallator 5 лет назад +1

      @@victorwei6053 if you don't pull it back very much, you can't get any more power out of the shot. This is because once the bird's x position passes the slingshot's x position, the slingshot will start to slow the velocity of the bird down and bring it back. It's pendulum physics 😉

    • @robertlister5192
      @robertlister5192 5 лет назад

      @@Eniallator do you have the code to get this to work having trouble because of the class objects.

    • @Eniallator
      @Eniallator 5 лет назад

      @@robertlister5192 I don't, sorry

    • @robertlister5192
      @robertlister5192 5 лет назад

      No worries :)

  • @aryamankejriwal5959
    @aryamankejriwal5959 5 лет назад

    Another minor thing was that because the ground was exactly the same size as the screen, any blocks that went partially off screen could be seen falling off the ground

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Ah, yes, that definitely needs to be fixed!

  • @YitzharVered
    @YitzharVered 5 лет назад +7

    Just remember, pong took him longer.

  • @XGSDEV
    @XGSDEV 5 дней назад

    He thought that it knew what he was going to type, but the thing is he already called it! (LOLLLLLLL)

  • @KX36
    @KX36 4 года назад

    bird's x velocity is maximum when its x position passes the slingshot's x position, so release then.

  • @KakoriGames
    @KakoriGames 5 лет назад +1

    Maybe it would be better to release the bird when its distance to pointA is less than a certain number, that way the bird can get the full momentum before releasing and you don't have to time it.

  • @Henkie
    @Henkie 5 лет назад +18

    bird box?
    ground

    • @averagewojak2623
      @averagewojak2623 5 лет назад +1

      :O

    • @mikkel1383
      @mikkel1383 5 лет назад +2

      I have tried to find someone say bird box in the chat for a long time, FINALY😂

  • @michelangelo3330
    @michelangelo3330 5 лет назад

    u r my leader in coding world

  • @HossynAssghary
    @HossynAssghary 5 лет назад +1

    Oh rainbow im coding with unity for game this is awesome. I love 🌈

  • @Rydergomes11
    @Rydergomes11 3 года назад +1

    im learning about kinetic energy and potental energy at school!

  • @kolliden
    @kolliden 5 лет назад +4

    Love ur content

  • @alefsdev
    @alefsdev 5 лет назад +3

    It would be great if u do the jenga one!

  • @tekoreypy
    @tekoreypy 5 лет назад

    It is a very useful and entertaining video, I just missed the part where the teacher explains than you must run the code from a java server or the browser will not load the images Because the cors system. but it let me learn about Apache and tomcat, so a the end I'm thankful for that too

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      More in this workflow series! ruclips.net/p/PLRqwX-V7Uu6Zu_uqEA6NqhLzKLACwU74X

  • @aryamaangoswamy179
    @aryamaangoswamy179 5 лет назад

    Can you do a coding challenge where you create an interactive Rubik's cube? And possibly publish it to the Internet? Also, include a few buttons to make those moves (like an R button, L button etc.).

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Please suggest or upvote here! github.com/CodingTrain/Rainbow-Topics/issues

  • @MrWindboarder
    @MrWindboarder 4 года назад

    If anyone is having troubles with the mouseConstraint part, you may need to set this parameter if you are on a HD display:
    mouseConstraint.mouse.pixelRatio = 2;

  • @EENYX
    @EENYX 5 лет назад +2

    Why u so pro at programing ?? How did u learn that ??

  • @hashmitsingh572
    @hashmitsingh572 3 года назад

    thanx for the help , u deserve more subs

  • @minghaoliang4311
    @minghaoliang4311 5 лет назад

    what about checking the position: when the bird is on the right side of the constraint position, release the sling

  • @carterjean
    @carterjean 5 лет назад +1

    12:22 *its okay, we can break physics and make a floor*

  • @neelgohel335
    @neelgohel335 5 лет назад

    Awesome!

  • @average-enjoyer7
    @average-enjoyer7 5 лет назад

    Hi, a big fan of your channel! You have mentioned this project is done in an object orientated manner, I can't help but wonder how would you simulate this in a functional programming paradigm :) Cheers!

    • @joestevenson5568
      @joestevenson5568 5 лет назад

      With great difficulty. OOP is really ideal for graphical and physics problems as they typically revolve around objects.
      Functional programming is better suited for tasks requiring guaranteed memory and thread safety.

  • @VikingCanadian
    @VikingCanadian 5 лет назад

    Can you do the Tower of Hanoi, showing the algorithm's work every step. I would love to see this!! :)

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Please suggest here! github.com/CodingTrain/Rainbow-Topics/issues

  • @LapSiLap
    @LapSiLap 5 лет назад +1

    Nice video! Btw instead of const options = { mouse: mouse} you can just do const options = { mouse}

  • @sajeevanfuels1980
    @sajeevanfuels1980 3 года назад +1

    Daniel Sir Can you tell me which book should I prefer for javascript coding that includes all the concepts right from variables to physics enjine and everything please tell! :)

  • @atakanakkas2580
    @atakanakkas2580 5 лет назад +1

    Good Content
    you better do more videos like this before those (fast typing) fingers get tired

  • @χάθηκα
    @χάθηκα 2 года назад

    I just can't stop laughing with that bird.js

  • @micronix1888
    @micronix1888 5 лет назад

    Good job

  • @sergioescobar3468
    @sergioescobar3468 5 лет назад

    awesome!, you made a great game as few minutes..

  • @JuanMunoz-th3vn
    @JuanMunoz-th3vn 5 лет назад

    finally was a HAPPY BIRDS , thanks Dan

  • @mr.rabbit5642
    @mr.rabbit5642 5 лет назад

    If you attract a infinite mass with a (constant) gravitional force you get an infinite acceleration which is pretty much not what you've wanted for the 'ground' object xD

    • @joestevenson5568
      @joestevenson5568 5 лет назад

      Luckily for Dan matter.js doesn’t simulate N-body gravity.

  • @EduardsSilins
    @EduardsSilins 5 лет назад

    You should check after releasing mouse when the ball gets to its start position. In that way you will get the best results... :D At least i would do that...

  • @hedwinbonnavaud6998
    @hedwinbonnavaud6998 5 лет назад +2

    What about problem: click on equals enemy to move them? :D plz show how to fix it!

  • @davidbundgaard
    @davidbundgaard 5 лет назад

    I guess the proper way is to calculate the circle distance to start position and when it reaches 0 cut the line.

  • @malikd.mcnish6482
    @malikd.mcnish6482 2 года назад

    great vid, how do you setup the presentation of your vidoes (what are the softwares)

  • @Zxios
    @Zxios 5 лет назад +1

    Dan, you of all people should know by now that preincrement is superior to postincrement.

  • @Troy-ol5fk
    @Troy-ol5fk 2 года назад

    I think it would be more realistic to remove the constraint when mouse is released *and* the magnitude/length of the slingshot line equals 0

  • @ziuhoque1532
    @ziuhoque1532 5 лет назад

    keep coding challenage

  • @matiasvlevi6647
    @matiasvlevi6647 5 лет назад +1

    15:36 I don't know why but I had to write " this.body = Matter.Bodies.circle(x, y, r/2); " dividing radius by 2. Is it possible that they updated the way matter.js works and made it the diameter input instead of radius?

    • @DragonSparks
      @DragonSparks 5 лет назад +1

      I feel like your right, but the api still has it as radius, maybe they havent updated the api? I was having the issue of it floating over the ground

  • @toxiczappyt5937
    @toxiczappyt5937 4 года назад +1

    why is my bird floating

  • @FroyoAnto
    @FroyoAnto 5 лет назад +6

    you need a shorter drumroll sound.

  • @cutipets8706
    @cutipets8706 5 лет назад

    wooow that's amazing

  • @anuraghazra4772
    @anuraghazra4772 5 лет назад +4

    Next Coding Challenge: Full Fledged Physics Engine With SAT Collision Detection And Resolution

  • @kavyagandhi8839
    @kavyagandhi8839 4 года назад

    bro you are best

  • @Hello_There820
    @Hello_There820 2 года назад +1

    (Please Ignore)
    25:04

  • @Robber7
    @Robber7 5 лет назад +2

    Could you do a video of depolying processing applications on Android? I couldn't get it to work that well unfortunately.

  • @melody3741
    @melody3741 4 года назад

    Wait u til mouse press set a flag the flag looks for mouse release and then once that happens it waits until the ball crosses the center point i.e. string is length 0 it releases.

  • @matthewsmeets
    @matthewsmeets 5 лет назад

    Imo you could have used a decorator instead if inheritance

  • @sugiono2801
    @sugiono2801 5 лет назад +2

    next coding fps game with js

    • @joogps
      @joogps 5 лет назад

      have you ever seen that guy who made an online fps game only with HTML and CSS? keithclark.co.uk/labs/css-fps/

  • @bernardorodrigues8848
    @bernardorodrigues8848 3 года назад +1

    Super late to the party, I know, but is there a reason not to have the this.body.isStatic in the box constructor, and so when you create a new box you just tell it if it’s true or false?

  • @unlikelysalmon786
    @unlikelysalmon786 5 лет назад

    Heya, I was just wondering why you sometimes use function and sometimes use classes when you can just do both with function. Is there a difference, and if so, is it important enough to use both?
    Edit: great video btw

    • @DrBlort
      @DrBlort 5 лет назад +1

      Think of OOP as a way to model a problem, which is closer to how we (humans) think. You could resolve all programming problems with just variables, loops, conditionals, and functions (and maybe even without functions), which in the end is how CPUs work.
      When you model your data and behaviours in classes, you're making it easier for you to think about a solution. A classic example would be to model a car, which has an engine, and wheels, all interconnected, and you can only accelerate, brake, or steer. Otherwise, imagine having a chassis, an engine, and wheels, and having access to their innards, and moving everything with wire and by hand :D

  • @Adam-rt1lc
    @Adam-rt1lc 5 лет назад

    Bonne vidéo!!!

  • @WEBSTART-LIVE
    @WEBSTART-LIVE 4 года назад

    спасибо за русские субтитры!)

  • @pasirbedog124
    @pasirbedog124 5 лет назад

    The coding train Vs all coding challenge

  • @sorrychou
    @sorrychou 5 лет назад

    👍👍👍厲害!

  • @grainfrizz
    @grainfrizz 5 лет назад

    I don't like the setTimeOut. I think it should release when the tension between the bird and the line reaches 0 Newton.

  • @gustavsanimations7556
    @gustavsanimations7556 4 года назад

    *SHOOTING RELEASE PROBLEM FIXED.* if the bird is in a given radius of pointA then remove the SlingShot

  • @xFaull
    @xFaull 5 лет назад

    help 19:00
    matter-js: MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected
    i dont know why but when i type mouse: mouse it doesnt let me move the ball but i figured if i type Mouse: mouse it does but comes up with the warning above

    • @CodeBlue-le2sf
      @CodeBlue-le2sf 5 лет назад

      Same... Did you ever figure it out im just now watchong this?

  • @alexandrezuppo2095
    @alexandrezuppo2095 4 года назад

    AMAZING
    😂😂😂😂😂😂

  • @mehediabdullah2693
    @mehediabdullah2693 5 лет назад +1

    Sir, can you provide some ui and backed with firebase and ui with p5.js..
    suppose where menu screen need to click and go to game screen

  • @liamasman
    @liamasman 5 лет назад

    woooo!

  • @proyas21
    @proyas21 3 года назад

    4:00 lol🤣

  • @GuillemRibes-w7y
    @GuillemRibes-w7y 5 лет назад

    I actually have an error. In around the minute 19:00 Dan writes code that is able to move the bird object around and toss it. This rarely works for me and it grabs the bird when the cursor isn't even on it! I think that this has to do with the scale but I can't think of anything else, if anybody who has also had this problem or have been able to do this challenge anyway, please help. Thanks

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Oh! Are you on a "high pixel density display" by any chance? Try adding the following:
      mouse.pixelRatio = pixelDensity();

    • @adk_88
      @adk_88 4 года назад

      @@TheCodingTrain I had the same problem on a 4k display, this fixed it. Thanks !

  • @thebarnold7234
    @thebarnold7234 4 года назад

    Update! Your code throws an error
    "
    Event {isTrusted: true, constructor: Object}
    isTrusted: true
    : "Event"
    name: "Event" "
    May wanna fix it, I was watching this and wanted to try it out lol.