Enemy/AI system {Still need help D:}

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Enemy/AI system

Post 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.
Help us help you: attach a .love.
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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.
User avatar
clickrush
Citizen
Posts: 83
Joined: Tue Dec 13, 2011 12:50 am

Re: Enemy/AI system

Post 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.
Sry about my english.
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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.
User avatar
clickrush
Citizen
Posts: 83
Joined: Tue Dec 13, 2011 12:50 am

Re: Enemy/AI system

Post 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 :)
Sry about my english.
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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:
MP6767
Prole
Posts: 16
Joined: Wed Dec 21, 2011 12:18 am

Re: Enemy/AI system

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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).
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 6 guests