Log In  

Hey all,

New to Pico-8 - Trying to get my feet wet. I created 3 sprites - 2 Bad Guys and 1 Good Guy. In the sprite editor my bad guys are located in location 000,001,002 and 016, 017, 018 while my good guy is located 003, 004, 005.

I am using a move_demo from here - Movement Demo by Shane Riley.

When the program is ran - I get the Bad Guy located at 000 to 002 to control. I tried changing some values around to get the sprite located @ 003 to 005 to no avail.

How do I go about doing this without cutting and pasting my Good Guy to the Bad Guy position?

It's been a great many years since I coded anything, FYI.

Cheers,

P#18350 2016-01-18 11:59 ( Edited 2016-01-20 10:12)

Hi Megazell! The values you want to change are the player.sprite ones. In your very case, you should set player.sprite to 3 at the beginning and then your move function should look like this:

function move()
  player.moving = true
  player.sprite += 1
  if player.sprite > 5 then
   player.sprite = 3
  end
end

You would then be asking for your cart to use the sprites 003 to 005!

P#18351 2016-01-18 12:22 ( Edited 2016-01-18 17:22)

Thanks!

P#18352 2016-01-18 12:31 ( Edited 2016-01-18 17:31)

Sprite 000 can't be used - it must be left blank!

P#18353 2016-01-18 16:13 ( Edited 2016-01-18 21:13)

It's possible to use sprite 000, The top left of the player's face uses it in Oubliette.

P#18362 2016-01-18 23:52 ( Edited 2016-01-19 04:52)

The only thing to note is that sprite 0 won't show up on the map--it shows as an empty space when rendered on the screen. However, you can still use sprite 0 with the spr command: spr(0,x,y) for example.

P#18363 2016-01-19 00:03 ( Edited 2016-01-19 05:03)

Ooh yes soz - my bad!

P#18364 2016-01-19 00:31 ( Edited 2016-01-19 05:31)
:: Meir

As an alternative, I'm a fan of setting an origin point for a sprite animation, and then cycling the displacement e.g.

function move()
  player.moving = true
  player.phase +=1
  player.phase %=3
  player.sprite = player.origin + player.phase
end

Which does not use any 'if' clauses.

P#18372 2016-01-20 03:50 ( Edited 2016-01-20 08:50)

Oh, that is pretty nifty and a good idea. I seriously underestimate the uses of modulo sometimes.

P#18373 2016-01-20 05:12 ( Edited 2016-01-20 10:12)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-07-13 14:27 | 0.012s | 2097k | Q:25