Posted: 26th Oct 2011 4:00
As I been developing my game I notice more then half my code was case select statements, and 1/4 of it was if statements. So I guess a game is a bunch of if and case statements what a disapointment.
Posted: 26th Oct 2011 4:10
how long is the program ?

i'd average about 1 select/case every 1000 lines. If statements are going be lot more frequent though.
Posted: 26th Oct 2011 4:24
Hu no line count in xcode. I just know i have one case select statement that is 51 different select statements.
Posted: 26th Oct 2011 11:32
what a disapointment

Why are you disapointed? I don't understand the problem.
Posted: 26th Oct 2011 11:49
If the compiler is efficient case statements are massively more efficient than a load of nested if - elseif etc, particularly if you order the cases select from most probable (or frequent) to least.
Posted: 27th Oct 2011 12:37
my test games runs at 60fps on iphone. it is made up of 95% case and if conditional statements. the rest is sin and cos sprite movement formulas!

it runs fast, so why the disappointment?
Posted: 27th Oct 2011 14:38
I read it as he was just disappointed that there wasn't more to game making than learning case statements. Although from my point of view it means we're doing our job properly as we managed to hide all the physics and rendering calculations in the engine so you can focus on the game logic!
Posted: 27th Oct 2011 15:38
Case/Select is a very powerful tool in my opinion. It allows for better organization of your code and keeps everything clean looking.
It's one of the best tools I have found for game flow as opposed to using a bunch of IF Statements which is what they are but looks cleaner.
If you combine Case/Select with Constants for your states you have the perfect setup.
Posted: 27th Oct 2011 20:54
Although from my point of view it means we're doing our job properly as we managed to hide all the physics and rendering calculations in the engine so you can focus on the game logic!


Agreed, thanks tgc for keeping things simple.
Posted: 27th Oct 2011 21:05
My WIP is far from simple, with only 2 instances of select, one for the main loop, one for level creation. Alot of IF and FOR NEXT loops, and alot of functions. It's nearing 3000 lines of code now. I don't know what game you are making 3d point, but it must be simple, just wait til you get to make a more complex one.

Try coding in machine language, then 50% of your game will be 0's and the rest will be 1's, even the media.. then we're talking booring.