Make Your Game Fair With i-Frames @Frankslaboratory
Make Your Game Fair With i-Frames  @Frankslaboratory
Uploaded May 2026 | Updated September 2026, 1 week ago
Don't make your players throw their keyboards. In this episode, we fully implement invincibility frames (i-Frames) in our JavaScript 2D game. i-Frames are the short window of immunity after taking damage that prevents players from being instantly destroyed by overlapping hits. We also add a smooth blinking opacity animation using a sine wave to visually signal invincibility, and wire up a complete game over loop with a panel, sounds, and play again/quit buttons.

This is part of a full vanilla JavaScript game development series, where we’re building a reusable starter kit step by step: youtube.com/playlist?list=PLYElE_rzEw_tjnJ_5gzRw0ZM5HRn7AIS0&si=j53kz7v7JoN5dg1B

What we cover:
iFrame logic inside the takeDamage() method
Invincibility timer driven by delta time
Flickering opacity effect using Math.sin() and Math.abs()
isDead() helper and player died event system
Game over state, HUD hide, and panel display
Play Again and Quit button wiring

Resources:
Source code: code-laboratory.kit.com/f08d3d0aa8
Audio:
šŸŽµ player_hurt.mp3: frankslaboratory.co.uk/downloads/147/player_hurt.mp3
šŸŽµ game_over.mp3: frankslaboratory.co.uk/downloads/147/game_over.mp3
šŸŽµ mission_complete.mp3: frankslaboratory.co.uk/downloads/147/mission_complete.mp3

ā± Timestamps
00:00 What Are Invincibility Frames & Why They Matter
01:00 Source Code Checkpoint (P18)
01:31 iFrames: Logic, Timer & Blink Animation
06:58 Game Over Screen: State, Panel & Sound
11:15 Full Damage Pipeline Explained
13:31 What's Next?

If this series is helping you, a like really does help the channel grow and drop a comment telling me what style of game you'd like to build next: pixel art, hand-drawn, or something else entirely. I read every one.
Make Your Game Fair With i-FramesState 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 Enemies
Franks laboratory |

Make Your Game Fair With i-Frames

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER