Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How many case select statements does your program have

Author
Message
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 26th Oct 2011 04:00 Edited at: 26th Oct 2011 04:20
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.

Go through yourself at a wall.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 26th Oct 2011 04: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.

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 26th Oct 2011 04:24
Hu no line count in xcode. I just know i have one case select statement that is 51 different select statements.

Go through yourself at a wall.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Oct 2011 11:32
Quote: "what a disapointment"

Why are you disapointed? I don't understand the problem.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
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.

-- Jim
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
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?
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
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!
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
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.
Almus
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Brasil
Posted: 27th Oct 2011 20:54
Quote: "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.
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 27th Oct 2011 21:05 Edited at: 27th Oct 2011 21:07
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.

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.

Login to post a reply

Server time is: 2024-04-19 02:23:02
Your offset time is: 2024-04-19 02:23:02