Author Topic: Tips & Tricks for Optimization: Reloaded  (Read 2343 times)

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Tips & Tricks for Optimization: Reloaded
« on: April 19, 2020, 12:32:10 PM »

Tips & Tricks for Optimization
Reloaded

Platform Builder is quite slow sometimes, and slow games are boring. Here are some tips and tricks for optimizating your game. This is a reloaded version to the original, with more stuff. Let's go:



1.- Avoid cluttering tiles
Tilesets are not very laggy, but if you use too much of them, they will start to lag. Use no more than the necessary and also use expandable tiles if possible.



2.- If you use looping command prompts, use constant type:
As far of my researchs, constant looping is much faster than normal, even if it sounds stupid. You can set this type of looping by executing
Code: [Select]
loop = constantat the start of the area.



3.- Minimize hud commands
It's not recommended to loop hud updates if you're using custom HUDs. If you want to update the hud when you collect a coin, do it when you collect a coin and only the money counter for better optimization.

Example:
Code: [Select]
//Collect CP. Money item
money + 1
<hud text 2>[money]$ //This is an example if the hud text 2 was the money.



4.- Use curly brackets less as possible
When using conditionals, you may notice these are sometimes laggy and you can find them weak. If your conditional only executes 1 command, remove the curly brackets so you can do this.
Code: [Select]
//Bad code
if score > 1000
{
lives + 1
}
//Better code
if score > 1000
lives + 1

This trick gave me better optimization for my "test" games.



5.- Use area variables as much as possible:
When you run a code, you may need to use variables to do fast calculations for THAT code. Use just area variables for that.
In fact, much variables saved on memory actually causes lag, so, it's better to make their values stay in memory as least as possible. Area variables remove after the area finishes.
Also, if you use variables for only 1 code, and doesn't need to be saved for more than 1 frame, use the same name for all them, so they are reused each time you need a variable for only 1 code.
Example of names I use:
Code: [Select]
var i = 0
var j = 1
var k = 2
//In general, 1 is good.



Hope these tips are useful for you. Thanks for reading and happy building! :D
Sorry because my English is not very good because I'm Spanish ;) :P

CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Tips & Tricks for Optimization: Reloaded
« Reply #1 on: April 20, 2020, 03:56:35 AM »
Are you sure of all of these?

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Re: Tips & Tricks for Optimization: Reloaded
« Reply #2 on: April 20, 2020, 10:09:18 AM »
Sorry because my English is not very good because I'm Spanish ;) :P

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Re: Tips & Tricks for Optimization: Reloaded
« Reply #3 on: April 20, 2020, 11:26:00 AM »
I will explain these better:

1.- I think you know actually this, also TingThing said.

2.- As far of my projects, constant looping is impressively better optimized than staggered, at least with big quantity of commands.

3.- HUD commands were very laggy for me, I used a lot of huds and this system works pretty fine for me.

4.- I had a big looping command prompt that used a lot of curly brackets, I removed the unnecessary ones and the fps raised like foam.

5.- This is not much PB but lot more for real programming. This is why local variables exist in coding, they're created in the same frame that they're removed if you won't use them anymore as they consume space in RAM (I think) that can be used by other more prioritary stuff. As PB doesn't have local variables, reusing area variables for the same proposit than local variables would be allows to free a little of memory on your PC.

Another way to raise a few fps is removing comments when you're going to export the game in a separate slot, as comments are also lines that the command prompt reader should have to check first and that is also memory consuming. Idk how much helpful will be this, but depends on the amount of comments in your game. This is not necessary on games made with other programs as these mostly convert into machine language and that removes entirely the comments from the exported exe, so you don't have to concern as user when playing the final game.
« Last Edit: April 20, 2020, 11:29:03 AM by Antikore »
Sorry because my English is not very good because I'm Spanish ;) :P

CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Tips & Tricks for Optimization: Reloaded
« Reply #4 on: April 20, 2020, 03:36:32 PM »
Ah. I've done a lot of work in ASM to decrease commands use. ASM levels take a long time to load, due to the many decorations. I found a way to make the grass still look nice, without sacrificing speed. I hope it'll run well on even low end computers. Yes, I know, my PC is low end, but it's not _that_ low end! I can get full speed playing games like Human Fall Flat, Roblox, and others no problem. And yes, that's with the graphics on the highest settings. 1080p resolution, ambient occlusion, HD shadows, etc.

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Re: Tips & Tricks for Optimization: Reloaded
« Reply #5 on: April 20, 2020, 04:18:07 PM »
So that's not low end ;)
Sorry because my English is not very good because I'm Spanish ;) :P

CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Tips & Tricks for Optimization: Reloaded
« Reply #6 on: April 20, 2020, 07:12:48 PM »
It is low end compared to today's standards. This computer is a dinosaur in comparison with modern computers. It's a 2012. And the computer itself runs very poorly just doing basic functions.

War

  • "The top player is here!"
  • Level 20: Nobom
  • *
  • Posts: 1490
    • View Profile
    • My website
Re: Tips & Tricks for Optimization: Reloaded
« Reply #7 on: April 23, 2020, 02:43:34 PM »
And the computer itself runs very poorly just doing basic functions.
Move to windows 7
Hey, wassup wassup? My name is Warrior555MainsGanon (but just call me War) and I'm the main guy behind Megaman Zero Online and the upcoming Matt's Adventure! I don't speak often here but I'm a very friendly lad so if you wanna talk, don't hesitate!

Aeterna Games | Æ

  • Game Developer and Creator of Aeterna Games | Æ
  • Level 10: Jelli
  • *
  • Posts: 215
  • I‘m a big fan of Escape-Rooms =)
    • View Profile
    • My YouTube Channel
Re: Tips & Tricks for Optimization: Reloaded
« Reply #8 on: April 23, 2020, 02:56:42 PM »
Move to windows 7

Windows 10 is great too.
My Projects:


CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Tips & Tricks for Optimization: Reloaded
« Reply #9 on: April 23, 2020, 05:54:01 PM »
This thing is running Windows 10. It came with 8, but it's very buggy with 8.1. It runs very badly at 8.1 for no reason. It is possible the 8.1 installation was corrupt or something, but it would do absurd things. I had that for a long time till I finally was able to upgrade to 10. And all of those issues ceased. It's a long story. I love Windows 7, too. But it becoming obsolete...eh...I think you get it.

I'm hoping to get a new PC when this corona virus panic settles down.