Exemple #1
0
# Font Drawing test object
fontObj_diehld = pygame.font.Font('./fonts/DIEHLD__.ttf', 32)
textSurfaceObj_2 = fontObj_diehld.render('New Font!', True, colorObj.RED, colorObj.BLACK)
textRectObj_2 = textSurfaceObj_2.get_rect()
textRectObj_2.center = (150, 100)

# button test
import myButton
button = myButton.cMyButton("OK", (350,320),(64,64),0)

# Setup game objects
   
# Make a list of game objects
cats = []
cats.append(cMyCat((200, 200), [1, 0], 0, './img/cat_01.png'))
cats.append(cMyCat((500, 200), [0, 1], 1, random.choice(cat_types)))
cats.append(cMyCat((500, 400), [-1, 0], 2, random.choice(cat_types)))
cats.append(cMyCat((200, 400), [0, -1], 3, random.choice(cat_types)))
selected_cat = 0 

# Make a list of Targets
targetlist = [pygame.Rect(100, 100, 10, 10),
              pygame.Rect(700, 100, 10, 10),
              pygame.Rect(700, 700, 10, 10),
              pygame.Rect(100, 700, 10, 10)]

# Load cat images - all the same for now.
#for cat in cats:
#        if cat.id != 1:
#                if cat.load_img('./img/cat_01.png'):
Exemple #2
0
soundObj = pygame.mixer.Sound('./sfx/beeps.wav')

# Loading and playing background music:
pygame.mixer.music.load('./music/07 - F6 Gs (Lost Area).mp3')
                        
#Fill window with background color
screen.fill(BGCOLOR)

#start playing music
pygame.mixer.music.play(-1, 0.0)

#setup game objects
   
#make a list of cats
cats = []
cats.append(cMyCat(init_pos=(100, 100), init_speed=[1, 0], init_id = 0))
cats.append(cMyCat(init_pos=(200, 100), init_speed=[0, 1], init_id = 1))
cats.append(cMyCat(init_pos=(200, 200), init_speed=[-1, 0], init_id = 2))
cats.append(cMyCat(init_pos=(100, 200), init_speed=[0, -1], init_id = 3))
selected_cat = 0 

targetlist = [pygame.Rect(100, 100, 10, 10),
              pygame.Rect(200, 100, 10, 10),
              pygame.Rect(200, 200, 10, 10),
              pygame.Rect(100, 200, 10, 10)]

for cat in cats:
        if cat.load_img('./img/cat.png'):
                pass
        else:
                tempMsg=cat.getErrors()