Python interaction with Panda

This is a technic question, I paused the game dev for myself, because i think i must learn Python at least 70% to then introduce Panda.

Now, i have a basic knowledge of Python, e.x : while, if, elif, else, print, raw_input, int, float, strings, for, def…etc. etc. from ¨Introduccion a la programacion con Python¨ a spanish book.

In game development, what are the most internal commands do you use to program (not API)?.

This is the way that i imagine programing a game :


def startgame():
     import gameinit                # External module goes directly to game.


def sectionmenu():
     print "Select your model"
     print "1 - Blue Ship"
     print "2 - Red Ship"
     
     option = int(raw_input("Select: "))

     if option == 1:
          model = loader.loadModel("models/blue_ship")
          print "Select the size of your ship"
          print "H - Huge"
          print "S - Small"
          size = raw_input("Size: ")
          if size == "H":
               model.setScale(5,5,5)
               model.reparentTo(render)
               startgame()


          elif size == "S":
               model.setScale(1,1,1)
               startgame()
          
         
     elif option == 2:
          model = loader.loadModel("models/red_ship")
          print "Select the size of your ship"
          print "H - Huge"
          print "S - Small"
          size = raw_input("Size: ")
          if size == "H":
               model.setScale(5,5,5)
               model.reparentTo(render)
               startgame()


          elif size == "S":
               model.setScale(1,1,1)
               model.reparentTo(render)
               startgame()
          
         

sectionmenu()

That is what i has been studying, i do programs like this way (python programs without gui), but … is the same way for games?, i know that raw_input() does not work with engines… just tried and it does not ask nothing…

Well, i am also a very newbie with panda and python (its been only 3-4 days now)

But i can tell you that, you better consider sprite buttons(if there is any possibility, i dont know yet myself either) or engines gui buttons for the menu options and all interaction with the end user.

yes, of course, you’re right, imagine to use a menu like that, totally anti-esthetic haha. I just want to know if the way to call your objects is like a normal python program… the structure… the algorithm.

If game dev is like this, genial !!
but if there is another way to program other syntax or structure, better not continuing to learning python algorithm… (since my main objective is to program games and no programs).

PS. Are you following the manual’s tutorials?

In my opinion, programming a complex game should be done using an object oriented approach.
You have to create classes that you can call easily and that do with few call all what you need.
For menus, i created in my project a StartMenu class and a PauseMenu class;
when I create an object of those, I get with one call the cursor, the background and all of the GUI elements; inside of those same classes I have specific methods to create the elements for a options menu, a save/load engine, and other things like that…
The good point is that it allows for abstraction and modularity in the code.

If you’re still learning how to program, first get a confident approach to structured programming, through simple tutorials; after you get the basis, try to learn the principles of Object Oriented Programming
Object Oriented Programming , as you will surely find in the intermediate-to-advanced Python tutorials.

But to do things nicely, you have to come up with a consistent organization of classes, or better said “roles” for your classes: that way, it will be clear what you have to implement and where, and your code will be clean and re-usable.

Grazie Ausir.

The wiki has many information about OOP, OOPS, oops yes, i-m going to check it out specially the CLASS section…