EldarT
EldarT

Reputation: 31

In Scratch, how do you set boundaries on your top down scrolling?

I recently have been working on a scrolling game in scratch, and have been using a simple scrolling method, where the player is always centered and does not move, and the map is incredibly sized up, and moves instead. The problem is that even though i'm using a big size (1000), the map ends at certain points, and I want to make it so the map won't scroll to that point.

I've tried stopping the scrolling, and killing the player

An image of the killing code

but noting I've tried has worked with success.

Upvotes: 2

Views: 535

Answers (3)

Falling10fruit
Falling10fruit

Reputation: 319

In the sprite of the scrolling level:

Code

Upvotes: 0

John doe
John doe

Reputation: 33

touching color () is bad practice. you should always handle collisions with hitboxes. you can implement these by quickly switching the custom to and from the `hitbox` in a run without screen refresh block.

Upvotes: 1

Unlov6r
Unlov6r

Reputation: 11

You’ll need four sets of ‘if statements’. The first 2 sets being for X and the second being for Y values. I assume you’re using scrollX and scrollY. You’ll need 2 ‘greater than’ and 2 ‘less than’ operators as well as 2 ‘set scrollX to’ variable statements and 2 ‘set scrollY to’ variable statements. The very first if statement should be ‘if scrollX > (430) then set scrollX to 430’. You can use whatever number you want to, just make it where you can still see the background before it scrolls offscreen, have your scrollX variable on screen so you can see what number is best to put here. Repeat this again for the opposite side but this time it will be ‘if scrollX < (-430) then set scrollX to -430’. Repeat the same thing for the y values. It should look like this for direction up: ‘if scrollY > 430 then set scrollY to 430’ and this for direction down: ‘if scroll y < -430 then set scrollY to -430’.

Upvotes: 1

Related Questions