Page 1 of 1

[alpha v8]Wastelands Of Death

Posted: Thu Dec 13, 2012 6:20 pm
by jjmafiae
moved thread!

Re: [alpha v2]Wastelands Of Death

Posted: Thu Dec 13, 2012 6:30 pm
by micha
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:

Code: Select all

dx = player.x - zombie.x
dy = player.y - zombie.x
Then divide this vector by it's length

Code: Select all

length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
Then move the zombie in this direction, multiplied with it's speed

Code: Select all

zombie.x=zombie.speed*dx*dt
zombie.y=zombie.speed*dy*dt
Now the zombies should walk to the player in straight lines.

Re: [alpha v2]Wastelands Of Death

Posted: Thu Dec 13, 2012 6:31 pm
by jjmafiae
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:

Code: Select all

dx = player.x - zombie.x
dy = player.y - zombie.x
Then divide this vector by it's length

Code: Select all

length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
Then move the zombie in this direction, multiplied with it's speed

Code: Select all

zombie.x=zombie.speed*dx*dt
zombie.y=zombie.speed*dy*dt
Now the zombies should walk to the player in straight lines.

thanks for the tip/help i had ALOT of problem with the zombies :D

Re: [alpha v2]Wastelands Of Death

Posted: Thu Dec 13, 2012 7:13 pm
by jjmafiae
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:

Code: Select all

dx = player.x - zombie.x
dy = player.y - zombie.x
Then divide this vector by it's length

Code: Select all

length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
Then move the zombie in this direction, multiplied with it's speed

Code: Select all

zombie.x=zombie.speed*dx*dt
zombie.y=zombie.speed*dy*dt
Now the zombies should walk to the player in straight lines.
and nearly forgot about it: print("micha has a nice avatar!")

Re: [alpha v2]Wastelands Of Death

Posted: Fri Dec 14, 2012 5:03 pm
by jjmafiae
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:

Code: Select all

dx = player.x - zombie.x
dy = player.y - zombie.x
Then divide this vector by it's length

Code: Select all

length = math.sqrt(dx*dx+dy*dy)
dx = dx/length
dy = dy/length
Then move the zombie in this direction, multiplied with it's speed

Code: Select all

zombie.x=zombie.speed*dx*dt
zombie.y=zombie.speed*dy*dt
Now the zombies should walk to the player in straight lines.

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

Re: [alpha v2]Wastelands Of Death

Posted: Fri Dec 14, 2012 5:49 pm
by Robin
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
The "local" declarations are not necessary, but they are proper.

Re: [alpha v2]Wastelands Of Death

Posted: Fri Dec 14, 2012 6:25 pm
by micha
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
Can you specify what exactly not works?
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

Posted: Fri Dec 14, 2012 7:50 pm
by jjmafiae
micha wrote:
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
Can you specify what exactly not works?
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.
the zombie don't move it just stands still! :|

Re: [alpha v2]Wastelands Of Death

Posted: Fri Dec 14, 2012 7:53 pm
by jjmafiae
Robin wrote:
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
The "local" declarations are not necessary, but they are proper.
THANKS ROBIN AND MICHA YOU HAVE BEEN A HUGE HELP (i will put you in special thanks section when the game is ready!)