Uploaded January 2022 | Updated November 2026, 2 days ago
Making mobile friendly games with vanilla JavaScript can be easy, if you understand how to use touch events to calculate direction and distance of swipes. As a bonus I will show you how to use brand new JavaScript full-screen feature. It's quick and easy.
PART 1: youtu.be/7JtLHJbm0kA
โญ๏ธTutorial Contents โญ๏ธ
00:00 Final project preview
00:19 Simulate mobile devices with Device Mode
02:19 Restart game function
04:46 touchstart, touchmove and touchend events
07:14 How to use touch events to calculate swipe direction
12:45 How to use JavaScript Fullscreen API
16:53 How to resize and reposition hitboxes
๐ฎ Game Development MASTERCLASS SERIES with vanilla JavaScript, basics for beginners: ๐ฎ
๐ถ Project 1: Sprite animation youtu.be/CY0HE277IBM
๐ถ Project 2: Parallax backgrounds youtu.be/Mg7ibYWhjPI
๐ถ Project 3: NPC movement youtu.be/pyhb8Y9qKUI
๐ถ Project 4: Rectangle collision youtu.be/r0sy-Cr6WHY
๐ถ Project 5: Circle collision youtu.be/rtBCVe3j_24
๐ถ Project 6: Triggered event based animations youtu.be/Eg_zUEy_lDE
๐ถ Project 7: Raven game youtu.be/gCa0z4B-CRo
๐ถ Project 8: Enemy types youtu.be/aEDADLtLEbk
๐ถ Project 9: State Management youtu.be/jKe44NeFzwE
๐ถ Project 10: Easy side-scroller game youtu.be/7JtLHJbm0kA
๐ถ Project 11: *** this video ***
๐ฅ I really like these courses on Udemy ๐ฅ
โ The Web Developer Bootcamp (Colt Steele, 2022 update) bit.ly/2ZZJM0d
โ JavaScript Basics for Beginners bit.ly/32Tn5wq
โ Object-oriented Programming in JavaScript bit.ly/3f4Otu0
โ The Complete JavaScript Course 2022: From Zero to Expert! bit.ly/3fXGwaZ
โ JavaScript - The Complete Guide 2022 (Beginner + Advanced) bit.ly/37Hlxqq
โ JavaScript: The Advanced Concepts (2022) bit.ly/2Uk6Wyk
โ JavaScript: Understanding the Weird Parts bit.ly/2WVe0zn
โ Modern HTML & CSS From The Beginning (Including Sass) bit.ly/2Ec6Cch
โ 20 Web Projects With Vanilla JavaScript bit.ly/3anlCQR
GAMEDEV and GAME ART:
โ How to Program Games: Tile Classics in JS for HTML5 Canvas bit.ly/2ZUfKuG
โ Learn Professional 2D Game Graphic Design in Photoshop bit.ly/2SpPdE8
โ The Ultimate 2D Game Character Design & Animation Course bit.ly/3eoZWqT
โ Produce Professional Pixel Art for Your New Game bit.ly/3nUrTKm
My FREE courses on UDEMY:
โ HTML Canvas Crash Course bit.ly/3y8yAgz
โ Sprite Animation Deep Dive bit.ly/2Q9BG2K
Let's be friends
๐ You can message me on TWITTER twitter.com/code_laboratory
๐ Check out some of my source code on CODEPEN codepen.io/franksLaboratory
โค Related Links โค
Art by bevouliin.com check out their website for more game art assets!
Download project sprite sheets:
๐ Player: frankslaboratory.co.uk/downloads/93/player.png
๐ณ Background: frankslaboratory.co.uk/downloads/93/background_single.png
๐ฆ Enemy: frankslaboratory.co.uk/downloads/93/enemy_1.png
Backup links:
Background ibb.co/jrpX7BY
Enemy ibb.co/FxFC9mF
Player ibb.co/z51dQS0
Music: (YouTube audio library) Dub Hub - Jimmy Fontanez Media Right Productions
The description of this video may contain affiliate links, which means that if you buy one of the products that I recommend, I'll receive a small commission without any additional cost for you. This helps to support the channel and allows me to continue making videos like this. Thank you for the support!
#frankslaboratory
Making mobile friendly games with vanilla JavaScript can be easy, if you understand how to use touch events to calculate direction and distance of swipes. As a bonus I will show you how to use brand new JavaScript full-screen feature. It's quick and easy.
PART 1: youtu.be/7JtLHJbm0kA
โญ๏ธTutorial Contents โญ๏ธ
00:00 Final project preview
00:19 Simulate mobile devices with Device Mode
02:19 Restart game function
04:46 touchstart, touchmove and touchend events
07:14 How to use touch events to calculate swipe direction
12:45 How to use JavaScript Fullscreen API
16:53 How to resize and reposition hitboxes
๐ฎ Game Development MASTERCLASS SERIES with vanilla JavaScript, basics for beginners: ๐ฎ
๐ถ Project 1: Sprite animation youtu.be/CY0HE277IBM
๐ถ Project 2: Parallax backgrounds youtu.be/Mg7ibYWhjPI
๐ถ Project 3: NPC movement youtu.be/pyhb8Y9qKUI
๐ถ Project 4: Rectangle collision youtu.be/r0sy-Cr6WHY
๐ถ Project 5: Circle collision youtu.be/rtBCVe3j_24
๐ถ Project 6: Triggered event based animations youtu.be/Eg_zUEy_lDE
๐ถ Project 7: Raven game youtu.be/gCa0z4B-CRo
๐ถ Project 8: Enemy types youtu.be/aEDADLtLEbk
๐ถ Project 9: State Management youtu.be/jKe44NeFzwE
๐ถ Project 10: Easy side-scroller game youtu.be/7JtLHJbm0kA
๐ถ Project 11: *** this video ***
๐ฅ I really like these courses on Udemy ๐ฅ
โ The Web Developer Bootcamp (Colt Steele, 2022 update) bit.ly/2ZZJM0d
โ JavaScript Basics for Beginners bit.ly/32Tn5wq
โ Object-oriented Programming in JavaScript bit.ly/3f4Otu0
โ The Complete JavaScript Course 2022: From Zero to Expert! bit.ly/3fXGwaZ
โ JavaScript - The Complete Guide 2022 (Beginner + Advanced) bit.ly/37Hlxqq
โ JavaScript: The Advanced Concepts (2022) bit.ly/2Uk6Wyk
โ JavaScript: Understanding the Weird Parts bit.ly/2WVe0zn
โ Modern HTML & CSS From The Beginning (Including Sass) bit.ly/2Ec6Cch
โ 20 Web Projects With Vanilla JavaScript bit.ly/3anlCQR
GAMEDEV and GAME ART:
โ How to Program Games: Tile Classics in JS for HTML5 Canvas bit.ly/2ZUfKuG
โ Learn Professional 2D Game Graphic Design in Photoshop bit.ly/2SpPdE8
โ The Ultimate 2D Game Character Design & Animation Course bit.ly/3eoZWqT
โ Produce Professional Pixel Art for Your New Game bit.ly/3nUrTKm
My FREE courses on UDEMY:
โ HTML Canvas Crash Course bit.ly/3y8yAgz
โ Sprite Animation Deep Dive bit.ly/2Q9BG2K
Let's be friends
๐ You can message me on TWITTER twitter.com/code_laboratory
๐ Check out some of my source code on CODEPEN codepen.io/franksLaboratory
โค Related Links โค
Art by bevouliin.com check out their website for more game art assets!
Download project sprite sheets:
๐ Player: frankslaboratory.co.uk/downloads/93/player.png
๐ณ Background: frankslaboratory.co.uk/downloads/93/background_single.png
๐ฆ Enemy: frankslaboratory.co.uk/downloads/93/enemy_1.png
Backup links:
Background ibb.co/jrpX7BY
Enemy ibb.co/FxFC9mF
Player ibb.co/z51dQS0
Music: (YouTube audio library) Dub Hub - Jimmy Fontanez Media Right Productions
The description of this video may contain affiliate links, which means that if you buy one of the products that I recommend, I'll receive a small commission without any additional cost for you. This helps to support the channel and allows me to continue making videos like this. Thank you for the support!
#frankslaboratory




![How to Make a Game with JavaScript and HTML Canvas | Keyboard Input & Sprite Animation [Vanilla JS]
Do you like pixel art? In this episode of my game development series I will show you how to make a game with JavaScript and HTML canvas from scratch with no libraries. We will learn more about sprite animation, keyboard input and we will build custom algorithm to control how often request animation frame method serves frames of animation loop using Data.now() JavaScript method. All with vanilla JS.
We will practice JavaScript techniques that are useful for web development in general, not just for games. We are front end web developers and these exercises are here to help up us to improve our skill set and learn new things. We will focus on event listeners, array manipulation and pulling and handling data stored in an object and while doing that will learn how to create a player character and move it around canvas with keyboard.
If you want source code to my tutorials I have made some of my videos available on live coding platform Eversparked. You can watch my videos with LIVE browser preview and live code that can be copied and adjusted at any stage. I really like the project idea, I wish I had a tool like that when learning hot to code. Let me know what you think https://bit.ly/3djMrF6
You can message me on TWITTER https://twitter.com/code_laboratory
Check out some of my source code on CODEPEN https://codepen.io/franksLaboratory
Sprite sheets:
http://untamed.wild-refuge.net/rmxpresources.php?characters
ALTERNATIVE BACK UP FILES since the original site is down, let me know when the site is back up please
https://www.frankslaboratory.co.uk/downloads/chewie.png
https://www.frankslaboratory.co.uk/downloads/starwarssprites.zip
Backup link: https://ibb.co/Pj24jSz
Background image:
https://pixeldra.in/u/ZhZrYLJR
https://www.frankslaboratory.co.uk/downloads/tattooine_game_background.png
https://ibb.co/jzY654g
In the previous episode I just placed the background image in our game using CSS, this time we will do it properly and draw game background on canvas. Since we are using simple pixel art sprites we want to be able to set custom fps to request animation frame method, by default the animation will be extremely fast on most modern computers and characters will be zooming across the screen and especially sprites will be animating way too fast. There is a way to throttle sprite animation with algorithm.
We could also simply slow down our game by using custom set interval instead of using request animation frame, but lets do it the proper way and employ the best practices, I will show you an algorithm that will allow us to set FPS for our game in milliseconds, which will be consistent across all machines regardless of how strong users computer is using data.now JavaScript method.
I have pure vanilla JavaScript animation series, in each tutorial we create all different kinds of interactive animated effects from scratch. No plugins, no libraries, no frameworks. Every line of code is explained to give you hands on experience and teach you as much JavaScript as possible. If you want more creative JavaScript tutorials, HTML canvas animations, interactive animated effects to code along, video guides for beginners as well as advanced pure vanilla JavaScript, check out the playlist here:
https://www.youtube.com/watch?v=afdHgwn1XCY&list=PLYElE_rzEw_siuo-kkHh5h7Sk 6IPYNh
For more creative vanilla JavaScript tutorials, CSS tricks, HTML canvas animations, front end web development and web design guides, subscribe to the channel and click the bell icon to get notified when I release a new video.
If you want to improve your Front End Web Developmnent skills, check out my CSS tutorial series where we explore animations and effects that can be done with modern CSS3 techniques:
https://www.youtube.com/watch?v=loKyT99W2s8&list=PLYElE_rzEw_t2O2DvfopIoq-diTgefVzV
#javascript #html5canvas #frankslaboratory
The description of this video may contain affiliate links, which means that if you buy one of the products that I recommend, Ill receive a small commision without any additional cost for you. This helps to support the channel and allows me to continue making videos like this. Thank you for the support! How to Make a Game with JavaScript and HTML Canvas | Keyboard Input & Sprite Animation [Vanilla JS]](https://i.ytimg.com/vi/EYf_JwzwTlQ/mqdefault.jpg)




![Learn JavaScript By Building Games | How To Make A Game With Vanilla JS [Frogger]
In todays creative coding tutorial we will learn JavaScript by building games. I will teach you how to make a game with vanilla JS and HTML canvas element all from scratch with no libraries. We will focus on collision detection, keyboard input, frame-rate optimization and sprite animation, but every technique we learn can be used for other web development projects as well, not just for games. The skills and techniques I am about to teach you today will help you build your own unique games faster, but you can also apply them in any other JavaScript project, we are using pure vanilla JavaScript so everything we learn here are transferable skills.
LIKE the video please if youre getting value out of my tutorials and SUBSCRIBE if you want to learn more vanilla JavaScript!
Some of my favorite UDEMY courses:
*** Creative coding ***
How to Program Games: Tile Classics in JS for HTML5 Canvas https://bit.ly/2ZUfKuG
Next Level CSS Creative Hover & Animation Effects https://bit.ly/3jEkzju
*** CSS / Front-end web development ***
The Web Developer Bootcamp (Older but still very relevant) https://bit.ly/2ZZJM0d
Modern HTML & CSS From The Beginning (Including Sass) https://bit.ly/2Ec6Cch
Advanced CSS and Sass: Flexbox, Grid, Animations and More! https://bit.ly/3g0uqxT
*** Vanilla JavaScript from beginner to advanced ***
JavaScript Basics for Beginners https://bit.ly/32Tn5wq
JavaScript: Understanding the Weird Parts https://bit.ly/2WVe0zn
The Complete JavaScript Course 2020: Build Real Projects! https://bit.ly/3fXGwaZ
Modern JavaScript From The Beginning https://bit.ly/3fWJgWk
Object-oriented Programming in JavaScript https://bit.ly/3f4Otu0
Recommended book: Game Programming Patterns https://amzn.to/2ZlnplB (Amazon)
If you are really interested in game development check out this book. Its written in pseudo-code so it can be used for any programming language, if you are able to follow this video you will be able to use this book. It covers game development concepts that will eventually help you how to create much more complicated games, frogger game we are building today is very basic, but it is a nice project for beginners to practice JavaScript on.
Sprites & background images:
Project files:
All files zip: https://www.frankslaboratory.co.uk/downloads/Frogger/Frogger.zip
Individual files:
Background https://www.frankslaboratory.co.uk/downloads/Frogger/background.png
Background 2 https://www.frankslaboratory.co.uk/downloads/Frogger/background_lvl2.png
Background 3 https://www.frankslaboratory.co.uk/downloads/Frogger/river_bank.png
Background 4 https://www.frankslaboratory.co.uk/downloads/Frogger/grass.png
Frogger spritesheet https://www.frankslaboratory.co.uk/downloads/Frogger/frog_spritesheet.png
Cars https://www.frankslaboratory.co.uk/downloads/Frogger/cars.png
Collisions https://www.frankslaboratory.co.uk/downloads/Frogger/collisions.png
Turtles https://www.frankslaboratory.co.uk/downloads/Frogger/turtles.png
Log https://www.frankslaboratory.co.uk/downloads/Frogger/log.png
This tutorial is part of a series - COMPLETE PLAYLIST:
https://www.youtube.com/watch?v=lGJ9i6CYKyQ&list=PLYElE_rzEw_siuo-kkHh5h7Sk 6IPYNh
Today we are going to take things we have have learned in this series so far - and create a bigger polished game you can show off on your coding portfolio or personal website. It is a remake of classic Konami arcade game released in 1981, it received a popular sequel for PC and PlayStation 1 in 1997 and there are multiple clones for this game concept like go chicken go. Lets build FROGGER! :)
Tools I use:
Adobe Creative Cloud https://bit.ly/3e60cI0 (official Adobe website to buy Creative Suite applications)
Recommended channel: Ania Kubรณw #JavaScriptGames
https://www.youtube.com/channel/UC5DNytAJ6_FISueUfzZCVsw
You can message me on TWITTER https://twitter.com/code_laboratory
Check out some of my source code on CODEPEN https://codepen.io/franksLaboratory
#javascript #htmlcanvas #frankslaboratory
Music:
Business / Corporate by Mixaund | https://mixaund.bandcamp.com
Music promoted by https://www.free-stock-music.com
The description of this video may contain affiliate links, which means that if you buy one of the products that I recommend, Ill receive a small commission without any additional cost for you. This helps to support the channel and allows me to continue making videos like this. Thank you for the support! Learn JavaScript By Building Games | How To Make A Game With Vanilla JS [Frogger]](https://i.ytimg.com/vi/GXvNEwu9cgM/mqdefault.jpg)
