Log In  

Hey peoples I've recently started using pico-8 again after a while of not using it, and I've been trying to make rooms (individual screens part of a full level) but I've been having trouble trying to make the camera actually move over to the next screen. (preferably with a transition, cause I've also tried doing that) I know this is kinda a dumb question but it would help me a lot if someone knows how to help.

P#106522 2022-02-08 00:37 ( Edited 2022-02-08 00:37)

1

That depends on how you're structuring your code. Moving the built-in camera is just camera(x,y) where x and y are where you want it. As long as you're using the map and drawing the whole thing at (0,0), then it should work to just move the camera to the top-left of the next room. If you need a gui, just set the camera back before drawing it or draw it within the current room.

If you're not using the built-in camera (such as using variables like cam_x and cam_y), then everything except the gui needs to be drawn at their position minus (cam_x, cam_y).

Transitions also depend on your preferred way to code, but one quick drop-in way is to temporarily change the _update() function and then change it back when done. For example, if you want to move the camera to a room 1 screen to the left, then this would work:

function camera_move_left()
  cam_curr_x = room_x
  cam_curr_y = room_y
  cam_dest_x = room_x - 128
  prev_update = _update
  _update = camera_move_left_update
end 

function camera_move_left_update()
  cam_curr_x -= 1
  camera(cam_curr_x, cam_curr_y)
  if (cam_curr_x <= cam_dest_x) _update = prev_update
end

where room_x and room_y are the location of the current room in pixels. If they're in tiles instead, then they need to be multiplied by 8.

P#106531 2022-02-08 02:14
1

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 17:58:26 | 0.006s | Q:13