# Slope collision test

donic the hedgeduck

5 Likes

Awesome! I did something similar a while ago but I never ended up packaging it up.

5 Likes

Itās not letting me view the code.
How did you make the wheel of platforms turn so smoothly?
Did you use sin cos tan?

Yep! The formula looks something like this:

``````x = cx + Math.cos(game.runtime() / 1000) * radius
y = cy + Math.sin(game.runtime() / 1000) * radius
``````
• cx, cy is the center of the circle
• radius is distance from the center
• 1000 is just to convert the runtime into seconds. Make that number bigger to rotate slower, and smaller to rotate faster

In blocks, you can find the runtime in the `game` toolbox. Itās the one that says `time since start (ms)`.

thanks!

This really helps.

So do this on a game update every ___ ms?

Yep, but if you want it to be smooth then you should probably just use an `on game update` (no interval)

Okay!

How did you make many platforms? How did you make a sprite stick to them?

Ah, thatās tougher. I made my own custom physics engine for that demo. This is not something that you can do in blocks.

Basically, every platform is a āmini tilemapā with its own collisions defined. I also store a list of āridersā, which are sprites that have landed on the platform. When I move the platforms, I also move all of the riders for that platform. A sprite stops being a rider when thy no longer collide with it anymore.

1 Like

Okay, that seems a bit to difficult for me.

like i copied it
and it got deleted somehow

Umm this is too cool

@reyhanPanci256

I think your code is awesome, and makes a good use tiles and a tile map. I found an issue that places donic outside the game (see screenshot below)

I think it has to do with the code within the sprite.overlap functions and specifically:

sprite.y += -5

The player sprite can fall out of the screen when moving down a slope, right at the ācornerā of the slope (so where the flat tile meets the sloping tile) It happens at both sides. At this point the code does not see that the player overlaps a tile sprite and is sent hurtling down the screen.

Wait, is it possible to make a 1x1 tilemap extension? Maybe call it micromaps.

This came up in another thread some time ago but the physics engine in arcade really canāt support 1x1 tilemaps. It would be way too slow, unfortunately.

That being said, I know @GameGod was working on something: 1x1 tilemaps

1 Like