I have recently started to make a game with python and pygame, I have a main script that has all my other scripts imported in and then it runs them all, but I have two main problems. The first being that when I run the first script in the main script it seems to stop after that class and not continue with the other script.
what i want the game to do:
show thee pictures as the opening credits. (working)
then once the credits are finished start up a menu, at the moment this is just one play button and a Rect which will have a collision response to detect whether the player has clicked it or not. (not working)
here are my scripts:
RUN.py (main game that runs everything together):
import pygame, random, math, sys, os, time
import startUp, Menu
from pygame.locals import *
pygame.init()
#classes setup
Begin = startUp.Begin()
Menu = Menu.HUD()
while True:
#quit button
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
#show 3 pics for the opening credits
Begin.Run()
#bring up the menu once the opening credits are done
Menu.Run()
Then Menu.py (the menu for the game)
import pygame, time, random
from pygame.locals import *
pygame.init()
class HUD(object):
def __init__(object):
object.playButtonUp = "playButtonUp.png"
object.playButtonUpHover = "playButtonUpHover.png"
object.playButtonDown = "playButtonDown.png"
object.Black = (0, 0, 0)
object.Red = (0, 255, 0)
object.screen = pygame.display.set_mode((1440, 720), 0, 32)
object.playButtonUp = pygame.image.load(object.playButtonUp).convert_alpha()
object.playButtonUpHover = pygame.image.load(object.playButtonUpHover).convert_alpha()
object.playButtonDown = pygame.image.load(object.playButtonDown).convert_alpha()
def Run(object):
#object.screen.fill(object.Black)
#creat rects
object.playButtonRect = Rect(464, 232, 256, 128)
#blit imagers
object.screen.blit(object.playButtonUp, (464, 232))
there are no error message's and it seems to work but the image is not shown on the screen.
thanks for you time and help!
Begin.Run()ends? By the way, the standard python naming convention is to use lowercase for functions and methods names, and CapWords for class names.pygamebut is it okay to callpygame.init()twice? You repeat that inMenu.py.