Log In  


Hi all!

I would like to build walls for a shoot'em'up and I know I can obtain the result with map.

What I do not understand is how to make the drawing dynamic.

For example I have the sprite 0 that contains my wall and I would like PICO-8 to draw walls on the side programmatically.

What would be the best approach to do so?

Thanks for your time and patience.



This is a tough question, not because it's hard to do, but because there are so many ways to do it that it's tough to know what would be best for your project.

The simplest way would probably be this.

for xx = 1 to 16 do
 spr( WallSprite, xx, 0 )
end

That'll put a wall across the top of the screen. (Unless I've made a typo somewhere, which is very likely.)

There are much more complicated answers depending on what you're trying to do.

Maybe you could describe your project a little more, then we could provide a more detailed suggestions.


An alternative way is to use a map, draw the wall tile into to map with mset(x,y,0) and render the map in _draw(). Might be a good ides to preserve 0 as "void" in that case and move the wall sprite to index 1. If you not only want to draw the wall, but do want collision checks, using a map might be better.


Thanks for your input, guys!

Sorry if my request was not that clear, I will try to explain better.
In my dreams it would be something similar (but waaaaaaaay uglier and simpler) to Xenon 2.

A vertical scroller with boundaries on the sides.

After scrolling for a bit a final monster, end :)


Here's a very simple and failed attempt, using apLundell's idea:

function _update()
cam_y-=1
print(cam_y)
end

function _init()
y=0
cam_x=0
cam_y=0
end

function _draw()
cls()
print(cam_y)
camera(cam_x,cam_y)
for x=0,-500,128 do
y+=8
spr(1,0,x+y)
end
end


Suggest to follow one of the basic tutorials:

  • draw a map (using PICO built-in features)
  • shift the map on-screen according to player x/y
    Something like:
y=0
function _draw()
	y+=1
	cls(0)
	map(0,flr(y/8),0,-(y%8),16,16)
end


[Please log in to post a comment]