For example I can write a text-based RPG battle engine, the walking around part of an RPG, and I'm fairly certain I know how to write a graphical menu, but haven't tried to do it just yet.
The problem is I haven't integrated this all into one and I keep on running into problems(errors in python) that I can't find solutions for... and anything I can think of to try causes more of a problem.
Also I can't find any tutorials that do any basic RPG stuff like open/closing menus, switching to a battle mode, etc... so I'm really winging it and hoping that I've figured out a way that will work.
Here's the code I'm working with so far...
#Global Variables
GameMode = "StartMenu"
#Import Modules
import pygame
from pygame.locals import *
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
#classes for our game objects
def main():
#Initialize Everything
pygame.init()
screen = pygame.display.set_mode((468, 60))
pygame.display.set_caption('Aporia')
pygame.mouse.set_visible(0)
#Create The Backgound
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
#Display The Background
screen.blit(background, (0, 0))
pygame.display.flip()
#Prepare Game Objects
clock = pygame.time.Clock()
#Main Loop
while 1:
clock.tick(60)
if GameMode == "StartMenu":
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
elif GameMode == "InGameMenu":
return
elif GameMode == "Walk":
return
elif GameMode == "Battle":
return
elif GameMode == "SpaceTravel":
return
elif GameMode == "Fighter":
return
#Draw Everything
screen.blit(background, (0, 0))
pygame.display.flip()
#Game Over
#this calls the 'main' function when this script is executed
if __name__ == '__main__': main()
This is causing this error to show up...
error: display Surface quit
I tried moving around the pygame.quit() function, but it gives me the same error or the window stops responding.
Also..
I through the global variable at the top of the code because that's where it is in a lot of languages and i think works for Python too, not sure if that's standard in game programming though
The if..elif thing I used because i can't remember the other thing that may or may not be better there...
My idea for that is that I'm going to have each of those "play modes" in different modules and since they will each have their own actions for same events they the event stuff should be within them. The for loop in the StartMenu is temporary to make the code work till i get the modules there, but I also considered that that should be outside of it cuz that will be the same for every module, but that doesn't work quite right for some reason.
The screen resolution in code is just that way due to the exmple code i'm using and i haven't changed it since i haven't figured out the error yet.
So, am I doing this right? and can someone help me with this error?
also I just noticed something I have main as a regular function (as it was in the original code I altered to work from) isn't it usually a class? Could that be the problem?