Do more classes slow a game down?

I was wondering if it was better to separate code into many classes, or just leave it in my main class. For example, say I have a method that checks certain things with if statements. Would it be beneficial to my app to store the code into a class where I would call it in the main method, or keep it in the draw or setup method in the main method? I am only wondering this because I would like things to be called as quickly as possible as I am trying to incorporate all iPads into my app. Thanks guys!

splitting your code into classes or subfunction is a must to keep your code manageable. In general it will not slow down the execution noticeably.

@YoloSwag best rule for programming is don’t optimise it until you’ve finished making it work, once it works then look in to making things faster. From what I’ve seen classes do not slow down to any noticeable extent, literally milliseconds. I think its just one extra call to make before the code is executed, and a computer is made for thousands upon thousands of calls a seconds so don’t worry make it as neat as you want with as many classes.

Totally agree. Code to make it work, and ideally to make the code as clean and easy to understand as possible.

Then performance tune only where the bottlenecks are. Performance tuned code invariably trades maintainability and readability for performance, and the dirtier you make the code, the harder it’ll be to progress the app from there on in.

I guess the biggest slowdown with classes is likely to be referencing global variables external to the class, rather than passing parameters to methods and the judicous use of local vars within each method which in Lua is significantly faster.