02:06Coding Challenge #94: 2048 - Part 1
From the creator
In this multi-part coding challenge, I code the sliding puzzle game 2048 in JavaScript using canvas and p5.js. Code: https://thecodingtrain.com/challenges/94-2048 ๐น๏ธ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/aeIk9JZ-U Other Parts of this Challenge: ๐บ 2048 - Part 2: https://youtu.be/8f8P1i0W26E ๐บ 2048 - Part 3: https://youtu.be/3iYvT8TBIro ๐บ 2048 - Part 4: https://youtu.be/vtMKeEGpMI4 ๐ฅ Previous video: https://youtu.be/uWzPe_S-RVE?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ฅ Next video: https://youtu.be/5cNnf_7e92Q?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ฅ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH References: ๐พ 2048: https://gabrielecirulli.github.io/2048/ ๐ 2048 on Wikipedia: https://en.wikipedia.org/wiki/2048_(video_game) Videos: ๐ด Coding Train Live 122 https://youtu.be/ze_o4YvZ6-s?t=5648s Related Coding Challenges: ๐ #142 Rubik's Cube: https://youtu.be/9PGfL4t-uqE ๐ #149 Tic Tac Toe: https://youtu.be/GTWrWM1UsnA ๐ #165 Slide Puzzle: https://youtu.be/uQZLzhrzEs4 Timestamps: 0:00 Introducing today's topic: 2048 sliding puzzle game 2:50 How does the game work? 5:16 Let's Code! 6:10 Write an addNumber function 8:12 Use the ternary operator to pick either a 2 or 4 9:54 Draw the board 14:38 Write a slide function 18:10 Add a keyPressed function to slide the numbers 19:13 Write a combine function 25:23 Write an operate function 31:29 Check to see if a number has moved 33:09 Write a function to compare two
Published 2018-02-26 ยท Watch on YouTube โ
Availability and playback restrictions are controlled by the original channel.





