Page 3 of 4
Re: Zombie Game
Posted: Wed Nov 17, 2010 4:05 am
by TechnoCat
ishkabible wrote:TechnoCat wrote:I can't play because zombies move at the speed of light.
really? i slowed them down? mabey check to see if it's waiting for the v sync in the config file? any one else having this issue?
You need to familiarize yourself with using deltatime as a multiplier.
/scripts/Zombie.lua:32
Code: Select all
function Zombie:update()
local px = ThePlayer.x
local py = ThePlayer.y
local zx = self.x
local zy = self.y
self.theta = math.atan2(py-zy,px-zx) + math.pi/2
local ix = math.sin(self.theta)*self.speed
local iy = -math.cos(self.theta)*self.speed
self.x = zx + ix
self.y = zy + iy
end
You need delta time. Delta Time, commonly referred to as dt, is the time in seconds since the last time it was called.
What you should take from this is that
self.x = zx + ix is a computation based speed. If my computer if faster than yours, then my computer is going to be doing
self.x = zx + ix a lot faster than yours, making zombies very fast. However, if you pass the dt from
love.update(dt) into
Zombie:update() as
Zombie:update(dt) and then change
self.x = zx + ix to
self.x = zx + ix*dt, it will only do a full
ix increase every second on every computer.
Code: Select all
function Zombie:update(dt)
local px = ThePlayer.x
local py = ThePlayer.y
local zx = self.x
local zy = self.y
self.theta = math.atan2(py-zy,px-zx) + math.pi/2
local ix = math.sin(self.theta)*self.speed*dt
local iy = -math.cos(self.theta)*self.speed*dt
self.x = zx + ix
self.y = zy + iy
end
Hope this helps.
Re: Zombie Game
Posted: Wed Nov 17, 2010 4:13 am
by ishkabible
well it runs at 60fps on mine with vsync. yes frame independent games are more ideal and i should make that improvement but i don't see how you computer would do this any faster than mine if the vsync is set to true. that calculation is frame by frame so unless on your system the vsync is at a higher frame rate than 60fps it should run at the same speed. im not trying to say it's not happening on your computer im just confused as to how it's running any faster.
Re: Zombie Game
Posted: Wed Nov 17, 2010 4:25 am
by TechnoCat
I see vsync is on in the conf.lua, but indeed, my computer isn't obeying it.
Re: Zombie Game
Posted: Wed Nov 17, 2010 6:10 am
by ishkabible
strange, what would cause this? still good idea to make it frame independent. that way on slower computers the gameplay is relatively the same and it should be a work around for what ever is causing this issue on your system. im really tired now so ill fix it tomorrow
thanks for the feed back!!
Re: Zombie Game
Posted: Wed Nov 17, 2010 10:56 am
by ninwa
I enjoyed the update! Would it be possible to capture the mouse while the game is running? On more than one occasion I managed to click outside the window and had to quickly alt-tab back in.
Re: Zombie Game
Posted: Wed Nov 17, 2010 11:36 am
by arquivista
I liked too the update with another class of enemy. To be easier to know what to download you should start v.xxx the files. Probably you should make the other mob harder to kill.
Re: Zombie Game
Posted: Wed Nov 17, 2010 3:40 pm
by bartbes
NEVER trust vsync to make your games run at proper speed. There, that's out. Now the reasons:
- It is merely a request, video drivers are known to have options to override it.
- What about people who have slower computers?
- Even if vsync works, why would you not make it framerate independent? It's not like it's hard.
On a more.. happy note, it sounds good, can't wait to play it (can't at the time of writing).
Re: Zombie Game
Posted: Wed Nov 17, 2010 11:44 pm
by ishkabible
it would not make it frame independent just 'if' your computer can run it at 60fps then the game will run well. frame independent code allows for lower frame rates witch is nice.
Re: Zombie Game
Posted: Thu Nov 18, 2010 6:05 am
by Mud
I added a muzzle flash and bullet trail for you. Kinda cheesy, but better than nothing. Needs some meatier gun sounds, too.
- MuzzleFlash.png (32.14 KiB) Viewed 2685 times
Re: Zombie Game
Posted: Thu Nov 18, 2010 9:37 am
by arquivista
Mud wrote:I added a muzzle flash and bullet trail for you. Kinda cheesy, but better than nothing. Needs some meatier gun sounds, too.
MuzzleFlash.png
Well seems nice but you did the things in the version without 2nd type of mob. Please ishkabible, like I warned try to put version in updates (and remove one of the versions).