/usr/games/bambam is in bambam 0.4.dfsg-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | #!/usr/bin/python
#Copyright (C) 2007-2008 Don Brown 2010 Spike Burch <spikeb@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pygame, sys,os, random, string
from pygame.locals import *
# figure out the install base to use with image and sound loading
progInstallBase = '/usr/share/bambam'
screenheight, screenwidth = 600,800
# Load image in data/, handling setting of the transparency color key
def load_image(name, colorkey=None):
fullname = os.path.join(progInstallBase, 'data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print "Cannot load image:", name
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()
# Load sound file in data/
def load_sound(name):
class NoneSound:
def play(self): pass
if not pygame.mixer:
return NoneSound()
fullname = os.path.join(progInstallBase, 'data', name)
try:
sound = pygame.mixer.Sound(fullname)
except pygame.error, message:
print "Cannot load sound:", fullname
raise SystemExit, message
return sound
# Loads a list of sounds
def load_sounds(lst):
result = []
for name in lst:
result.append(load_sound(name))
return result
# Processes events
def input(events, quit_pos):
for event in events:
if event.type == QUIT:
sys.exit(0)
elif event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN:
#print "eepos: %s" % (quit_pos)
if event.type == KEYDOWN:
if event.key == K_q:
quit_pos = 1
elif ((event.key == K_u) and (quit_pos == 1)):
quit_pos = 2
elif event.key == K_i and quit_pos == 2:
quit_pos = 3
elif event.key == K_t and quit_pos == 3:
sys.exit(0)
else:
quit_pos = 0
# Clear the background 10% of the time
if random.randint(0, 10) == 1:
screen.blit(background, (0, 0))
pygame.display.flip()
sounds[random.randint(0, len(sounds) -1)].play()
if event.type == MOUSEBUTTONDOWN or not(is_alpha(event.key)):
print_image()
else:
print_letter(event.key)
pygame.display.flip()
return quit_pos
# Prints an image at a random location
def print_image():
global screenheight, screenwidth
img = images[random.randint(0, len(images) -1)]
w = random.randint(0, screenwidth-img.get_width())
h = random.randint(0, screenheight-img.get_height())
screen.blit(img, (w, h))
# Is the key that was pressed alphanumeric
def is_alpha(key):
return key < 255 and (chr(key) in string.letters or chr(key) in string.digits)
# Prints a letter at a random location
def print_letter(key):
global screenheight, screenwidth
font = pygame.font.Font(None, 256)
text = font.render(chr(key), 1, colors[random.randint(0, len(colors) -1)])
textpos = text.get_rect()
center = (textpos.width / 2, textpos.height / 2)
w = random.randint(0+center[0], screenwidth-center[0])
h = random.randint(0+center[1], screenheight-center[1])
textpos.centerx = w
textpos.centery = h
screen.blit(text, textpos)
# Main application
#
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
pygame.init()
window = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
pygame.display.set_caption('Bam Bam')
screen = pygame.display.get_surface()
screenwidth = screen.get_width()
screenheight = screen.get_height()
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
screen.blit(background, (0, 0))
pygame.display.flip()
sounds = load_sounds(('boom.wav', 'house_lo.wav', 'punch.wav', 'secosmic_lo.wav', 'whiff.wav', 'areyousure.wav', 'bleep.wav', 'bubble.wav', 'click.wav', 'eraser1.wav', 'eraser2.wav', 'flip.wav', 'giggle.wav', 'grow.wav', 'harp.wav', 'italic_off.wav', 'italic_on.wav', 'keyclick.wav', 'line_end.wav', 'line_start.wav', 'mirror.wav', 'paint1.wav', 'paint2.wav', 'paint3.wav', 'paint4.wav', 'prompt.wav', 'return.wav', 'save.wav', 'scroll.wav', 'shrink.wav', 'stamp.wav', 'thick.wav', 'thin.wav', 'tuxok.wav', 'typewriterbell.wav', 'youcannot.wav'))
colors = ((0,0,255), (255,0,0), (0,255,0), (255, 0, 255),(255, 255, 0))
images = (load_image("chimp.bmp", -1)[0],load_image('alien1.gif')[0],load_image('dog.gif')[0],load_image('frog.gif')[0],load_image('tux.gif')[0],load_image('bear.gif')[0],load_image('iguana.gif')[0],load_image('kangaroo.gif')[0])
quit_pos = 0
clock = pygame.time.Clock()
while True:
clock.tick(60)
quit_pos = input(pygame.event.get(), quit_pos)
|