[alpha v8]Wastelands Of Death
[alpha v8]Wastelands Of Death
moved thread!
Last edited by jjmafiae on Wed Jan 02, 2013 7:51 pm, edited 6 times in total.
Re: [alpha v2]Wastelands Of Death
Nice and already quiet well playable.
The enemy movement is not very well. you should change it, so zombies don't cluster so much.
First, take the distance vector from a zombie to the player:
Then divide this vector by it's length
Then move the zombie in this direction, multiplied with it's speed
Now the zombies should walk to the player in straight lines.
The enemy movement is not very well. you should change it, so zombies don't cluster so much.
First, take the distance vector from a zombie to the player:
Code: Select all
dx = player.x - zombie.x
dy = player.y - zombie.x
Code: Select all
length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
Code: Select all
zombie.x=zombie.speed*dx*dt
zombie.y=zombie.speed*dy*dt
Check out my blog on gamedev
Re: [alpha v2]Wastelands Of Death
micha wrote:Nice and already quiet well playable.
The enemy movement is not very well. you should change it, so zombies don't cluster so much.
First, take the distance vector from a zombie to the player:Then divide this vector by it's lengthCode: Select all
dx = player.x - zombie.x dy = player.y - zombie.x
Then move the zombie in this direction, multiplied with it's speedCode: Select all
length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length
Now the zombies should walk to the player in straight lines.Code: Select all
zombie.x=zombie.speed*dx*dt zombie.y=zombie.speed*dy*dt
thanks for the tip/help i had ALOT of problem with the zombies
Re: [alpha v2]Wastelands Of Death
and nearly forgot about it: print("micha has a nice avatar!")micha wrote:Nice and already quiet well playable.
The enemy movement is not very well. you should change it, so zombies don't cluster so much.
First, take the distance vector from a zombie to the player:Then divide this vector by it's lengthCode: Select all
dx = player.x - zombie.x dy = player.y - zombie.x
Then move the zombie in this direction, multiplied with it's speedCode: Select all
length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length
Now the zombies should walk to the player in straight lines.Code: Select all
zombie.x=zombie.speed*dx*dt zombie.y=zombie.speed*dy*dt
Re: [alpha v2]Wastelands Of Death
micha wrote:Nice and already quiet well playable.
The enemy movement is not very well. you should change it, so zombies don't cluster so much.
First, take the distance vector from a zombie to the player:Then divide this vector by it's lengthCode: Select all
dx = player.x - zombie.x dy = player.y - zombie.x
Then move the zombie in this direction, multiplied with it's speedCode: Select all
length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length
Now the zombies should walk to the player in straight lines.Code: Select all
zombie.x=zombie.speed*dx*dt zombie.y=zombie.speed*dy*dt
i have a problem i cant get it to work:
Code: Select all
function zombie_move(dt)
for i,c in ipairs(zombies) do
if c.dead == false then
dx = player.x - c.x
dy = player.y - c.y
length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
c.x=zombies.speed*dx*dt
c.y=zombies.speed*dy*dt
end
end
end
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: [alpha v2]Wastelands Of Death
jjmafiae wrote:i have a problem i cant get it to work
Code: Select all
function zombie_move(dt)
for i,c in ipairs(zombies) do
if c.dead == false then
local dx = player.x - c.x
local dy = player.y - c.y
local length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
c.x= c.x + zombies.speed*dx*dt
c.y=c.y + zombies.speed*dy*dt
end
end
end
Help us help you: attach a .love.
Re: [alpha v2]Wastelands Of Death
Can you specify what exactly not works?jjmafiae wrote:i have a problem i cant get it to work:
Code: Select all
function zombie_move(dt) for i,c in ipairs(zombies) do if c.dead == false then dx = player.x - c.x dy = player.y - c.y length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length c.x=zombies.speed*dx*dt c.y=zombies.speed*dy*dt end end end
I have a wild guess: your variable "zombies" is a table of entities which have the information on all zombies. In the last lines you use zombies.speed. Maybe you mean c.speed? Or to test it you can also just use a global variable speed and set it to any value.
Check out my blog on gamedev
Re: [alpha v2]Wastelands Of Death
the zombie don't move it just stands still!micha wrote:Can you specify what exactly not works?jjmafiae wrote:i have a problem i cant get it to work:
Code: Select all
function zombie_move(dt) for i,c in ipairs(zombies) do if c.dead == false then dx = player.x - c.x dy = player.y - c.y length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length c.x=zombies.speed*dx*dt c.y=zombies.speed*dy*dt end end end
I have a wild guess: your variable "zombies" is a table of entities which have the information on all zombies. In the last lines you use zombies.speed. Maybe you mean c.speed? Or to test it you can also just use a global variable speed and set it to any value.
Re: [alpha v2]Wastelands Of Death
THANKS ROBIN AND MICHA YOU HAVE BEEN A HUGE HELP (i will put you in special thanks section when the game is ready!)Robin wrote:jjmafiae wrote:i have a problem i cant get it to workThe "local" declarations are not necessary, but they are proper.Code: Select all
function zombie_move(dt) for i,c in ipairs(zombies) do if c.dead == false then local dx = player.x - c.x local dy = player.y - c.y local length = math.sqrt(dx*dx+dy*dy) dx = dx/length dy = dy/length c.x= c.x + zombies.speed*dx*dt c.y=c.y + zombies.speed*dy*dt end end end
Who is online
Users browsing this forum: No registered users and 4 guests