Page 2 of 3

Re: Enemy/AI system

Posted: Wed Dec 21, 2011 10:40 pm
by MP6767
Robin wrote:That's more like it.

You made a mistake with the variable name. You used zomb, while it should be zombie.
Incorrect parameter type: expected userdata

Re: Enemy/AI system

Posted: Thu Dec 22, 2011 5:55 am
by MP6767
Sorry for double post, but it works now. Just one problem, it spawns it in the top-left corner of the game screen, not even on the map. I also don't know where to begin on making it move.

Re: Enemy/AI system

Posted: Thu Dec 22, 2011 11:10 am
by Robin
That's because you set x and y to 0. Set them to something different (for example using math.random, like you wanted) to put the zombies in other positions.

To make them move, change the x and y properties of the zombies in love.update.

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 1:01 am
by MP6767
Robin wrote:That's because you set x and y to 0. Set them to something different (for example using math.random, like you wanted) to put the zombies in other positions.

To make them move, change the x and y properties of the zombies in love.update.
I'm sorry, I'm just lost. What are the x and y properties supposed to be? zombie.x and zombie.y don't work, dt.x dt.y, self.x self.y, zombietype.x, zombietype.y, etc.

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 1:34 am
by clickrush
MP6767 wrote:
Robin wrote:That's because you set x and y to 0. Set them to something different (for example using math.random, like you wanted) to put the zombies in other positions.

To make them move, change the x and y properties of the zombies in love.update.
I'm sorry, I'm just lost. What are the x and y properties supposed to be? zombie.x and zombie.y don't work, dt.x dt.y, self.x self.y, zombietype.x, zombietype.y, etc.
It looks like you guess/expect too much without knowing much of how things work. We beginners are lucky that the wiki provides awesome tutorials that guide us through the first steps into the compelling and fun matter of programming with LÖVE:

I suggest you do this tutorial step by step: http://love2d.org/wiki/Tutorial:Gridlocked_Player

It is very compact and understandable and something like this should be one of the first things you do.

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 1:37 am
by MP6767
Yeah, that's the tutorial I'm using. I'm making a simple game out of it. I know multiple scripting languages already, but I just started learning Lua a few days ago.

To be a bit more clear, I've looked at pretty much all of the tutorials on tutorials on the Wiki.

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 1:48 am
by clickrush
I'am sorry I just now found your code in one of your replies. Your questions just seemed to be so general that I assumed your a complete beginner like me. Looking at the code I don't really get what your doing actually :)

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 2:19 am
by MP6767
clickrush wrote:I'am sorry I just now found your code in one of your replies. Your questions just seemed to be so general that I assumed your a complete beginner like me. Looking at the code I don't really get what your doing actually :)

It's okay :awesome:

Re: Enemy/AI system

Posted: Fri Dec 23, 2011 5:16 am
by MP6767
MP6767 wrote: I'm sorry, I'm just lost. What are the x and y properties supposed to be? zombie.x and zombie.y don't work, dt.x dt.y, self.x self.y, zombietype.x, zombietype.y, etc.

Re: Enemy/AI system {Still need help D:}

Posted: Fri Dec 23, 2011 7:51 am
by Robin
In love.draw, you loop over the zombies. If you do the same in love.update, you can do

Code: Select all

for i, foo in pairs(zombies) do
    foo.x = ....
    ...
end
You can use whatever name you like (best make it a clear one, though).