ULTRA FAST Raycasting in Scratch - Unmissable E6 Update

252,136
0
Published 2022-04-12
How to make a simple 3d game (Raycaster) in Scratch. This update episode can be slotted in anywhere after episode 2 and gives us a huge speed boost in our bitmap raycasting speeds! You won't believe it - I didn't!!! We also add an FPS counter, and implement framerate independent movement for the player and enemies in the game.
With the extra speed we have achieved we are all set to now look at adding texture mapping! I hope you are ready for some serious fun!

Don't forget to submit your projects to the studio linked below by commenting the project URL in the studio comments.

My tutorials are for all budding game & software developers using Code Blocks. Scratch On guys!

👀 Next Episode 7 -    • How to TEXTURE MAP Walls | Raycasting...  
🔥 Bug Fixes -    • Quick Fixes for Raycasting Ep.2-6 wit...  

⭐ Channel membership with perks - youtube.com/channel/UCawsI_mlmPA7Cfld-qZhBQA/join

🐱 Scratch Studio for this tutorial - scratch.mit.edu/studios/31438766/comments
👀 Part 1 -    • Crazy Simple Raycasting E1 - 🎮 How to...  
👀 Full Episode Playlist -    • Crazy Fun Raycasting (3D Scratch Tuto...  

👀 Quick and Fun Tutorials -    • Quick and Fun Scratch Tutorials  

❤️ Scratch Addons - scratchaddons.com/
📹 Video Editing Software - techsmith.pxf.io/c/2682566/506622/5161

-------------Video Chapters-------------
0:00 Intro
0:56 FPS
4:44 Fix for Transparent Walls – Oops
6:11 Framerate independent movement
8:39 Quick win – reduce number of pixels scanned
12:15 Why bitmap raycasting is slow
13:11 Proximity Based Ray Skipping
17:59

All Comments (21)
  • @Resseguie
    Separate question. Can you explain the trick behind using BIG and setting to 1% as opposed to just setting a percent on the original hitbox? I guess I would have thought 1% was 1% of the costume canvas regardless. Sounds like I need to look at the docs on Set Size.
  • @Probably_Daniel
    I cannot believe that a Scratch tutorial channel successfully rickroll'd me.
  • @N8-Squared
    Oh my god that is such a better way to do deltatime than what I was doing. I was just doing DELTA = timer and then resetting the timer, which gives you .033 which is terrible for getting exact values. I'm going to keep this video in mind.
  • @ItsMe-fr6em
    There is actually an algorithm called “ray marching” which states on moving ray checker at a distance to the closest opaque point of the scene every ray iteration. It is usually used with SDF-models (models defined as signed distance functions to them from the point of the space), but in your case you could pre-calculate an approximate 2D distance field map before launching the game and use it as a giant SDF of the whole level.
  • @real4kGaming
    I never thought I would be Rick rolled by a 3d game tutorial
  • I never thought I'd see rick astley on a wall in a scratch pen raycaster. You continue to amaze me, and probably the scratch team as well. I could never have thought of doing stuff like that.
  • @Harry_Pottery
    Hi! I'm just wondering how you would be able to create tunnels (that don't touch the floor and/or reach the ceiling) since the 3D world is being created from a 2D sprite and is a top-down view of the map?
  • @drevoksi
    This is incredible!!! I love this series so much!
  • @milankarow6567
    I love how the the barebone character of scratch forces you to reveal how performance optimization can be achieved (or rather must be worked for). Something that is usually hidden behind layers of code when working with modern game engines for example. And I also love how this demonstrates how such optimizations use approximations and thus always come at the cost of precision. I wasn't the biggest fan of the raycaster series, since I found it a bit too gimmicky, but this one brings home an important point for me.
  • Dude. I can’t even to begin to express how GENIUS your method is!
  • @Bajbro
    Thank you so much for this video! I made this game on my home account and told all of my friends at school. When they started playing it because our laptops are old the game ran like a snail for them. This video really helps!
  • @fazt1229
    Thanks for making another raycast video! I really love them!
  • @zmggames
    Wow! The texture and floor reflections look crazy! Can’t wait for episode 7!
  • @funkiestcord67
    I'm currently in Italy going back to the UK today, can't wait to do this.
  • @itsredboi7950
    Loving this series! Thanks for providing such amazing tutorials for scratchers!
  • I love this series for scratch because of how easy it is to understand! i made a raycaster following these tutorials, and using what you taught, i EASILY created projectiles that fire when space is pressed, and they kill the enemies! :DDD thank you :DDDD
  • @matjam911
    Awesome! I was doing this tutorial and a slower device and i was truly shocked when it didn't explode at a Resolution Of 1!
  • @Phillip_Anatra
    I am super excited! This more than doubled the speed on my laptop! Unfortunately I've found some bugs, so I might run through the tutorials again to see what I did wrong
  • @monicadua7
    Congrats on 150k! I am not currently following the series, but it looks seriously good for a sprite-based raycaster, How do you think about these tricks, man!