/usr/lib/games/solarwolf/objbox.py is in solarwolf 1.5-2.
This file is owned by root:root, with mode 0o644.
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 | #box class
import random
import pygame
from pygame.locals import *
import game, gfx, snd
boximages = []
yboximages = []
rboximages = []
wboximages = []
popimages = []
spikeimages = []
wspikeimages = []
def load_game_resources():
global boximages, yboximages, rboximages, wboximages
global popimages, spikeimages, wspikeimages
imgs = gfx.load_raw('boxes.png')
origpal = imgs.get_palette()
boximages = gfx.animstrip(imgs)
pal = [(g,g,b) for (r,g,b) in origpal]
imgs.set_palette(pal)
yboximages = gfx.animstrip(imgs)
pal = [(g,b,b) for (r,g,b) in origpal]
imgs.set_palette(pal)
rboximages = gfx.animstrip(imgs)
pal = [min(g+60,255) for (r,g,b) in origpal]
imgs.set_palette(zip(pal,pal,pal))
wboximages = gfx.animstrip(imgs)
popimages = gfx.animstrip(gfx.load('popbox.png'))
spikes = gfx.load_raw('spikeball.png')
origpal = spikes.get_palette()
spikeimages = gfx.animstrip(spikes)
pal = [(min(r+100,255),min(g+100,255),min(b+100,255)) for r,g,b in origpal]
spikes.set_palette(pal)
wspikeimages = gfx.animstrip(spikes)
snd.preload('boxhit', 'yboxhit')
class Box:
def __init__(self, pos, touches):
self.rotate = random.random() * 90.0
self.rotspeed = random.random() * 2.0 + 2.0
if random.randint(0, 1):
self.rotspeed = -self.rotspeed
self.rect = boximages[0].get_rect().move(pos)
self.touches = touches
self.touching = 0
self.firsttouch = 2.0
self.dead = 0
self.popped = 0
self.imglists = wboximages, boximages, yboximages, rboximages
self.numframes = len(self.imglists[0])
def erase(self, background):
r = background(self.rect)
if self.dead:
gfx.dirty(r)
def draw(self, gfx):
frame = int(self.rotate)%self.numframes
if self.popped:
img = popimages[int(self.popped)]
elif self.firsttouch > 0.0:
img = self.imglists[0][frame]
else:
img = self.imglists[self.touches][frame]
r = gfx.surface.blit(img, self.rect)
gfx.dirty(r)
def tick(self, speedadjust):
self.rotate += self.rotspeed * speedadjust * .2
if self.firsttouch > 0.0:
self.firsttouch -= speedadjust
elif self.popped:
if self.popped >= 1.9:
self.dead = 1
else:
self.popped = min(self.popped + speedadjust * .35, 1.9)
elif not self.touches:
self.popped = .01
def playercollide(self, rect):
if self.touching:
self.touching = self.rect.colliderect(rect)
return 0
elif self.touches and self.rect.colliderect(rect):
self.touches -= 1
if self.touches:
self.firsttouch = 4.0
self.touching = 1
snd.play('yboxhit', 1.0, self.rect.centerx)
return 2
self.firsttouch = 2.0
snd.play('boxhit', 1.0, self.rect.centerx)
return 1
return 0
def pop(self):
self.touches = 0
self.firsttouch = 2.0
class Spike:
blockrocks = 0
def __init__(self, pos):
self.rotate = random.random() * 90.0
self.rotspeed = random.random() * 1.0 + 1.0
if random.randint(0, 1):
self.rotspeed = -self.rotspeed
self.images = spikeimages, wspikeimages
self.numframes = len(self.images[0])
self.rect = self.images[0][0].get_rect().move(pos)
self.dead = 0
self.popped = 0
self.armed = 0
self.armtime = 0.0
def erase(self, background):
r = background(self.rect)
if self.dead:
gfx.dirty(r)
def draw(self, gfx):
frame = int(self.rotate)%self.numframes
img = self.images[not self.armed][frame]
r = gfx.surface.blit(img, self.rect)
gfx.dirty(r)
def tick(self, speedadjust):
self.rotate += self.rotspeed * speedadjust * .2
self.armtime += speedadjust
self.armed = self.armtime > 14.0
|