Log In  

I'm working up the basics for a small tile puzzle game where players navigate through a maze filling the path behind them so that they can only move on each tile once. so a trail that will then have some collision so it can't be crossed

I'm having trouble working out how to leave a trail of sprites. I have a grid set up, and a player sprite to move as follows:

function _init()
x = 0 
y = 64

function _update()
 if (btnp(0)) 
  then x=x-8 

 if (btnp(1)) 
  then x=x+8 

 if (btnp(2)) 
  then y=y-8 

 if (btnp(3)) 
  then y=y+8

function _draw()

I've tried having something in draw but this ended with the designated sprite following the player around and I tried adding something in the update function with the keystrokes but this b0rked it.

It seems to be something beyond what I kno so even if someone can point me in the right direction of something to read up on or code to review that would be much appreciated.

P#20196 2016-05-05 16:01 ( Edited 2016-05-05 21:39)

You can use a map and the MSET function for each tile the player walks over. Then, to prevent the player from going backwards, check if the tile is filled with MGET. The problem with your code is that every frame, before running _draw, PICO-8 clears the display.

P#20205 2016-05-05 17:39 ( Edited 2016-05-05 21:39)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-05-21 22:07:19 | 0.004s | Q:7