ScratchData LogoScratchData
Back to MrMeow_Meow's profile

Cool Character Movement Engine and Effect

MRMrMeow_Meow•Created March 2, 2023
Cool Character Movement Engine and Effect
20
18
346 views
View on Scratch

Instructions

If your game begins to lag and freeze up, it's because the engine went inside of a wall at a weird angle, just press the flag again until it's back to normal! Bring your mouse to the center of the scene and use it to move the "player" Feel free to use this in your game, just credit me in your notes and credits :) Oh and link it in the comments so I can check it out! :D To add it to your game: just take the engine, visual player, and player hitbox sprite inside, bring it into your backpack, and then your game, and make it follow the player. you might need to look and change it to detect your map sprite. Make sure to grab all three sprites! Leave a comment with any questions!! :)

Description

Okay awesome quick update! Threw together a cool movement effect where the further your mouse is the faster it moves and it gets blocked by walls. Thought this was a cool addition, and I think it'd make for a cool game. Feel free to use this in your game, just credit me in your notes and credits :) Oh and link it in the comments so I can check it out! :D Just a little effect inspired by the game "Carrion" I made entirely out of pen. There's not really a player that it generates from bc I couldn't come up with any design and I'm not very good at art lol, give me suggestions and feedback in the comments! For anyone curious, here's a brief summary of how it works (nerd stuff incoming, I know it looks long but I promise it's not actually that complicated!!): When I say it's made out of pen, I mean that there is a sprite (in this case it's 8 clones doing the same thing, one for each cord) that is drawing the result that you see by moving and leaving a (red in this case) paint-like trail behind it as it moves, drawing like a pen! It's constantly drawing the cords and then erasing everything that's drawn on the screen many times a second, then redrawing everything again in order to make things change dynamically and smoothly. The reason I have to erase all of the cords at once instead of just one at a time is because for some reason the only way to erase drawn pen is to erase everything at once. This means that the engine has to remember which points it picked for the lines to latch onto in order to redraw the lines in the same place. I use custom blocks and check the "run without screen-refresh" box in order to do this. Any code that is in custom blocks like these is run instantly, which allows me to have the pen sprite check for many things very very fast in order to get the effect to work. It creates 8 clones (one for each line), each following the same algorithm to draw the cords. It first finds points where the cords will latch onto, then draws the lines themselves. It uses pen to draw the lines and redraws them constantly many times a second like I mentioned before. Each clone follows the same steps whenever deciding on a place to draw a line and drawing it: First, they pick a random direction and go until they hit a wall, then it remembers this point that it has hit. This is where that tentacle/cord thing will latch onto. Next, it attempts to draw a line between this point and the player. However, before drawing the line, it checks for two things: If the distance between the player and point is greater than 100 (a simple yes or no) and If there is a wall in between this point it's picked and the player. It does this by walking from the point to the player and constantly checking if it's hit a wall every step of the way. (it is able to do this instantly despite it only moving one step at a time by using the "run without screen refresh" thing I mentioned earlier) If either of these are true, it picks another point instead to draw the line, since that means that this point it tried to pick has been either cut off by a wall or gotten too far from the player. If the point is not intersecting a wall and it is not too far away, then it constantly draws a line between the player and this same point that it picked, each time it draws the line it tests the same criteria above to decide if it should still be using this point or instead pick a new one. Thank you for reading and be sure to ask me any questions you have in the comments!. Unfortunatly I can't promise I'll respond because I'm not online often however I will try my best! :)

Project Details

Project ID812553771
CreatedMarch 2, 2023
Last ModifiedNovember 7, 2024
SharedDecember 22, 2023
Visibilityvisible
CommentsAllowed