Hi. I am new to game scripting, and even scripting itself (mostly object orientated programming, but i have a pretty good understanding of it). I have programmed a little bit in C++, some low level languages, and now i just learned java. To test my abillities and have some fun i decided to code a 3D snake game, with multiple levels, obstackles, and tons of other good stuff.
The 3d part(openGL) is pretty much covered, as pretty much everything else, however there is one thing that i am bad at and that is why i come to you
.
To ask my question i first have to tell you what i want this game to be like. When i start the game i want there to be a Title Screen, where i can choose whether to start playing or look at high scores or maybe do something else.
(don't mind the upside down, mirrored text
)
photo
When i decide to play, i choose the New Game button and press enter and the menu from the title screen(the set of buttons to the right on the picture above) gets replaced with another one(a submenu), but this time with the names of available levels. And there, when i choose one of the levels the game starts. But when i choose High Scores, i should get the highscores right away, no submenus.
Now this is a part of my question. The way i planned it out is that every screen (like high score screen, credits screen, and so on) has its own class where i define the render functions, and some other helper functions. But not every screen. For example the menu that you can see on the picture is rendered when i render the Title screen. But what do i do when i want to render the subMenu? This all got too complicated, and i believe there is an easier and cleaner way to do all this.
I think i can manage to just continue adding on to my code as it is, but as i do that i feel its harder and harder to do that.
So my problem is basically that i don't know how to properly structure the code. Because i know that what i just wrote may be a little bit hard to understand i will give you the code i've got so far.
The main class:http://pastebin.com/cChrMSVb
The TitleScreen class:http://pastebin.com/9wEkcv7y
The Menu class:http://pastebin.com/122Q7ks0
The Button class:http://pastebin.com/nZA9CD2Y
The Grid class:http://pastebin.com/NiLFDkEA This one is pretty much done for now
The Snake class:http://pastebin.com/anDbxf5i Same here, pretty much done for now
Right now im struggling to somehow pass the information that a button has been chosen by pressing enter to the instance of menu os that i can display the submenu. But it isn't that easy.
I think that if you take a brief look at it you should get an idea what i am talking about. I am not asking you to rewrite it, i am asking how to design any game code so that it is easier for me to write it. I know this is a big question, and im not expecting to get big answers, but small tips would be nice, or maybe some design tutorials.
The 3d part(openGL) is pretty much covered, as pretty much everything else, however there is one thing that i am bad at and that is why i come to you

To ask my question i first have to tell you what i want this game to be like. When i start the game i want there to be a Title Screen, where i can choose whether to start playing or look at high scores or maybe do something else.
(don't mind the upside down, mirrored text

photo
When i decide to play, i choose the New Game button and press enter and the menu from the title screen(the set of buttons to the right on the picture above) gets replaced with another one(a submenu), but this time with the names of available levels. And there, when i choose one of the levels the game starts. But when i choose High Scores, i should get the highscores right away, no submenus.
Now this is a part of my question. The way i planned it out is that every screen (like high score screen, credits screen, and so on) has its own class where i define the render functions, and some other helper functions. But not every screen. For example the menu that you can see on the picture is rendered when i render the Title screen. But what do i do when i want to render the subMenu? This all got too complicated, and i believe there is an easier and cleaner way to do all this.
I think i can manage to just continue adding on to my code as it is, but as i do that i feel its harder and harder to do that.
So my problem is basically that i don't know how to properly structure the code. Because i know that what i just wrote may be a little bit hard to understand i will give you the code i've got so far.
The main class:http://pastebin.com/cChrMSVb
The TitleScreen class:http://pastebin.com/9wEkcv7y
The Menu class:http://pastebin.com/122Q7ks0
The Button class:http://pastebin.com/nZA9CD2Y
The Grid class:http://pastebin.com/NiLFDkEA This one is pretty much done for now
The Snake class:http://pastebin.com/anDbxf5i Same here, pretty much done for now
Right now im struggling to somehow pass the information that a button has been chosen by pressing enter to the instance of menu os that i can display the submenu. But it isn't that easy.
I think that if you take a brief look at it you should get an idea what i am talking about. I am not asking you to rewrite it, i am asking how to design any game code so that it is easier for me to write it. I know this is a big question, and im not expecting to get big answers, but small tips would be nice, or maybe some design tutorials.