Is code for a lot of video games mostly if statements?

638 views

I know some coding, it’s mostly for web development. To me it just seems things that happen in games occur as the result of some condition being met or not met. Am I missing the mark here or is it something similar?

In: Technology

6 Answers

Anonymous 0 Comments

Well, if statements are really the fundamental building block of programming. In assembly language, if statements are comparable to branch statements, which tells the execution to hop from the branch to the line of code to which it points.

So, yes and no. All logic driven code is done with branch statements, but there is a considerable amount of stuff happening in between. From a code density perspective, no, most lines of a game’s code are not if statements. However, in the underlying libraries used by the game, a single method call might entail the use of 100 if statements.

You are viewing 1 out of 6 answers, click here to view all answers.