Just Another "My-First-Game" with Panda

Hello everyone!

After working through tutorial from this site, I decided to write some simple game. It is not very clear to me why tutorial is actually about some demo program, not a game.

So, I have chosen classic “Snake” and wrote it! Source code is now on github and everyone is welcome to download and play it :smiley: While it is not almost completed yet and have some cruft in the code, but it is already playable. I’ve lost hours by playing this game! :smiley:

My next step is to work through tutorial on mygamefast.com, but before that I want to remove cruft and implement some additional features:

[]Title screen and/or main menu[/]
[]Changeable gamespeed[/]
[]The list of the best scores[/]

Not the big deal, huh :smiley:


That’s good for a first game :slight_smile: Few suggestions:

[]You shouldn’t use sleep to slow down snake movement as that has an overall effect on gameplay (i.e. slow keyboard response etc). Use fixed-frame limit only for movement.[/]
[]In many snake games there is a separate mode where you don’t lose when you touch the wall. Add that as a mode.[/]
[]You should do something when the player loses instead of forcing the users to close the game when they loses.[/]

Good luck with game development process! :smiley:

Edit: Hm, you already did commit on sleep in github (I downloaded your game before that), so forget the first suggestion.

Thanks a lot! :smiley:

I’ve made some improvements and decorations but I have no clue how to make main (or not main) menu. Where I can get some examples?

I still have no clue how to make a main menu? Is there some simple example?

How you go about making a main menu may depend on just how complex your game’s flow is.

For a simple game, a main menu might simply be a screen-sized DirectFrame, several DIrectButtons for the options (“start game”, “quit”, and perhaps “continue” if the menu may be summoned while the game is running), and perhaps a DirectLabel for a title. Parent the buttons and label to a common node (let’s call it “menuNode”). (I find it helpful to parent the DirectFrame to render2d to make it easy to have it reliably cover the screen, but want buttons and the like below aspect2d so that they don’t suffer distortion, meaning that parenting the buttons, etc. to the frame presumably won’t work.)

Hide the frame and “menuNode” when the game is being played, and show them when you want the menu running.

Note that if your game has GUI elements itself, you may want to explicitly place the menu elements higher in the render order via render bins (see here); otherwise you can also simply hide the game GUI elements.

Finally, you may want to think about whether you want to pause the game while the menu is visible, and how to go about restarting your game (especially in the case in which the player may summon the menu while the game is running, and presses “start game” while doing so, presuming that you allow such a scenario).

For a more complex scenario, I find it useful to have a class that manages the game state. The actual game code then goes into a “world” or “level” class (or set of classes, if called for), an instance of which is stored in and updated by the manager class. Such a class can then hold logic for hiding or destroying the current “world”/“level” and showing and hiding the menu. It can also manage more complex menus, such as cases that involve an “options” menu that should replace the main menu until closed.

Thanks a lot! That really helped.

But what about another GUI system? I’ve read on wikipedia that panda since v1.8 including LibGocket. Why there is no manual at all and reference is very poor?

Also, for more complex cases: is there some guide or manual, or example for multi-level game programming using panda?

I’ve only used DirectGUI with Panda, and haven’t used LibRocket at all, that I recall, so I honestly don’t know much its use, I’m afraid. Hopefully someone with more experience with it will post.

As to a guide or manual for more complex GUI systems, I don’t know of one, I’m afraid–again, perhaps someone else has more information for you. You might find something useful to you in the Code Snippets sub-forum (you should be able to search within that sub-forum specifically by opening it, then using the search bar beside the upper “New Topic” button).

Otherwise, have a shot at it yourself, and simply post if you hit issues!

Anyway, thank you :smiley: