File: objpopbox.py

package info (click to toggle)
solarwolf 1.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,348 kB
  • ctags: 371
  • sloc: python: 2,640; makefile: 56; sh: 31
file content (42 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
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
#box class

import random
import pygame
from pygame.locals import *
import game, gfx


images = []


def load_game_resources():
    global images
    for i in range(1,3):
        img = gfx.load('popbox%d.gif'%i)
        images.append(img)

   

class PopBox:
    def __init__(self, pos):
        self.clocks = 4
        self.img = images[0]
        self.rect = self.img.get_rect()
        self.rect.center = pos
        self.dead = 0

    def erase(self, background):
        background(self.rect)
        if self.dead:
            gfx.dirty(self.rect)

    def draw(self, gfx):
        r = gfx.surface.blit(self.img, self.rect)
        gfx.dirty(r)

    def tick(self, speedadjust):
        self.clocks -= 1
        if self.clocks == 2:
            self.img = images[1]
        elif not self.clocks:
            self.dead = 1