[Intro] Hello Fellow Bug Squishers! And welcome to
this special bug fixing episode of our raycaster series. There have been a bunch of common issues
reported over the last 6 episodes, so I’m hoping this this video will help round up most of them
and get everyone up to date! Each issue & fix has it’s own chapter, so let’s just jump
right in and summarise what fixes are coming up! Fix number 1 is for “Small Player Syndrome” (all
the way back from episode 2) – This is where only the top half of the level is drawn. Makes us look
really small, or the level is towering above us! Fix number 2 – Is for when only one type of
Entity appears in our game even when we should see nanos, franks & even
collectables – This was since episode 4 Fix number 3 – Is for the Mysterious extra
Entity bug – Where this mystery entity we didn’t add would appear in your level
Fix number 4 – Is for Entities clinging to the edge of the screen, yeah I don’t like that!
Fix 5 - Help – My walls have turned into Sprites! – Looks amazing, but just… amazingly wrong!
And finally fix number 6 – “For those who want more than 9 entity costumes” – More
of a feature request than a bug, but we’ll cover that quicky here anyhow.
So these the ones we are going to fix today. Let’s get bug squishing!
[1. Small Player Syndrome] Fix number 1 is for “Small Player Syndrome”. This
problem has been reported to me many times since episode 2.
This is where the level’s walls appear to only come halfway down the screen.
It makes it feel like the plater is really small! But it’s a simple fix
In the raycaster sprite, under the Single Ray script. The cause for this is that you’ve probably
used a “change y by” block in here when drawing your line, and with good reason,
after all that’s often how we do things. But in this case I sneakily used another “set
y to” block. A pen line will always draw between the previous and new position, and you don’t need
to use a change for that to happen. Check it out… There splendid,
our walls are drawing as intended. [2. Only one type of Entity Showing up]
Fix number 2 – When all entities are showing up with the same costume.
Yep, all nanos, franks & even collectables appear as Nanos… This was since episode 4,
and this one was my bad! – So unless you caught my fix posted in the community tab, then you will
be wondering what you did wrong - I’m so sorry! So what did we miss? Click into the Pen sprite.
If we look at the Draw Row script. Here you can see any “type” less than 10 represents an entity
(that is a costume to be stamped). But… if you look at the stamp script,
you’ll see we omitted to switch the sprite’s costume before we stamp, so we only get one
type of entity costume showing up in game. No problem. Before we position the sprite,
switch costume to… And we pop in that same type variable.
Smashing the green flag, and there you go – So simple, you can see collectables, Nanos’
and Franks are now all present and correct. [3. Mysterious extra Entity Appearing on Level]
Fix number 3 – Is for the Mysterious extra Entity bug – Some of you have
noticed a mysterious entity showing up in your game, and it doesn’t move. Also,
it can be seen to switch costumes erratically… Yeah – there it is, can you see them?
When we coded our entity sorting scripts, we stuffed a blank item into the list to
initialise it. This blank entity was needed to simplify the sorting code, but the blank tow
is now showing up as a naughty random costume. The fix is to just get Scratch to ignore the blank
item. In the Pen sprite, Add an IF to the top of the Stamp Entity Script. Checking if the type
is the blank value. And if it is, we use a stop this script to avoid painting it to the screen.
Testing that now, and the mysterious entity is nowhere to be found! Great stuff.
[4. Entities cling to the edge of the screen] Fix number 4 – Is for Entities clinging to the
edge of the screen. This one is annoying to see too. Especially with the bigger entities like
Frank, you can sometimes see their costume clinging to the edge of the screen even when
they obviously should be fully off screen. This is just Scratch doing what Scratch does,
as it tries to stop sprites going off screen. We can fix this, again under the Stamp
Entity script in the Entity sprite. What happens is that we ask scratch
to position the sprite at x, but instead Scratch places it so that the sprite is still
just on screen. That means the x position doesn’t get set to the value we asked it to.
That makes for a reasonably easy fix. Surround the “set brightness and stamp” with an IF check.
Then subtract the x position from the x variable. That gives the difference
in position. Then use an abs block to flip any negative differences, and check whether the answer
is less than 1 pixel away. Job done. Now the sprite is not stamped when it goes off screen.
[5. Help – My walls are all Sprites!] Fix 5 – Help – My walls have turned into
Sprites. Woo-hoo, this is a good one! I know a number of you have been getting this bug!
It looks really funny, and it’s easy to explain.
In our Raycaster sprite, under the Single Ray script, We have entered the wall colours as
numbers in the Draw blocks, here and here. Now if you’ve used any number under 10, then
I’m afraid rather than being a nice red colour as you probably intended, we get entities appearing
instead. Remember we now use numbers 1 to 9 to store our entity costumes in this same list. But
because colour hues are cyclic. All we need to do is add 101 to the desired colour,
and hey presto, we get our red colour back! No more random glorious repeating entity craziness.
[6. I want more than 9 entity costumes] And finally fix number 6 – “For those who want
more than 9 entity costumes”. This is more of a feature request than a bug fix – If
we come into the Pen sprite, you can see that we only treat “types” less than 10
as entities. But this limits us to 9 different entity types, or costumes to be stamped.
So what if we want more? Well, no problem, we can boost this number up to 100… Giving us 99
entity types to play with. The downside of this, is that we must make sure to add 101 to all our
colour values that are less then 100 in the Raycaster sprite, using the “draw” block.
[Outro] Cool – That’s all the fixes at this time,
I’ll watch the comments and try to pick up any other issues that come up a lot.
But for now, get yourselves up-to-date, because the official episode 7 is also in production
and will be out shortly! I’m so excited too! We’re finally getting texture mapped walls into
our ray casters amazing!!! Come on!!! If you are as excited as me,
and want to catch it before everyone, then do consider joining the early access membership.
Not only do you get great perks, and early access to all my videos, but doing so also
directly supports this channel and helps me make more of these awesome videos! So win win!
Please smash the like button if you enjoyed the video or want to keep
this series going! And I’ll see you all soon, Have a great week ahead, and Scratch on Guys!