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

639 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

It uses a lot of objects and then if statements between them.
Something like this, though with actual coding language:

Create circle, name it “Player”

Create rectangle, name it “Floor”

Correspond “Player” position on screen to WASD, speed 3

If “Player” touches “Floor,” add friction of some -x

If “Player” not touching “Floor,” add gravity of some -y

Create rectangle, name it “Gun”

Create triangle, name it “Bullet”

Create circle, name it “Enemy”

Create number counter, name it “Kill Count”

If “Player” has “Gun” and X button pressed, spawn “Bullet”

When spawned, send “Bullet” x direction at x speed

If “Bullet” touches “Floor,” delete “Bullet”

If “Bullet” touches “Enemy,” change “Kill Count” +1

If “Bullet” touches “Player,” reset the game

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