Log In  

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.

P#29976 2016-10-04 11:57 ( Edited 2016-10-04 20:41)

This is pretty new territory for me in PICO. Let's see ... I'll make a new post of it, shall I ?

...

COMPLETE !

You can find it and accompanied source code example HERE:

https://www.lexaloffle.com/bbs/?tid=27809

P#29981 2016-10-04 13:21 ( Edited 2016-10-04 17:37)

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
P#29985 2016-10-04 13:53 ( Edited 2016-10-04 17:56)

Fweez, could you please post the above as a full working example ? I'd like to see what you are doing here and likely I could learn from it.

P#29987 2016-10-04 13:56 ( Edited 2016-10-04 17:56)

I don't have time to do a minimal version, but it's implemented in my Kick Wizards WIP cart

P#29988 2016-10-04 13:59 ( Edited 2016-10-04 17:59)

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.

P#29991 2016-10-04 14:07 ( Edited 2016-10-04 18:07)

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.

P#29992 2016-10-04 14:17 ( Edited 2016-10-04 18:17)

Thanks for all the input

fweez,
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!

P#30009 2016-10-04 15:43 ( Edited 2016-10-04 19:43)

Fweez, I'm looking at your screen shake routine.

What does RND"6" do ? Is that the same as RND(6) ?

P#30012 2016-10-04 16:00 ( Edited 2016-10-04 20:00)

The same. Saves some tokens if you can call that way. See the optimizations thread for some discussion.

P#30014 2016-10-04 16:29 ( Edited 2016-10-04 20:32)

I was there. Seems a little tricky. I'll only call on it if I run out of space or something. Doesn't seem likely, I write pretty tight code.

P#30016 2016-10-04 16:41 ( Edited 2016-10-04 20:41)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 20:45:17 | 0.009s | Q:22