Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need help with scrolling map
- AdventuriousYappy
-
Scratcher
7 posts
Need help with scrolling map
Hello scratch! I'm trying to create a scrolling screen-based platformer, which is going okay so far, just a proof of concept, but I also wanted to create a zoom function, so i could make the map smaller/larger if i wanted to. Simply making the map tile's scale doesn't work, as there's gaps between the tiles, how would i move these tiles together so that there's no gaps, but the map is still smaller?
Link to project: https://scratch.mit.edu/projects/1075009309/
Link to project: https://scratch.mit.edu/projects/1075009309/
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
Okay soooo I THINK I know what you're trying to say. I believe you're trying to make it so when you zoom out in your project, there's no white space in the x file between the tiles, so instead of red-white space-orange, it's just red-orange but smaller? I mean, what you can try to do is make the sprite different costumes. For example, costume 1 is fully zoomed in, but instead of changing the size of the sprite (you could change it a little bit for sure but not have it as the main way of zooming) you can have smaller and bigger costumes. I don't just mean smaller and bigger, but I'm also saying you could add shape into it.
You can make each different costume a little bit thinner width-wise, making the first a square, the second just about a square, but by the time you zoom out 5 times it's a rectangle, or by the 2nd one it's a rectangle, whichever works. Hope this helps, respond if you're confused I have it followed.
You can make each different costume a little bit thinner width-wise, making the first a square, the second just about a square, but by the time you zoom out 5 times it's a rectangle, or by the 2nd one it's a rectangle, whichever works. Hope this helps, respond if you're confused I have it followed.
- AdventuriousYappy
-
Scratcher
7 posts
Need help with scrolling map
Hi, thanks for the response! I'm actually hoping that this becomes a rather wide-scope project, and this solution would work, but it'd require possibly 10 different variants of each costume for each zoom level, and i'd much prefer a simpler catch-all solution to this dilemma. I'm hoping there's some way to move both of the tiles on the x coordinate towards eachother to eliminate the whitespace mathematically, somehow calculating the distance between the two and sliding them to meet eachother to eliminate the gap.
I'm thinking that in doing this, a third tile needs to be visible onscreen, so maybe there's a way to calculate which tile is closest to the middle of the screen, and take the two adjacent tiles, calculate the distance to the middle tile, and scoot them over to remove the gap between them. I know how to check which is closest to the middle of the sceen, but I have no idea how to check the distance of the whitespace between the tiles and adjust for that distance. If you can find a way to find out how to get the width of this whitespace you mentioned, that'd be all i need. Thanks for the timely reply, and in advance!
I'm thinking that in doing this, a third tile needs to be visible onscreen, so maybe there's a way to calculate which tile is closest to the middle of the screen, and take the two adjacent tiles, calculate the distance to the middle tile, and scoot them over to remove the gap between them. I know how to check which is closest to the middle of the sceen, but I have no idea how to check the distance of the whitespace between the tiles and adjust for that distance. If you can find a way to find out how to get the width of this whitespace you mentioned, that'd be all i need. Thanks for the timely reply, and in advance!
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
Well, another way you can try to do it is when you zoom out, move all of your cubes in a direction. For example:
OR
Basically you do this piece of code over and over for the amount of times you zoom out, and the mirrored opposite on each block for each zoom in. That would move the sprites at the same time you zoom out/in, essentially moving them all in one direction. Hope this helps!
when I receive [ZOOM OUT x1 v]
move (-80) steps
OR
when I receive [ZOOM OUT x1 v]Or whatever your spots are, not really sure.
go to x: (-400) y: (160)
Basically you do this piece of code over and over for the amount of times you zoom out, and the mirrored opposite on each block for each zoom in. That would move the sprites at the same time you zoom out/in, essentially moving them all in one direction. Hope this helps!
- AdventuriousYappy
-
Scratcher
7 posts
Need help with scrolling map
This actually seems like a pretty nice solution! However, since Scratch's sprite sizing system works via percentage, I couldn't just move each by the same incriment, as the value for that would change based on how big the sprite is, and how big it will be. Do you know of any way to find the value for that change mathematically?
- AdventuriousYappy
-
Scratcher
7 posts
Need help with scrolling map
I tinkered with it a bit, and I think i've actually found a way to accomplish this with lists, thanks for all the help though!
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
This actually seems like a pretty nice solution! However, since Scratch's sprite sizing system works via percentage, I couldn't just move each by the same incriment, as the value for that would change based on how big the sprite is, and how big it will be. Do you know of any way to find the value for that change mathematically?Well what you can do is sort of like, set it to the size you want, and then move it, let's say -80 as our like placement-starter-type thing. So you downsize it, move it -80, and then have a script that says when green flag clicked return to size x, and then you do this for all of the sizes. IMPORTANT: If you do it this way, make sure that if you have the script basically like I said, then just make sure that it says in the script first that it is changing sizes, waiting 0.05 seconds and then moving.
Alternative: you figure out the sizes you need to move with it already as the size, and then in your script you move -80 and THEN you downsize, meaning it shows move -80, wait 0.05 seconds, and then size down. Either way should work, but I would suggest the first way as it would look cleaner.
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
If you feel like doing a lot of work to make it the best, do it the first way I said with my original comment though. Depends on how much work you're up for, it will be a lot of moving and placing and checking how much further you need to cut the sprite or move it…
- mafrtpoll
-
Scratcher
100+ posts
Need help with scrolling map
Try this zoom feature that I made, https://scratch.mit.edu/projects/1075054493/
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
Try this zoom feature that I made, https://scratch.mit.edu/projects/1075054493/This is honestly a really cool feature, but for his specific project it probably wouldn't work for it, depends.
- mafrtpoll
-
Scratcher
100+ posts
Need help with scrolling map
I added the ability to move so I think he could use it now.
- Intelligent684
-
Scratcher
100+ posts
Need help with scrolling map
Possibly, I won't really look into it too much more so it just depends on his situation. Again, really cool feature though.
- Discussion Forums
- » Help with Scripts
-
» Need help with scrolling map


