Wile94
Member
Hello, first of all I'm not an english native speaker so I apologize in advance if something doesn't make sense.
Lately I'm being pretty much concerned about how to manage performance in GM because I'm making a pretty big fighting/action/roguelike platformer pixel art project:
I'm still developing my first level, and my frame rate is quite high (600-700 average). Although, sometimes the game gets a little laggy, mostly (not always) when I enter a big section of a level (1920x1344 is the largest room so far and I looking to make some larger ones) dropping to 300-180 and sometimes below 60 . I think it's mainly because of my laptop (Intel HD 4000, 8gb RAM, i7-3632QM @2.20ghz-2.20ghz) but it should handle well this type of retro-pixel art games.
Here are some of my doubts:
I know, I know... I read many times to not worry about performance issues until there's a real one. But as I said, I'm a hobby programmer, I don't do this for a living, I'm just doing for the love of learning and making art. This questions may even help beginner programmers like me who are looking to make a living of this.
Cheers
I'm using Windows Target Platform by he way...
I've been learning GML for about a year and a half on my own by watching tutorials and reading forums. I originally started to "code" on M.U.G.E.N. (fighting game engine by elecbyte, some of you may know it), so moving to GML seemed to be pretty challenging but I kinda get my head around how it works. Instead of changing variables in states controllers (mugen language), I got to make my own "engine" from scratch which it was hard as hell at the beginning. I've played videogames my whole life and I was very interested in programming when I was a kid, but I ended up doing it just as a hobby and I pursued music composition/production as my actual career.
I made some rpgs and small platformer games to keep myself learning and understanding how GameMaker handles memory, graphics, views, bounding boxes, collisions, animations, data structures, etc. I learned how to replace "image_speed" with ds_lists or arrays to handle my animations, replace all the "solid objects" with a ds_grid based collision system, animate tiles and bgs, export my levels into "*.ini" files and so on.
I made some rpgs and small platformer games to keep myself learning and understanding how GameMaker handles memory, graphics, views, bounding boxes, collisions, animations, data structures, etc. I learned how to replace "image_speed" with ds_lists or arrays to handle my animations, replace all the "solid objects" with a ds_grid based collision system, animate tiles and bgs, export my levels into "*.ini" files and so on.
Lately I'm being pretty much concerned about how to manage performance in GM because I'm making a pretty big fighting/action/roguelike platformer pixel art project:
- I made a random map generator so, when a new run starts, it makes a complete (sort of hehe) new level with severals rooms kinda like Binding of Isaac. Each room holds it's own amount of randomness (enemies, pickups, moving platforms, items, traps, secrets, etc.).
- Terrain is made with a ds_grid which I use to handle collisions and place my tiles. Cells are 16x16 pixels.
- The game runs in only one room (main menu and stuff got their own). When the player leaves a level section, I save evey instance left behind in a ds_map/ini file, restart the room and load the new section.
- Resolution is 640x360. I split the whole room size with this params (more or less) and create a grid to handle activation/deactivation. I check when the view corners enters an unactive cell and run deactivation/activation region function so it doesn't do it every step. Some instance deactivate themselves when leaving active cells.
- I have only one persistent object that handles key config, graphics config, score, unlocks, save files, etc. Then when a run starts I have some controllers: one for map generation (creates the map, save up ini files to load when needed and keeps track of triggers like door switchs or portals), one for level section (holds the terrain grid, place it tiles and instances), one for graphs and fx (animated tiles/bgs, lighting surfaces) and one for the view (follows the player and handles the activation/deactivation of instances). Only this last two have step events or at least the more coded ones.
- Room speed at 60fps.
I'm still developing my first level, and my frame rate is quite high (600-700 average). Although, sometimes the game gets a little laggy, mostly (not always) when I enter a big section of a level (1920x1344 is the largest room so far and I looking to make some larger ones) dropping to 300-180 and sometimes below 60 . I think it's mainly because of my laptop (Intel HD 4000, 8gb RAM, i7-3632QM @2.20ghz-2.20ghz) but it should handle well this type of retro-pixel art games.
Here are some of my doubts:
- If tiles aren't inside the view, they won't be drawn. Is this correct?
- If that's not the case, What if I try splitting my tiles into several layers so I can use tile_layer_show/hide when they're inside/outside the view? Will this boost my fps? Will it drop them? Or will it make no difference at all? The fact of having so many layers makes me think it may be counterproductive.
- I tried to draw my tiles into a surface, this kinda boosted my fps in smaller rooms and it didn't make much of a difference in bigger ones. Then I read that creating a surface will make a new texture sheet, should I avoid this? My first level is a cave and using surfaces instead of tiles grants me the option of swap the color palette and mix things up a little more, because... you know... more random stuff .
- The player has plenty of mechanics and abilities: walk, run, jump, wall jump, ledge grab, combo attacks on ground and air, throw bombs/stuff, shoot bullets, getting hitted in various ways, swim. I use state machines for this but I read somewhere that using multiple objects instead of one may improve performace. What do you think about this?
- Enemies should use their own draw events? Or is it better to use one object to draw them all? Same question with pickups (coins, health boost, etc). I mean, I use one object to draw several lighting objects in a surface...
- Is it better to have a room sized static surface? Or a view sized dynamic surface? This last one should take less GPU, right?
I know, I know... I read many times to not worry about performance issues until there's a real one. But as I said, I'm a hobby programmer, I don't do this for a living, I'm just doing for the love of learning and making art. This questions may even help beginner programmers like me who are looking to make a living of this.
Cheers
I'm using Windows Target Platform by he way...
Last edited: