/usr/share/games/whichwayisup/lib/particle.py is in whichwayisup 0.7.9-4.
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 | # A more simplified game object class to make special effects with less performance cost
import pygame
import os
import random
from math import *
from pygame.locals import *
from locals import *
import data
class Particle:
def __init__(self, screen, life = 30, x = None, y = None, dx = None, dy = None, random_move = 0, color = COLOR_DUST, radius = 3, gravity = False):
self.screen = screen
self.init_life = life
self.life = life
self.dead = False
self.color = color
self.init_radius = radius
self.radius = radius
self.random_move = random_move
self.x = x
self.y = y
self.dx = dx
self.dy = dy
self.radius = radius
self.gravity = gravity
if (self.x == None):
self.x = SCREEN_WIDTH / 2
if (self.y == None):
self.y = SCREEN_HEIGHT / 2
if (self.dx == None):
self.dx = 0.0
if (self.dy == None):
self.dy = 0.0
return
def update(self):
self.radius = (float(self.life) / float(self.init_life)) * self.init_radius
self.x += self.dx
self.y += self.dy
if self.gravity:
self.dy = self.dy + GRAVITY_PARTICLE
self.dx += self.random_move * random.uniform(-0.5, 0.5)
self.dy += self.random_move * random.uniform(-0.5, 0.5)
self.life -= 1
if self.life < 0:
self.dead = True
return
def render(self, drawsurface = None):
pygame.draw.circle(self.screen, self.color, (int(self.x), int(self.y)), int(self.radius))
return
def flip(self):
self.life = -1
self.dead = True
return
|