arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Feature request: Camera rotation

Open DigiDuncan opened this issue 3 years ago • 3 comments

Enhancement request:

The ability to rotate a Camera, affecting the viewport.

A simple mockup of Camera rotation.

What should be added/changed?

  • An attribute on a Camera, .rotation: float representing the amount of degrees the Camera is currently rotated (default 0)
  • An attribute on a Camera, .anchor: tuple[float, float] representing the point at which rotation will originate from (default center, or (self.viewport_width / 2, self.viewport_height / 2)
  • A method on a Camera, .set_rotation(degrees: float, anchor: tuple[float, float] = None) which sets the rotation of the Camera.

What would it help with?

  • Creating camera effects for cutscenes
  • Creating games that use movement systems like those in many space-themed games, where the camera moves and the ship does not
  • Creating transitions between scenes
  • ... and more!

DigiDuncan avatar Feb 05 '22 06:02 DigiDuncan

This can definitely be done and can be very powerful. One important part here is that it can break colission if someone tries to use different offsets for two sets of sprites, but I think what you get from this alone is worth it.

We can probably do this in combination with using pyglets WindowBlock Uniform Buffer Object. It has a projection and view matrix we can add to our shaders. I'm not sure if this is a 2.6.x thing or a 2.7 thing yet.

einarf avatar Feb 05 '22 09:02 einarf

You can draw onto a sprite now, and just rotate the sprite if you like. That minimap could be rotated: https://api.arcade.academy/en/latest/examples/minimap.html#minimap

pvcraven avatar Feb 05 '22 22:02 pvcraven

You can draw onto a sprite now, and just rotate the sprite if you like. That minimap could be rotated: https://api.arcade.academy/en/latest/examples/minimap.html#minimap

Right! That is also an option! Still cam rotation is nice to have.

einarf avatar Feb 06 '22 09:02 einarf

Hi, camera rotation is working on arcade development (pre 2.7), but keep in mind that rotation breaks collision detection at the moment.

alejcas avatar Oct 27 '22 23:10 alejcas