I am working on my first serious endeavor (something like flappy bird mixed with side scrolling shooter boss fights) and would appreciate some help regarding the scrolling maps.
The idea is that the map is divided into several 16x16 tile sections (one whole screen) and that these sections would scroll at a constant rate as you attempt to avoid obstacles. I wanted the scrolling obstacle sections to be randomized for replayability.
i.e. Your character starts in section Z. As it starts to scroll across the screen, section X follows it. Section Y follows section X, etc. for N iterations. At which point, a boss battle takes place.
Has anyone attempted something like this before? Are there any examples of games that could be useful?
Thanks in advance.
The way I've done this is with a combination of using map() calls with offsets and camera() work. My current game uses 5 8x128 sprite "stripes" of the map, then presents them as a continuous scrolling map. I keep a global mapoffset, tracking pixels away from the beginning of the stitched-together map, tracking the players on the map, and make the camera follow that.
If I'm understanding your requirements, you'd have a list of map sections to present (sometimes duplicating them), but it's otherwise pretty similar.
If it helps, here's the functions:
function drawmap() rectfill(mapoffset, 32, mapoffset+128, 16+32, 1) -- draw a color behind the map sprites for x=0,mapw,128 do local row = flr(x/128) local remaining = min(mapw-x, 128) map(0, row*8, row*1024, 32, remaining, 2) -- draw a couple of rows of the map before the palette shift local shift = maprowpalshifts[row+1] -- i do a palette shift on some rows if (shift) runpalshift(shift) map(0, row*8 + 2, row*1024, 48, remaining, 6) -- draw the remaining rows of the map pal() end end function camshake() local shakex = 0 local shakey = 0 if screenshake > 0 then shakex = 3-rnd"6" shakey = 3-rnd"6" screenshake -= 1 end camera(mapoffset+shakex, shakey) end
If your level moves horizontally and you keep it under 8 screens, it should be pretty easy. If you want something longer, you'll have to do some extra work to duplicate parts of the map and "teleport" the player/view so that you can keep scrolling seamlessly.
Tyroney, in S2, I used this exact method and had a routine draw the map. The map could be of any virtual size, you could 'teleport' to any place in it, and it appeared with tiles and sprites flawless at all times.
The actual storage was a 19x15 array. The sprites were saved as an overlay array. What was viewed was always 17x13. The 19x15 edges were always drawn off the edge or just touching the screen and in movement, always appeared perfectly and by pixel.
That might be a rather complex way to do it, however, the advantage is you can have ANY size map with any number of details and can appear at any tile or by exact pixel positioning.
Thanks for all the input
From your description, your solution seems to be what I am looking for as I have already figured out scrolling along a static (non randomized) map.
I plan on having about 28 "random" map sections,
2 boss fight sections which are more or less devoid of obstacles(These would repeat for the duration of the battle),
1 entry section for the start of the game,
1 title screen section.
I'll take a closer look at Kick Wizards and hopefully I'll get the random scrolling done in a few days!
[Please log in to post a comment]