[SOLVED]Really weird lag issue?[SOLVED]

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.
Post Reply
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

[SOLVED]Really weird lag issue?[SOLVED]

Post by Eamonn »

I'm working on a game, but when I load in my map using ATL, I get really bad lag and the FPS drops down to like 15. I can't seem to figure out what's going on! If someone could help I'd appreciate that!

I know the game's idea might be terrible, but I've worked for over a week on it! I plan to add over 200 levels and release it when I have 30 levels done. I also plan to comment the code.

The player code was just code from Goature's platformer tutorial and modified by me. There might be some unused variables. I am also aware that I'm possibly using an older version of ATL. This is intentional.

So yeah, don't rage at me of there is inefficient code. It'll all be fixed when the game is released.

The reason I'm making games is to learn, and I'm learning how to use a camera in LÖVE and ATL for Tiled Maps.

Game: https://www.dropbox.com/s/06j0eh4mnwonbb7/NOM.love

Thanks! Any help is appreciated! :D
Last edited by Eamonn on Fri Jun 28, 2013 1:39 pm, edited 1 time in total.
"In those quiet moments, you come into my mind" - Liam Reilly
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Really weird lag issue?

Post by IndieRetro »

Didn't look through the code but make sure you are not drawing the entire map all at once, you can use this to draw the map from a certain position

Code: Select all

Map:setDrawRange(x, y, w, h)
--Sets the draw range.
irc.freenode.org ##oodnet
http://exez.in/
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Really weird lag issue?

Post by Eamonn »

IndieRetro wrote:Didn't look through the code but make sure you are not drawing the entire map all at once, you can use this to draw the map from a certain position

Code: Select all

Map:setDrawRange(x, y, w, h)
--Sets the draw range.
Here's what I'm doing:

Code: Select all

lvl1:setDrawRange(0, 0, lvl1.width * lvl1.tileWidth, lvl1.height * lvl1.tileHeight)
I believe that's right!
"In those quiet moments, you come into my mind" - Liam Reilly
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Really weird lag issue?

Post by IndieRetro »

I think you are doing that wrong, you want something like (camera.x,camera.y,640,480), 640x480 being the draw distance from camera.x and camera.y

EDIT: Yep, you are doing it wrong, what you are doing is drawing the entire map all at once from 0x0 to the maps width and height, well a bit more actually o_O anywho change it to something like this.

Code: Select all

lvl1:setDrawRange(camera.x, camera.y, 640, 480)
Last edited by IndieRetro on Fri Jun 28, 2013 1:39 pm, edited 1 time in total.
irc.freenode.org ##oodnet
http://exez.in/
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Really weird lag issue?

Post by Eamonn »

IndieRetro wrote:I think you are doing that wrong, you want something like (camera.x,camera.y,640,480), 640x480 being the draw distance from camera.x and camera.y
I adjusted the 640 and 480 to 800 by 600 as that's the size of my window. I'll try to get the camera to move. But that fixed it for not! I guess the map was so big and I was drawing too much all at once! Thanks! :D
"In those quiet moments, you come into my mind" - Liam Reilly
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: [SOLVED]Really weird lag issue?[SOLVED]

Post by IndieRetro »

No problem! if you are not using a camera or something you could always do it like this

Code: Select all

lvl1:setDrawRange(player.x-800/2, player.y-800/2, 800/2, 600/2)
irc.freenode.org ##oodnet
http://exez.in/
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: [SOLVED]Really weird lag issue?[SOLVED]

Post by Eamonn »

IndieRetro wrote:No problem! if you are not using a camera or something you could always do it like this

Code: Select all

lvl1:setDrawRange(player.x-800/2, player.y-800/2, 800/2, 600/2)
I'll keep that in mind! Thanks!

A lot of the code in the player class I don't understand(because it was copied and I edited it) but it works. :D
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
jasonisop
Citizen
Posts: 93
Joined: Thu Jun 21, 2012 1:35 am

Re: [SOLVED]Really weird lag issue?[SOLVED]

Post by jasonisop »

also turning on spritbatching for me gave me a 400+ fps improvement.
Post Reply

Who is online

Users browsing this forum: Roland Chastain and 221 guests