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.

P#43796 2017-08-31 11:25 ( Edited 2017-09-03 09:20)

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.

P#43799 2017-08-31 12:04 ( Edited 2017-08-31 16:04)
:: sulai

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.

P#43805 2017-08-31 12:29 ( Edited 2017-08-31 16:30)
:: ltpitt

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 :)

P#43809 2017-08-31 16:03 ( Edited 2017-08-31 20:03)
:: ltpitt

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

P#43827 2017-09-01 04:27 ( Edited 2017-09-01 08:27)

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
P#43889 2017-09-03 05:20 ( Edited 2017-09-03 09:20)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-06-06 11:33 | 0.012s | 4194k | Q:22