/usr/lib/games/solarwolf/stars.py is in solarwolf 1.5-2.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 | #player ship class
import pygame
from pygame.locals import *
import game, gfx, math
from random import randint
import gameinit
class Stars:
def __init__(self):
stars = []
scrwide, scrhigh = gfx.rect.size
self.maxstars = 800
for x in range(self.maxstars):
val = randint(1, 3)
color = val*40+60, val*35+50, val*22+100
speed = -val, val
rect = Rect(randint(0, scrwide), randint(0, scrhigh), 1, 1)
stars.append([rect, speed, color])
half = self.maxstars / 2
self.stars = stars[:half], stars[half:]
self.numstars = 50
self.dead = 0
self.odd = 0
def recalc_num_stars(self, fps):
if isinstance(game.handler, gameinit.GameInit):
#don't change stars while loading resources
return
change = int((fps - 35.0) * 1.8)
change = min(change, 12) #limit how quickly they can be added
numstars = self.numstars + change
numstars = max(min(numstars, self.maxstars/2), 0)
if numstars < self.numstars:
DIRTY, BGD = gfx.dirty, self.last_background
for rect, vel, col in self.stars[self.odd][numstars:self.numstars]:
DIRTY(BGD(rect))
self.numstars = numstars
#print 'STAR:', numstars, fps, change
def erase_tick_draw(self, background, gfx):
R, B = gfx.rect.bottomright
FILL, DIRTY = gfx.surface.fill, gfx.dirty
for s in self.stars[self.odd][:self.numstars]:
DIRTY(background(s[0]))
self.odd = not self.odd
for rect, (xvel, yvel), col in self.stars[self.odd][:self.numstars]:
rect.left = (rect.left + xvel) % R
rect.top = (rect.top + yvel) % B
DIRTY(FILL(col, rect))
self.last_background = background
def eraseall(self, background, gfx): #only on fullscreen switch
R, B = gfx.rect.bottomright
FILL = gfx.surface.fill
for s in self.stars[0][:self.numstars]:
background(s[0])
for s in self.stars[1][:self.numstars]:
background(s[0])
|