Log In  
Follow
Birdstonelabs
Follow

Hello there!

I have been exploring Pico8 for over 2 years now trying to understand coding with let's say "some" progress.

But I'm stuck with Tables. I mean, I get the concept but there's something I haven't got to fully understand therefore I get mixed results.

So I created actors (player, enemy) as tables but I can't make them spawn several instances on screen. So far I have got to draw 5 enemies on stage (at random position) but they keep appearing all the time (where they should appear once), any light about what I'm doing wrong? here's the code:

--init
function _init()
--globals
wave=5
w=112
h=112

--player
pyr={
spt=1,
x=w/3,
y=h/3,
life=10,
spd=2,
flp=false,
idle=true,
}
enms={} --enemies

enm={ --single enemy

spt=10,
life=5,
spd=1,
flp=false,
idle=true,
draw=function()
spr(enm.spt,flr(rnd(w)),flr(rnd(h)))
end,
}

for a=1,wave do
add(enms,enm)
end

end

--draw
function _draw()
cls()
print(#enms,20,20,7) --checking created instances from enms table
foreach(enm,enm:draw())
end


I have read tutorials, videos and everything available but still I haven't figured it out yet :( Any help is much appreciated.

P#73732 2020-03-06 21:40

So I'm just another old school gaming enthusiast who loves to make games for fun. I stumbled upon Pico-8 and I got so amazed by the concept that I decided to learn programming. I have made some mobile games before but I used Construct 2, which provides a set of widgets and tools to create a game with just a little knowledge of coding.

However, after 2-3 weeks with P8 I got into to this situation where I'm wondering myself if I want to learn coding by making a tiny game or just want to have fun while making a tiny game.

I'd love to say both but for me, it depends of how "intuitive" is to communicate with the hardware through a programming language (that's the reason why languages exist) but at this time it is not. There are a few things that should be easy but for some reason I just can't get to understand, like:

  • Rotate a sprite by 90 degrees in order to recycle sprites on top view games instead of having 4 different animations for each direction
  • Simple stuff like understanding how to handle arguments within functions or tables

It's Worth to recall that I'm an absolute Noob on this matter and sometimes I feel that my brain is just not compatible with programming logic :(

And yes, I have spent days trying to understand the amazing pieces of code from the community and I have learned a lot, but there are some little things that I havent't found anywhere on the web that could help me and other newbies like me to find a balance between designing a game through graphics and music, and making it work through coding. I have created this topic to share these "silly and basic questions" by non-programmers :)

P#50404 2018-03-14 14:42 ( Edited 2018-03-17 10:51)

Follow Lexaloffle:        
Generated 2020-10-31 21:42 | 0.087s | 2097k | Q:12