State Management in Games @Frankslaboratory
State Management in Games  @Frankslaboratory
Uploaded December 2021 | Updated September 2026, 1 week ago
It's really fun designing special abilities and controls for animated video game characters. When you start building bigger, more exciting games full of special features, you will be faced witch challenges game developers have been dealing with since the 80's. How to keep code organised and easy to debug? How to keep it clean. Over time people came up with general reusable solutions to commonly occurring problems, these well tested and widely used code structures are called design patterns. Design patterns are a toolkit of tried and tested solutions to common problems in software design. So let's use state design pattern today to apply state management to a player character in a 2D side-scroller game. Have fun! :)

โค Related Links โค
Art by bevouliin.com check out their website for more game art assets :)
Download project sprite sheet:
๐Ÿ• frankslaboratory.co.uk/downloads/dog_left_right_white.png
Backup link: ibb.co/dpCW91M

โญ๏ธTutorial Contents โญ๏ธ
00:00 What are design patterns and why use them
03:19 HTML and CSS setup
04:21 Native JavaScript modules
05:01 How to use Live server VS code extension
07:38 JavaScript setup
08:47 Player class
11:13 How to export and import JavaScript modules
13:20 Drawing player
16:39 Keyboard inputs with input handler class
22:33 Utility functions
24:26 Applying state design pattern to player
45:33 Sitting
49:42 Running
53:55 Jumping
01:00:25 Falling
01:04:03 Sprite animation
01:05:47 Control FPS with timestamps and delta time

You could split design patterns into 3 main categories:
CREATIONAL patterns provide us with different object creation mechanisms
STRUCTURAL patterns help us to assemble objects into flexible and efficient code structures
BEHAVIOURAL patterns that deal with communication and assigning responsibilities between objects
In this class we will use state design pattern to control player character in a game. It's a behavioural design patter that lets an object alter it's behaviour when it's internal state changes.

๐Ÿ”ฅ I really like these GAMEDEV and GAME ART courses on Udemy ๐Ÿ”ฅ
โ˜• 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

๐ŸŽฎ 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 *** this video ***
๐Ÿถ Project 10: Easy Side-Scroller Game youtu.be/7JtLHJbm0kA

๐ŸŽฎ More HTML5 canvas and JavaScript game tutorials:
youtube.com/playlist?list=PLYElE_rzEw_sowQGjRdvwh9eAEt62d_Eu

BEGINNER creative coding playlist with HTML, CSS & JavaScript:
youtube.com/playlist?list=PLYElE_rzEw_v8TXJ_ITSSBP_ypUKfQ7K-

ADVANCED creative coding project tutorials with vanilla JavaScript & HTML5 canvas:
youtube.com/playlist?list=PLYElE_rzEw_siuo-kkHh5h7Sk--6IPYNh

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

Music: (YouTube audio library) Vacay In Fiji Riddim - Konrad OldMoney
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
State Management in GamesJavaScript 2D Game TutorialCreative CSS3 CheckboxThe Math Behind Game CollisionsWhat are flow fields #SHORTSDrawing Star Wars Droid With CSS - Animated Background Tutorial, CSS3 Web Design Ideas For BeginnersJavaScript Flappy Bird with Particles & SpritesNext Level Vanilla JavaScript UI AnimationsCSS Filters - SVG Turbulence Filter Animation [ CSS3 Creative Menu Hover Effects ] SquigglevisionCSS Login Form Animation With Wave Placeholder Text Effect - CSS3 & HTML5 Tutorial for BeginnersJavaScript Game Tutorial - Many Different EnemiesAnimated CSS Button Hover Tutorial | SVG Icons Drawing Effect
Franks laboratory |

State Management in Games

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER