Forums → Programming Forum → What is more performance efficient?
- 3 Replies
Is it more performance-efficient to have more classes? I was thinking, because there was this post on classes on memory efficiency and classes. I was wondering whether more classes is better, because I was thinking, if you had more classes, wouldn't references to more classes be detrimental to performance? I wasn't really sure though.
The question here is not how much classes exist in your project but how many instances of them you are using in a single moment of your program.
Think it that way:
You supposedly have a game using 3 types of ball: small, medium and large.
If you won't use classes, you are obliged to have your code include a function for each one of them, regardeless of the ball type you want to use at a given moment. You see a waste of memory here already aren't you? Now imagine that each ball has its own class which gets instantiated (and take memory that is) only when needed. Isn't better?
Furthermore, you can delete the class when no needed anymore and gain back its memory (or at least a big part of it).
With computers now days, you honestly don't need to worry about RAM efficiency when it comes to flash games. If you were doing lowest level C programming or something, say to make a video game engine, then by all means do it as memory efficient as possible.
If you are going to have tons of a few different things on a screen (for example, a couple enemy types) definitely rely on classes, it will let the processor focus more on rendering and less on keeping up with constructors, meaning a more consistent FPS.
If you're looking into getting higher FPS rates, do things on an interval instead of "onEnterFrame". This can lower processor calculations by a TON without losing any functionality. I switched over some stuff on my game to intervals that calculate at once per second (instead of 36 times a second) and it reduced lag by a lot, especially when there were lots of baddies on the screen.
You must be logged in to post a reply!
We strive to deliver the best gaming experiences on the internet and on your mobile phone. Play thousands of free online games, get access to free mmorpg games, online rpg games, fun online flash games, and more.
We offer free flash games in many different genres: online shooting games, online puzzle games, online war games, free online car games, free online hidden object games and dozens more.
This is the best place on the web to play online games for free! No matter what game style you prefer, we've got it here.
Want to advertise on Armor Games? Send us a note!
Gaming websites, passionate bloggers, and quirky streamers are welcome to share or review our games. If you need game keys, art, trailers, screenshots or more check out our press kit website.
Game developer? Visit developers.armorgames.com to request AG developer status, find documentation on our APIs, and get access to our development environment. Let's make sweet, sweet games together.
Looking for a publishing partner that can help your app rocket to success? Contact the mobile team to learn more about how we can help!