Live Stream #87.3: Timer in JavaScript, Pong and Binary Tree

[ad_1]
In this live episode, I attempt several coding challenges. First I create a countdown timer in JavaScript. Second, I code the classic video game “Pong” in Processing (Java). Finally, I begin examining topics for my “Intelligence and Learning” course with a warm-up on data structures and binary trees.

Edited videos from this live stream coming soon!

7:10 – Work from the community
22:35 – Coding Challenge: Timer in JavaScript
51:55 – Coding Challenge: Pong
2:35:10 – Coding Challenge: Binary Tree
3:19:43 – Visualizing binary tree

Support this channel on Patreon:
To buy Coding Train merchandise:

Send me your questions and coding challenges!:

Contact:
Twitter:
The Coding Train website:

Links discussed in this video:
DIY Light-Up Paper Bow Ties:
Grokking Algorithms book:
The Nature of Code Part 2 (Spring 2017) – Intelligence and Learning:

Work from the community:
Ada Lovecraft’s Smoke:
zimm0r’s AACT Half-Life Simulation:
Jacob Foster’s Corrupted, Grungy, Retro Text and CRT Effect:
Robin Lefebvre’s Bouncy – p5 build – prototype:
Alex’s Double Pendulum:
MrMusAddict’s A Star Road Maker:

Source Code for the all Video Lessons:

p5.js:
Processing:

For an Introduction to Programming:
For my Nature of Code videos:
For More Live Streams:
For More Coding Challenges:

Help us caption & translate this video!


Posted

in

by

Tags:

Comments

26 responses to “Live Stream #87.3: Timer in JavaScript, Pong and Binary Tree”

  1. Lanky Smurph Avatar

    April is also Autism Awareness Month. 😀

  2. Jacob Penney Avatar

    "Suppose you're using simple search to look for a person in the phone book. You know that search takes {/INSERT_CODE_HERE/} time to run, which means in the worst case, you'll have to look through every single entry"

  3. Kopuz Avatar

    if (x1 > x2 && x1 < (x2 + w)) {
    if (y1 > y2 && y1 < (y2 + h)) {
    return true;
    }
    }

  4. Jos W. Avatar

    Haha, I love that bit at 3:35:10! Listen to what Dan says and look at the screen. Anyway, loved the stream as always! 🙂

  5. Lupus Stiger Avatar

    I actually watched the whole AD to contribute something to p5 !

  6. Jonas Avatar

    Everything would be easier with pointers.

  7. neo x Avatar

    how am i install p5 in linux plz help bro

  8. SkeleLordGameR Avatar

    I have asked on stackoverflow about the setInterval part amd what I have been told is that it only adds the functions to the stack, so if the browser is slow, its not going to be accurate as there might be other functions in the stack. That is what I have been told though so dont be so sure.

  9. kyle Avatar

    Question. What language did you use for the pong game?

  10. CDArena Avatar

    The setInterval method is okay for updating the clock, but don't rely on it to calculate the time – instead do something like save the current date-time when you start the timer, and then when the interval event fires, use something like date difference (now) to calculate the remaining time; this will always display the correct time without worrying about particular browser implementations or task busy-ness. Ars Technica recently had an article about an upcoming change to Chrome to increase battery life by suspending background tabs in certain cases. https://arstechnica.com/information-technology/2017/03/chrome-57-background-tab-suspension-download/

  11. 343N Avatar

    you should use strawpoll for quick polls, everyone can vote, much better than twitters polls

  12. P-YAN Avatar

    I think the timer should be allowed to pause if you go to the whiteboard to explain stuff!

    Also it was funny how you weren't going to use OOP originally to keep it "beginner friendly" but spent so long trying to duplicate the paddles' code when you could have just drawn 2.

    Nice stream tho, always fun!

  13. Gerard brun 16 Avatar

    I can't download the J5.js Pleas help me, Give me the instructions to download!!!!!!!!

  14. Life under 60IQ Avatar

    Hello. I tried to make a little advanture game in Notepad++ but in part "SPAWN" it always says"The syntax of the command is incorrect" To get to there in the first enter "a" in the second enter "a" and in the third enret "Ks".
    Please save it a .bat file and tell me what's the problem.
    here is the program:
    echo off
    title advanture game
    color 0e
    echo.
    echo HELLO
    echo This is my first advanture game
    echo I'v ever made so if you find bugs
    echo or the game crash then report the
    echo bug for me.
    echo.
    echo To start the game wrie "start_game"
    echo To end the game write "end_game"
    echo You can quit the game any time during the advanture,
    echo BUT the game won't save
    echo.
    set /p var= Enter here:
    if %var%==start_game goto Menu
    if %var%==end_game goto end_game
    :Menu
    echo STORY
    echo You are in bronze1 pormo with your friend
    echo To get out of the ELO hell you have to
    echo choose the right decisison
    echo if you choose the wrong one you will end
    echo up loosing the game and you will be in
    echo the ELO hell forever.
    echo Good luck!
    echo.
    echo Rules. You will have to choose from
    echo a,b,c, or d
    echo if you won't choose from the
    echo options the game will automaticly close.
    echo And it won't save!
    echo.
    echo To go to the next page write anything
    echo.
    set /p var= You want to start?
    if %var%==Page2 goto goto Page2
    if %var%==end_game goto end_game
    :Page2
    echo ADC AND SUPPORT
    echo.
    echo Help out the jungler or not?
    echo.
    echo a.) Yes b.) No
    echo.
    set /p var= Answer here:
    if %var%==a goto Page3
    if %var%==b goto Bad1
    :Page3
    echo THE LANING
    echo.
    echo 5 minutes passed with farming
    echo stat: 0/0/0 35
    echo.
    echo a.) Farm more b.) Kill Draven and than back.
    echo.
    set /p var= Answer here:
    if %var%==a goto Page4
    if %var%==b goto Dravenkill
    :Bad1
    echo THE JUNGLER DIED
    echo.
    echo The jungler died so he went troll and
    echo you lost the game
    echo BRONZE
    echo start: 0/0/0 0
    echo.
    echo to restart wrie "Menu"
    echo.
    set /p var= Restard game?
    if %var%==restart goto Menu
    :Page4
    echo THE ACTION
    echo.
    echo You farmed 15 more in 2 minutes.
    echo And than… The enemy jungler came
    echo You ended up killing the jungler
    echo But you died as well
    echo After you respawned you went back
    echo to your lane with the support.
    echo stat: 1/1/0 50
    echo.
    echo WRITE: Ks
    echo.
    set /p var= write it here to respawn:
    if %var%==Ks goto Page5
    :Page5
    echo BACK TO LANE
    echo.
    echo Now you are in lane again
    echo and just farming and fanming.
    echo MID needs your help
    echo.
    echo a.)help MID b.)Leave MID alone
    echo.
    set/ p var= what's your choise?
    if %var%==a goto Mid
    if %var%==b goto Losttower
    :Dravenkill
    echo SPAWN
    echo.
    echo You killed Draven and you went back
    echo Stat: 1/0/0 35
    echo.
    echo To go back to lane write: Kss
    echo.
    set /p var= back to lane:
    if %var%==Kss goto Page5
    :Mid
    cls
    pause
    :Ending

  15. Jen Chan Avatar

    differential what…?!

  16. Jen Chan Avatar

    omg this double pendulum is NUTS it's better than my dippy bird!

  17. kongsin pansansou Avatar

    I thought my speaker was broken at first of the video, then tried to increase the volume. LOL

  18. Aniketh Deshpande Avatar

    why you wasting so much of time

  19. Yanick Rochon Avatar

    I'm just gonna paste the codepen I suggested after my comment at 2:15:16 here : http://codepen.io/yanickrochon/pen/dvJbQr 🙂

  20. TechnoChic Avatar

    Dan! Thanks for wearing my TechnoChic DIY Light-Up Paper Bow Tie! — You look great! 🙂 The Kickstarter campaign is still live here: http://bit.ly/bowtiesarecoolitp

  21. MASTER !!! Avatar

    u just explained binary search instead of binary tree..just sayin

  22. JoraForever Avatar

    i was going to watch this video, until i saw its length

  23. João Vitor dos Santos Avatar

    sets a twenty minutes clock
    takes one and a half hour

Leave a Reply

Your email address will not be published. Required fields are marked *