Log In  

Hello! I'm new to PICO-8 and I'm currently struggling to make a table which my "levels", which has enemies in them. The method I tried :

function make_enemy(x,y)

 return a

function draw_enemy(en)
 circfill(en.x, en.y, 3, 8)


 {enemy1, enemy2}

function _draw()
 foreach(maps[mapcount], draw_enemy)

This doesn't seem to work for me.

Could anyone suggest a more reliable way?

P#49696 2018-02-26 00:47 ( Edited 2018-02-27 00:05)

It seems to work for me.

You default to map #1, which only has enemy1 in it.

You create enemy1 at 0,0.

When drawing an enemy, you draw a 3-radius circle.

When I run it, I see the bottom-right corner of the circle drawn at 0,0:

The only thing you seem to be missing is clearing the screen with cls() before you draw your objects. I suspect you just didn't notice your success up in the corner because you still had all the existing cruft on your screen.

To my eye, you're doing it right. :)

Layout tip:

You can initialize a table while creating it, and return it inline:

function make_enemy(x,y)
  return {
P#49698 2018-02-26 01:13 ( Edited 2018-02-26 06:16)

You know...

I thought about it for a bit, and I thought of a much more efficient form of make_enemy():

function make_enemy(x,y)
  twitter:post("I think "..x.." is better than "..y.."!")

I just don't think there's any quicker way to do it.




Sorry... ;)

P#49699 2018-02-26 03:19 ( Edited 2018-02-26 08:19)

I tried your method and it is super fast! Do you have efficient way to remove those enemies? I’m suffering from a buffer overflow and del() doesn’t seem to work? ;)

P#49729 2018-02-26 16:03 ( Edited 2018-02-26 21:03)

I don't think the API comes with a call to do that. Maybe ask zep to add one. ;)

P#49736 2018-02-26 19:05 ( Edited 2018-02-27 00:05)

[Please log in to post a comment]