As some of you new to PICO might be asking. How can I make a smooth-scrolling map ?
The solution ? To use PICO's own MSET() to plot tiles into your map space and MAP() to draw it all out.
Check the code carefully though ! PICO apparently cannot by default smoothly scroll a map one pixel at a time so I am plotting the map using a modulos of 8 steps to count as one tile for pixel-perfect movement.
Hit the (Z) key to change from the 1st room to the 2nd.
A center digit will tell you which page you are on.
When you get to the end, before you hit a key to return to the prompt, hit CTRL-R right there to run it again.
You can scroll however you want to. All functions that draw are automatically clipped to the screen, so you can map(tilex,tiley, -1,0, 17,17) to draw the map shifted one pixel to the left.
edit: and scrolling a map larger than the screen is one of the times you probably want to use camera(). As usual, I suggest digging into Jelpi to see how it handles things.
I think I'm doing this already ?
But you bring up an interesting idea. What if ... ? I scroll BIG map that is well outside the screen, limited to CLIP() ?
That seems to work. That saves not doing a modulos - yet this method is REALLY bad coding. :D
I guess what I wanted was map(pixelmapx,pixelmapy,...)
So you would need to have pixelmapx at 8 in order to read ahead one tile. As it is, a single "1" jumps 8-pixels, and no, you can't use math 1/8 to extract the smooth pixel either; that is ignored.
The first two arguments to map() are tilex and tiley, since the map works in tiles. The next two are screenx and screeny, which are in pixels.
So you keep track of your offset (the same numbers you'd be sending to camera() ) and do a map call something like
edit: no clip() needed, since all draw calls are automatically clipped. You can draw at (-500,49217840) if you want to. (and if you've used camera() to move the "view" over there, you'd even see something on the screen)
edit edit: I'll expound that map call in detail:
map( offsetx/8, offsety/8, --[[offset is in pixels. here divided by 8 to convert to tiles. if x is 8 to 15 inclusive, i'll get the proper 1 tile i need to move the view of the map by.]] 0-offsetx%8, 0-offsety%8,--[[so if my x offset is one pixel, the remainder is 1 and the position of the map is shifted one pixel left off of the screen]] 17,17--[[just big enough since there's always 1 to 8 pixels spare pixels offscreen in the positive direction]] )
I'm using CLIP() merely cause I hate even-numbered screens. Gotta have a natural center tile. :)
Tyroney, what would be a source code example of using camera() to duplicate the above effect ?
Wait. I think I just got it.
Well now that is interesting ! Camera being able to scroll to any point on a MAP and no modulos needed !
This also works:
I guess it's just a matter of preference.
Likely good advice there. To handle Zelda-style scrolling, all I would really need is the space of 30x30 tiles. And if I wrote my own mapper routines, zero.
MAPPER space is something entirely new to me and no other game programming language I've worked with ever had it.
Question. Can you do MODE 7 with this mapper area ?
I have a minor correction to the comment near the end of your code. after line 36, insert:
035-- note that you can only 036-- 'scroll' in steps of 8, [b]037-- [i](if you hard code your map()[/i] 038-- [i]call to screen pos [4,4] )[/i][/b]
[Please log in to post a comment]