[alpha v8]Wastelands Of Death

Show off your games, demos and other (playable) creations.
Post Reply
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

[alpha v8]Wastelands Of Death

Post by jjmafiae »

moved thread!
Last edited by jjmafiae on Wed Jan 02, 2013 7:51 pm, edited 6 times in total.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: [alpha v2]Wastelands Of Death

Post 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.
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: [alpha v2]Wastelands Of Death

Post 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
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: [alpha v2]Wastelands Of Death

Post 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!")
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: [alpha v2]Wastelands Of Death

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

Re: [alpha v2]Wastelands Of Death

Post 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.
Help us help you: attach a .love.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: [alpha v2]Wastelands Of Death

Post 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.
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: [alpha v2]Wastelands Of Death

Post 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! :|
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: [alpha v2]Wastelands Of Death

Post 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!)
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests