Zombie Game

Show off your games, demos and other (playable) creations.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Zombie Game

Post by TechnoCat » Wed Nov 17, 2010 4:05 am

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.

User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: Zombie Game

Post by ishkabible » Wed Nov 17, 2010 4:13 am

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.

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Zombie Game

Post by TechnoCat » Wed Nov 17, 2010 4:25 am

I see vsync is on in the conf.lua, but indeed, my computer isn't obeying it.

User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: Zombie Game

Post by ishkabible » Wed Nov 17, 2010 6:10 am

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!!

User avatar
ninwa
Party member
Posts: 118
Joined: Tue Oct 12, 2010 1:21 am
Location: Metro Detroit
Contact:

Re: Zombie Game

Post by ninwa » Wed Nov 17, 2010 10:56 am

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.

User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Zombie Game

Post by arquivista » Wed Nov 17, 2010 11:36 am

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. ;)
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Zombie Game

Post by bartbes » Wed Nov 17, 2010 3:40 pm

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).

User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: Zombie Game

Post by ishkabible » Wed Nov 17, 2010 11:44 pm

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.

User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: Zombie Game

Post by Mud » Thu Nov 18, 2010 6:05 am

I added a muzzle flash and bullet trail for you. Kinda cheesy, but better than nothing. Needs some meatier gun sounds, too.
MuzzleFlash.png
MuzzleFlash.png (32.14 KiB) Viewed 980 times
Attachments
Zombie_Game.love
Muzzle flash added
(6.01 MiB) Downloaded 207 times
Last edited by Mud on Thu Nov 18, 2010 10:03 am, edited 1 time in total.

User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Zombie Game

Post by arquivista » Thu Nov 18, 2010 9:37 am

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).
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests