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!
[SOLVED]Really weird lag issue?[SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED]Really weird lag issue?[SOLVED]
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
-
- Citizen
- Posts: 51
- Joined: Mon Apr 15, 2013 8:21 pm
- Contact:
Re: Really weird lag issue?
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/
http://exez.in/
Re: Really weird lag issue?
Here's what I'm doing: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.
Code: Select all
lvl1:setDrawRange(0, 0, lvl1.width * lvl1.tileWidth, lvl1.height * lvl1.tileHeight)
"In those quiet moments, you come into my mind" - Liam Reilly
-
- Citizen
- Posts: 51
- Joined: Mon Apr 15, 2013 8:21 pm
- Contact:
Re: Really weird lag issue?
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.
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/
http://exez.in/
Re: Really weird lag issue?
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!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
"In those quiet moments, you come into my mind" - Liam Reilly
-
- Citizen
- Posts: 51
- Joined: Mon Apr 15, 2013 8:21 pm
- Contact:
Re: [SOLVED]Really weird lag issue?[SOLVED]
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/
http://exez.in/
Re: [SOLVED]Really weird lag issue?[SOLVED]
I'll keep that in mind! Thanks!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)
A lot of the code in the player class I don't understand(because it was copied and I edited it) but it works.
"In those quiet moments, you come into my mind" - Liam Reilly
Re: [SOLVED]Really weird lag issue?[SOLVED]
also turning on spritbatching for me gave me a 400+ fps improvement.
Who is online
Users browsing this forum: Roland Chastain and 221 guests