Camera Shake? / Collisions / Enemies...

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.
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Camera Shake? / Collisions / Enemies...

Post by Ryne » Mon Nov 08, 2010 6:39 pm

Robin wrote:Three things:
  1. Now I'm not sure what the issue was. Wasn't it the initial position of the enemy weird?
  2. You could change the if-statement to if not CheckCollision(player, enemy) then. It works the same, but you're less likely to get odd looks from others. ;) Perhaps if you rename the function to hasCollision or isCollision or so it will make more sense?
  3. The enemy speed doesn't have an upper limit: the further they are away, the faster they will go. Off the top of my head, that will probably mean that:
    1. You can't outrun the zombies. Ever.
    2. Any horde will end up in one jumbling mess, since the ones at the back move faster than the ones in front.
Right now you can outrun the single zombie no problem since he slows down as he gets closer. I think the way it is right now (it will need tweaking when there is more than 1 enemy) is fine, you can outrun the zombies but they always look like they will catch you.

The issue is this:

When dragging my "game folder" (the one containing main.lua etc.) onto the love shortcut it works fine, the exact way it was coded.

If I package the game as a ".love" the enemy oddly approaches from the left instead of the right? Though after some testing this doesn't happen every time, I think only times where the .love file has a name like "zombie_test_long_name.love" instead of just something like "zombie.love".

Solution?:

I was thinking that giving the player an ACTUAL starting value might help. Basically a freeze time since right now start position could be different every time (depending on the load time)

Another thing I found was that if I copy and paste the game folder (to create "game - copy"" and drag the COPY onto the love shortcut the same issue occurs, though after changing the name of the folder from "game - copy" to something smaller like "random" it works fine again. It's so weird lol :crazy:

On an unrelated side-node: I almost lost this whole post since my internet "cut-out" luckily the back button let me copy it...
@rynesaur

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Camera Shake? / Collisions / Enemies...

Post by Robin » Mon Nov 08, 2010 6:51 pm

I think I know how to solve the problem (also, it seems independent of the things you mentioned, in my testing).

Try adding this at the beginning of love.update:

Code: Select all

dt = math.min(dt, 0.1) -- or some other not too large value
Help us help you: attach a .love.

User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Camera Shake? / Collisions / Enemies...

Post by Ryne » Mon Nov 08, 2010 6:58 pm

Robin wrote:I think I know how to solve the problem (also, it seems independent of the things you mentioned, in my testing).

Try adding this at the beginning of love.update:

Code: Select all

dt = math.min(dt, 0.1) -- or some other not too large value
That fixed it. How exactly did you come to this conclusion?
@rynesaur

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Camera Shake? / Collisions / Enemies...

Post by Robin » Mon Nov 08, 2010 7:17 pm

Because of this:
Robin wrote:The enemy speed doesn't have an upper limit: the further they are away, the faster they will go. Off the top of my head, that will probably mean that:
  1. You can't outrun the zombies. Ever.
  2. Any horde will end up in one jumbling mess, since the ones at the back move faster than the ones in front.
This also means that if the dt is very large (as is the case at the beginning of the game), their speed is very large as well, causing the zombies to be "warped" to the other side of the player.
Help us help you: attach a .love.

User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Camera Shake? / Collisions / Enemies...

Post by Ryne » Mon Nov 08, 2010 7:41 pm

Robin wrote:Because of this:
Robin wrote:The enemy speed doesn't have an upper limit: the further they are away, the faster they will go. Off the top of my head, that will probably mean that:
  1. You can't outrun the zombies. Ever.
  2. Any horde will end up in one jumbling mess, since the ones at the back move faster than the ones in front.
This also means that if the dt is very large (as is the case at the beginning of the game), their speed is very large as well, causing the zombies to be "warped" to the other side of the player.
I assumed it was because of the function, I just didn't know why, thanks again!
@rynesaur

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Camera Shake? / Collisions / Enemies...

Post by Robin » Mon Nov 08, 2010 7:42 pm

Glad to help. ;)
Help us help you: attach a .love.

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Camera Shake? / Collisions / Enemies...

Post by zac352 » Mon Nov 08, 2010 11:57 pm

What did I miss? :roll: My brother has been hogging the computer for 4 hours.
Here's some generic code to make a zombie move towards you, seeing as I noticed some posts about it.

Code: Select all

local zombieX,zombieY=-100,-100
local playerX,playerY=0,0

function magnitude(x,y)
return math.sqrt(x*x + y*y)
end

function norm(x,y)
local dist=magnitude(x,y)
return x/dist,y/dist
end

while true do --main loop
local dirx,diry=norm(playerX-zombieX,playerY-zombieY)
zombieX=zombieX+dirx*speed*dt
zombieY=zombieY+diry*speed*dt
end
When I get some time, I'll look over your code and make some awesome zombie hording stuff. ;)
Hello, I am not dead.

User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Camera Shake? / Collisions / Enemies...

Post by Ryne » Tue Nov 09, 2010 12:33 am

zac352 wrote:What did I miss? :roll: My brother has been hogging the computer for 4 hours.
Here's some generic code to make a zombie move towards you, seeing as I noticed some posts about it.

Code: Select all

local zombieX,zombieY=-100,-100
local playerX,playerY=0,0

function magnitude(x,y)
return math.sqrt(x*x + y*y)
end

function norm(x,y)
local dist=magnitude(x,y)
return x/dist,y/dist
end

while true do --main loop
local dirx,diry=norm(playerX-zombieX,playerY-zombieY)
zombieX=zombieX+dirx*speed*dt
zombieY=zombieY+diry*speed*dt
end
When I get some time, I'll look over your code and make some awesome zombie hording stuff. ;)
Thanks for the post, but the zombie already walks toward the player. I like how it's set up now, the zombie is faster if it's further away and slows as it gets closer, it gives the illusion that the zombie will catch you when you can slightly outrun him. The challenge comes with hordes, even though you can outrun one, you wont be able to outrun a mob.
@rynesaur

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Gunroar:Cannon() and 32 guests