Hi guys; just bought pico-8 to use for the Game Jam and have some questions;
I'm following the platformer tutorial from Nerdy Teacher and was able to get my own status screen as show in the picture;
*the fanzine code I'm looking at is so I can remember how to draw a rectangle
What it does now is that the camera follows the player so when you progress the map the previous tiles will disappear where the new ones will show up; but when this happens the status box I made disappears along with it. I tried pasting and copying the code within the camera code I copied but that doesn't seem to work.
Is there a way where I can have the status text just stay static or doesn't move? Or move along with me?
The tutorial that I'm following: https://nerdyteachers.com/Explain/Platformer/
I'm not sure I know what you're asking. Follow camera box following the camera ?
Did you want a sprite to maintain in the center ? And remember that camera() does NOT adjust the screen. It adjusts what you plot AFTER that.
That's all it does. Important for you to know this. There is no function that actually shifts the screen.
Here is a variation with a center sprite and resetting the camera so you do not need to track it outside of the scrolling playfield.
Oh I see what you're doing now; I got my menu to be static by adding camera() to the function but the camera made the scrolling goofy. Like now the physics has been altered
Here's my example
It's because you're drawing the actors after resetting the camera. They're drawn in the wrong place relative to the map.
You want to be doing something like this:
function draw_game() camera(cam_x, 0) -- draw map and actors here camera() -- draw status bar here end
Basically, call camera() with arguments before drawing things in the world and without arguments before drawing things on the screen. You can think of it as switching between different coordinate spaces.
Ohh that seemed to work; Let me see if I can understand this
the first camera(arg1, arg2) sets the main camera for the map? Which makes the map scroll with the player
where the 2nd camera() resets what's going on and anything under it will scroll with the player even though the first camera() already has it set?
Yep, that's about right.
All the camera function really does is add offsets to the coordinates given to subsequent drawing commands. A call with no arguments resets them to 0.
camera(10, 20) spr(1, 70, 90) -- actually draws at 60, 70 camera(70, 90) spr(1, 70, 90) -- actually draws at 0, 0 camera() spr(1, 70, 90) -- actually draws at 70, 90
But it's useful to think of it in a more abstract way. If you imagine an actual camera looking at the map at position cam_x, cam_y, calling camera(cam_x, cam_y) switches the view to that camera, and any drawing done after that is done as though you were looking through it. The status bar doesn't exist in the world and shouldn't be viewed through that camera, so you call camera() to switch away from it and draw directly on the screen.
[Please log in to post a comment]