Scratch Tile Scrolling Game | Player Movement (#4)
VloĆŸit
- Äas pĆidĂĄn 22. 07. 2024
- In this Scratch tutorial, I show how to code player movement into the Tile Scrolling game. Now, you can explore your randomly generated worlds!
đš GET THE GAME'S ART: scratch.mit.edu/projects/6921...
Griffpatch's Tile Collision Video: âą Tile Scrolling Platfor...
đ LINKS: All Videos In This Series: âą Scratch Tile Scrolling...
Scratch Profile Page: scratch.mit.edu/users/ShiftCl...
Night Ninja Scrolling Platformer: âą Scratch | Scrolling Pl...
Cat Clicker tutorial: âą Scratch | Cat Clicker ...
Tower Defense tutorial: âą Scratch | Making a Tow...
How-to tutorials: âą Scratch | How-To Tutor...
Get Scratch Addons: scratchaddons.com/
đ§ŸCHAPTERS:
00:00 - Intro
00:35 - Project Setup
01:57 - Creating the Tile Meta
08:40 - Adding All Tile Data
10:13 - Player Setup
13:54 - Getting Player Tile Info
16:05 - Gravity!!!
16:39 - Player Collision
21:17 - Horizontal Movement
25:22 - aNti-gRAvIty (Jumping)
26:25 - Player Animation
28:48 - Outro
â DISCLAIMER:
This video is family-friendly! Hostile and/or rude comments will not be tolerated!
Alrighty, this video is finally out- thank you all so much for watching! â„
first
Second
@@WhyAreYouReplingToMe ThIrD!!!111!!1!!1!!!!!1!!1 OmG1111!1!!112!112
Hey we (Blob2763) were going to start a game jam and we really appreciate if you would like to join us to be a judge to review the games :)
@@maxtr0b0t555 what is it
Griffpatch will be so proud
lol
Yay! Its finally out! I kept on checking your channel after school everyday just to see if you had released another episode!
That's awesome! Thanks for watching!
@@ShiftClickLearn yah soooooooooooooooooooooooooooooooooooooooooooooooooooooooooo good
I canât wait to get started on this next episode! Iâve been waiting all week for it :)
Glad to hear it! :D
@@ShiftClickLearn Let me guess: next episode youâll add a hotbar?
Wow! I actually also watch Griffpatch's! When I was watching this, I thought "this reminds me of Griffpatch's Mario tutorial" and "What's this guy's favorite color?"
Nice XD! I like all the colors...
Love your videos, I watched griffpatch's tile scrolling game, and this one is kinnda the same, I still love your videos, keep making more! (I kinnda cheated and used some of my old code of griffpatch's game..)
I have a problem with my player...
My player trys hit the block on right side it stuck 2cm before he hit block and in left the player stuck 2cm inside the block..đ±
Plz help me đđ
Did you copy the all the collision points correctly?
Yes.đ
My player also doing same
YESSSSSS! EPISODE 4! THIS IS GOING TO BE GREAT! đđđđđđ
TYSM! :DD
epicccc cant wait for the next one!
Thanks! I'm working on it!
29:17 the loading screen ainât loading out. Iâve rewatched till there for an hour, but it ainât working. Iâm super stressed cuz I have to do this for a project and only have a week left. I need to know asap pls..
So exiced to see more awesome content!
Yayy! I'm glad! â„
I followed all the steps correctly but still have a problem, when I do all the collision points and subtract the costumeheight from the Reset. Then it still gets stuck. I made sure all my collision points were the same.
Thank You So Much This Helped Me a lot!! đđđ
You're welcome, that's awesome! :D
why does my costume hight so glitchly? when i set it to the right costume hight some of the blocks makes him go down (the grass bocks) there already true but they think its false some of the blocks is normal couse there not glitch but some arent
Hi , i would like yo know how to get the grass collision to work because mine doesn't work ( i follow the exact same as yours )
Hey, I just wanna ask a question, why do u put a _ as the first letter in every variable or custom block?
I put a _ for any variable that is "for this sprite only"! :D
I did not spend 2 hours on fixing why i am coliding on the grass forgeting that i set the meta to 0 instead of -1 in the backdrops
Great video btw!
e n d l e s s p a i n
thanks lol
yay another episode! :D
Yup!!
How did you use that blur effect on the loading screen (because I might want to use it in my future games)
I used Inkscape and blurred it! The blur bar is in the color page. :D
Yeah Episode 4 wwooooohhh! You've come so far keep going
TYSM, will do! :D
My AnimationController script looks just like yours but the last frame in every animation is always the turn frame. (which is the last costume in my sprite) And for the walk animation I changed it to 4 instead of 1 but it still makes the 1st frame be idle1. (which is 1st in the costumes) IDK why, and the animation I made is 3 frames for idle and 2 for walking and I told it those 2 numbers in the (mod) section.
Hey, are you changing the _costume variable by a number larger than 1? That could make it skip frames.
The real problem is if yours says 1 * playerCostume... then it does that, replace the * with a + then it works
I forgot to say I got it working.
It always says the player is colliding when the costume width or height is greater than 0. how do I fix this?
Hello i know im commenting one 1 entire year later but i have a problem
When i press to move, the player move correctly, but when i stop pressing the arrow, the player sprite doesnt stop moving slowly, its like on an infinite ice until it hits something. How do i fix it? (Also, i re-did your code 5 times and nothing)
another amazing video by SCL
Thank you so much Kayra Yayında! :D
I, believe it or not, have another problem. So when ever I move or change â_y,âall the tiles at the edge bunch up and look really bad. I tried recoding everything but no luck. :/
Hmm, did you make the correct variables for this sprite only/ for all sprites? If not, the whole game could break.
So, if you tap a or d you go flying for some reason even with the max speed thing
i have costume problems that the player goes trough stone and every block because the costumes are wrong. What would i do for it?
Match up the IDs in the tile meta with the names of the tiles! Make sure they're in order as well. (Costume named 1 should be before 2.) :D
During The Creating Tile Meta, I don't know if this is a full problem but at (7:20) THE ID grabber list both numbers are (for me) 0, not 1 and 2 is there a way to fix this? I'm also so having problems with gravity I keep going up and not down.
Are you sure you copied the "Creating the Tile Meta" part correctly? Also, did you set the gravity to a NEGATIVE number? If it's positive, the player will "fall" upwards.
@ShiftClickLearn I got the gravity working but the ID grabber isn't still
Thx for this cool episode!
U r so cool!
You're very welcome! Thank you so much! You're cool too! :P
Why mine isn't falling after I substracted to the costumeHeight?
I mean when you are going dawn you will collide with the leaf but when you collide with the leaves at the bottom you wonât collide
Ahh
yes finally, also why you're uploading in 3am
Time zones.
Hey, what pixel art animator are you using???
I'm using a program called Aseprite. :D
my player is colliding on air even though i set it to has collision false i re-check the tile meta but its correct can you help me with that?
Hmm, does your Air have an ID of 1? Is the costume named 1? Lastly, did you copy the player collision code correctly?
my player does collide with the tiles, but then it keeps falling through them afterwards.
could there atleast be a fix to that?
edit: nvm
mine broke and aint really using the ID's. its just looping, everything looks correct but it just does the annoying looping so im just waiting for the whole shop thing to exist so i can try to use it in a differently styled game
Hmm, are you sure you didn't put an accidental change/set variable block in the tiles? If so, the whole thing could break! :D
So I was wondering if itâs possible to make this infinitely generated. I really like your engine and there is no other tutorial like this, but I donât exactly want to make a miner game. So, is it possible?
I'm sure it is... but I couldn't tell you off the top of my head. I think eventually the list containing the tile IDs would get too large for Scratch and freeze/ crash the game.
@@ShiftClickLearn im not an expert but couldnt you grab the last 20000 or so like in the tile grabber you made and store that in a seperate list to make significantly larger worlds again i not an expert so yeah it might not work its just an idea
I'm not an expert either but I already tried it and it didn't work.
@@ShiftClickLearn I agree. Scratch isn't the most powerful game engine ever and even when Minecraft had infinite worlds, you probably have heard of the farlands and how broken they are so you would also have to figure out a way to fix that.
Yay! Thank yous :p
You're welcome! :D
I made sure to follow all the code correctly, I did it all correctly. I refollowed it step by step 5 times and the same problem has been occurring. At 19:01 when I start my game, the character doesn't fall at all and just stays at the top of the screen. The code that makes it fall is highlighted once I started but it isn't falling. Is it getting stuck? If so, how can I fix it? I used the same character as yours.
same
Your video was great but at the player collision I did it correctly but my player just got stuck on top of the screen I thought it was because of gravity but I watch again and I did the gravity part correctly and if I tried to put the change y in forever loop it just goes down and doesn't collide and I did check the variable and custom block but I was correct to so I don't know how this happens so can you please help me?
Hmm... did you copy the TIleMeta stuff correctly? The tile IDs need to match with the costume names.
@@ShiftClickLearn I did it correctly too, is there any more way this could happen?
same problem with me
i think the problem is that scrolly isnt working because i tried changing the scroll y but the player is stuck in the air
i found the problem in the tile manager find when i recive position tiles and change it to tick:position tiles
what sprite art maker thing are you using @1:36
sorry @1:50
It's a program called Aseprite. đ
Please my player tileid does not work properly it it's only when I use the center of my player that it indicates the tile.is it because of my player tileindex or my scratch version,I am using scratch 3.0
Did you keep going in the tutorial? I show how to add more points so that way it doesn't just detect tiles in the center of the player.
Thanks
when i did the 6 check collision things it made it so i am always colliding with things so when i was in the air it was colliding even tho i set it to false on the air collision
Edit: the ones without costume height in calculation thing are the ones that work and the costume height is set to 24
Huh, did you add the correct data in the TileMeta? Also, did you add/subtract the costume width and height in the right places?
â@@ShiftClickLearn
collision code
set _colliding 0
CheckCollisionPoint _x + _costumeWidth + dx _y + dy
CheckCollisionPoint _x - _costumeWidth + dx _y + dy
CheckCollisionPoint _x + _costumeWidth + dx _y + _costumeHeight + dy
CheckCollisionPoint _x + _costumeWidth + dx _y - _costumeHeight + dy
CheckCollisionPoint _x - _costumeWidth + dx _y - _costumeHeight + dy
CheckCollisionPoint _x + _costumeWidth + dx _y + _costumeHeight + dy
check collision code
GetCurrentTile x y
if item _playertTileID + 2 = false
{
stop this script
}
set _colliding 1
i cant be bothered to write the rest my gmail is jutseggz@gmail.com for screenshots and if u wont do gmail my discord is jutsEggz#4411 so i can send screenshots
Which pixel art software do you use??
I use Aseprite!
I encountered a problem, I am always touching air and itâs always false, so that means in the CheckCollisionPoint, 1+2=3 so then item 3 of the TileMeta is false, and false=false, so it stops this script.
Did you copy the check collision point / collision custom blocks EXACTLY? They're really easy to mess up! :D
It worked! Thanks ShiftClickLearn! :D
I have a problem from part 3 where my world generation is all wacky with the bedrock weirdly at the top of the screen when you press the flag, is there a way you could help, I replied to your comment in the 3rd video, you could check that out but I really like this series, so please try to help.
Did you make the world height too small? It should be AT LEAST 150.
I will try that, thank you
for some reson my grassTall and Flower are acting like its solid witch it says it isnt
if you have capital letters for those inputs it might bug out, I'm not sure?!
If you have your own costumes what i did was Join Idle or whatever you wrote and than the original code on the right for animation
Nice!
i dont know why but its always teleporting me in the last layer (bedrock layer)
Is there an error in your collision code?
My Player floats on top of the long grass/flower?
Did you copy the tile meta correctly? (The IDs need to match everywhere. Air = 1, Bedrock = 2, Stone = 3, etc.)
i have a problem, whenever i start the game. the miner guy keeps moving along the x axis???
edit: i did it wrong
I'm glad you fixed it. đ
Do you mind if I ask Owen when will part 5 come out??
I'm planning on posting the video today! :D
If Anyone is having a problem at 7:20 there is a high chance you used the wrong id cause i had the same problem and i was mad looking for a sulotion but couldnt find one until i relized there is 3 id so dont get them mixed up
Your tutorials are absolutely amazing! Could you please just zoom in to the code, it's pretty hard to see sometimes. Thnx
Thanks a ton! Sorry about that, if you need, you can set the video to fullscreen!
@@ShiftClickLearn You're right, but it's annoying to switch back and forward to different tabs, I don't have 2 monitors
I have a problem in player collision for some reason the box is so big and it looks like I am floating in the air
Did you set the _playerWidth/ playerHeight to a big number?
When I use the more accurate points, it's less accurate?
Wdym?
@@ShiftClickLearn it falls to its neck instead of the centre. I did it again and now it's down to it's head
Would you consider linking images to the scripts in the description so we can review code easily if it isn't working? Thanks!
I'll share the project once the series is over.
Hello, so I have started my project after finishing the movement script and my player just fall through all of the blocks. Please tell me if you know how to fix it. Thanks :D!!
Did you copy the tile meta stuff correctly?
@@ShiftClickLearn I'll check now.
@@ShiftClickLearn Yes I've checked but my player still just goes through the blocks and when my player finds tile collision it just slows down but it doesn't stop.
@@ShiftClickLearn I'll redo episode four because I have an extra copy.
@@ShiftClickLearn Ok so I've re-done it and my player is colliding. Yay!!
Nice!
Thank you Eric & Eddie!
@@ShiftClickLearn You're welcome!
My colliders doesn't work
Do you have any completed ep 4 project?
No?
when i load in i just fall through then i get stuck underground
Did you copy the collision code correctly?
aye amazing video sorry im always late time zones you know anyways can you send you dc server link and give some tips on how to start my own coding channel I have a trash PC bad scripts and weird art so idk how do I start
Thank you! I don't have a Discord server. Try to start by making a real simple and small game. Keep practicing, and you'll get it! â„
@@ShiftClickLearn what about a recording software that wont make my fan go faster than nasas rocket?
@@centycebra4447 LOL hmmm... I use OBS- I'm not sure if that would work for you or not, but you could try it out! :D
Here's the link: obsproject.com/
@@ShiftClickLearn i already use it well its let umm ignore that
can you make the leaf jump through
You can set the collision to false in the tile meta for the leaves! :D
Everytime when I walk left into a block, I get stuck and I can't move or leave the block, can u tell me how to fix this. This episode was very good, I just need help fixing this bug please
Are you sure you copied the x collision correctly? If you misplaced one block, the whole thing could break!
Thanks, it worked :)
for some reason, horizontal collision doesn't work, but vertical collision does. why might this be?
Hmm, check the collision custom block, did you copy the ones with the x variables correctly?
@@ShiftClickLearn yeah, i've quadruple checked everything. even went through and watched the whole video again and cross referenced the code. not sure why it isn't working.
My player cant fall to the ground because he is stuck on the boarder of the stage, at y 180, and I don't know why.
Try reducing the _y variable in the player in the beginning (in the Reset block). Maybe subtract like 25.
@@ShiftClickLearn Thank you so much! It worked! Love that you respond to comments!!
The game just got better !
Thanks! :D
I'm having a problem. I done everything the same as you but, the miner guy is sinking a litle in the ground
Hmm, maybe try setting the costume height to a larger number.
@@ShiftClickLearn Thanks dude! Btw your videos are awesome :)
ebiccc
Thanks John!!! :D
When is next video coming out?
It's out now
My player is stuck on the corner of the screen not moving. Can you help?
Did you copy the code that positions the player? (Go to _x - ScrollX, _y - ScrollY)
@@ShiftClickLearn Yes
my "PlayerTileID Variable isnt displaying the right number." i can send a link to the scratch project if you want to check it out. (and yes i will temporarily use your player costumes.)
nvm i fixed that now all the objects are getting collided, even the logs and flowers and tall grass.
Did you match the IDs in the TileMeta to the numbers of your tiles. For instance, if you have a costume called 7 and it's the grass, the TileMeta should match that: ID 7 should be grass in the TileMeta!
its all working now, thanks for your help.
@@CrystalKyryn Oh, awesome! You're welcome! :D
@@ShiftClickLearn I did the same thing however it still does not work.
ShiftClickLearn, i've done Episode 4 of yours and it was great! But there is a bug (of course there is) about the player animation you make. The Bug is: When you jump and then fall down and then touch the ground, the animation is glitching. Please make a video how to fix this bug, ShiftClickLearn.
Yesssss .....
Did you copy this part of the code (28:11) correctly?
I implemented the fix for collisions on tall grass and it doesnât work.
Are you sure you added the correct values in the tile meta?
Yes. I went back 3 times and it was the same
_xSpeed is for this sprite only, right?
ps: your vids are the best!đ»
Yup, it is! Thank you so much! :D
Lol -1 likes and dislike i saw that, ur vids are awsome! Not horrible!
LOL thanks! :D
Grvitatio doesn't work for me. Can everyone help me?
my player falls to a stone and then he stops and colliding is always on 1 from then on
Um, dude? I'm continuously colliding with air even tho i set the collision to false..
Ok bug fixed
For those confused about the player collision, pay VERY close attention to how SCL arranges the equation blocks.
@ShiftClickLearn
Was this helpful?
What do you think of Paper Minecraft, Do you ever play it?
I like Paper Minecraft! :D
he said it in part 1
@@PalekJRam did you really reply to a year old comment? Lol
Can you please make a crafting system?
Hey, that's an awesome idea! I don't think I'll have time to in this series- we still have a LOT to do. Maybe in an addon epsiode! :D
#ShiftClickLearn what to do if my player is stucked in the air and when i change y by -100 it doesn't fall(Gravity doesn't work). Can you make a special project for each episode pls. I liked you and subscribed. Thank you!
Can you make a tutorial on pixel art?
I made an old one on pixel art, but an updated one would be cool!
whwere is the link?
The art is in the description. :D
I`m having a problem where my player doesn`t move through non solid objects.
@@MeArgo77 Me either.
@@MeArgo77 Yeah but I did it like that.
@@MeArgo77 Send me a turbowarp link of yours and I`ll see.
@@MeArgo77 Look let`s take the flower, it is number 7, number seven is stone and if we add 2 it`s true so what you said will not work.
Nevermind.
first! Btw, love your vids
TYSM!
what program did you make the pixel art in?
I made the pixel art in Aseprite! :D
@@ShiftClickLearn i made mine in scratch lol
My player wont go do down during coding gravity
Did you copy the positioning correctly? (Like this: 13:33)
Thanks!
Also, do I set _y or ySpeed to zero anywhere in the code, because I start near the bottom of the screen.
(Because I tried setting ySpeed to zero at the beginning and it was fixed)
can you put the art
Just did, thanks!
as a wise man once said...
'"run screen without refresh"
very wise indeed xD
refresh without screen run
*run refresh without screen*
đđđ§đđđŁ đđȘđŁ đđđ©đđ€đȘđ© đđđđ§đđšđ
I mean the leaf will colide when you fall on not jump on.
Oh, I have no idea how to make that off the top of my head! XD
bro the gravity isnt working
Did you copy everything correctly?
i made the add ids block before you thought about it đ
Niceee! :D
I forgor to turn on the notification sorry
That's ok! :D
scratch addons?
What about it?
I saw scratch addons
@@firstofthesame150 Cool! :D
What is the ideal in the next video
I'm going to add block breaking!
Ohhh nice ideal
cool
Thanks!
Some random guy: What is your favorite shape?
No one, Absolutely No one :
Me:My favorite shape? A rhombicuboctahedron
I was wondering, how old are you?
Anyway, this tutorial is great!
Thanks! I'm 120 years old!
@@ShiftClickLearn lol your 14 i know
@@ShiftClickLearnBRUH
am I the only one that finds a bug in my animation code?
edit: I had *0.15 instead of +0.15
Oh, nice! Glad you fixed it! :D