🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·
🎮 Game Design

Game States — Title, Play, Game Over

Most games have multiple screens: a title screen, the actual gameplay, and a game-over screen. Use a 'state' variable and a switch statement to control which screen is showing. Events (like pressing SPACE or clicking) transition between states.

3 min 10 XP Lesson 7 of 9
Game States — Title, Play, Game Over

Most games have multiple screens: a title screen, the actual gameplay, and a game-over screen. Use a 'state' variable and a switch statement to control which screen is showing. Events (like pressing SPACE or clicking) transition between states.

Quick Quiz

1 / 2

Why use a state variable?