Best code structure for arcade games
Posted
by user280454
on Stack Overflow
See other posts from Stack Overflow
or by user280454
Published on 2010-04-09T20:54:41Z
Indexed on
2010/04/09
21:13 UTC
Read the original article
Hit count: 429
Hi, I've developed a few arcade games so far and have the following structure in almost all of them: I have 1 file which contains a class called kernel with the following functions:
init()
welcome_screen()
menu_screen()
help_Screen()
play_game()
end_screen()
And another file, called Game, which basically calls all these functions and controls the flow of the game. Also, I have classes for different characters, whenever required.
Is this a good code structure, or should I try having different files(classes) for different functions like welcome screen, playing, help screen, etc? As in, instead of including all the code for these things in 1 file, should I be having different classes for each one of them? The only problem I think it might cause is that I would need certain variables like score, characters, etc which are common to all of them, that's why I have all these functions in a Kernel class so that all these functions can use these variables.
© Stack Overflow or respective owner