Menu

[r11]: / sprites.py  Maximize  Restore  History

Download this file

62 lines (45 with data), 2.2 kB

 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
#!usr/bin/env /python
#
# Filename : sprites.py
# Author : Juhana Kammonen 25.08.2009 - for JukiWeb Merseine
# Purpose : the file for all sprite classes needed by game MitoBlaster
import pygame
class PointerL(pygame.sprite.Sprite):
def __init__(self, initial_position):
self.image = pygame.image.load('data/pointer_1l.PNG')
self.original = True
# Make our top-left corner the passed-in location:
self.rect = self.image.get_rect()
self.rect.topleft = initial_position
self.next_update_time = 0 # update() not called yet
def update(self, current_time, initial_position):
# in case it's time to update:
if self.next_update_time < current_time:
if self.original == True: # if this is the original image
self.image = pygame.image.load('data/pointer_1l_light.PNG')
self.next_update_time = current_time + 75
self.original = False
self.original = False
else:
self.image = pygame.image.load('data/pointer_1l.PNG')
self.next_update_time = current_time + 75
self.original = True
class PointerR(pygame.sprite.Sprite):
def __init__(self, initial_position):
self.image = pygame.image.load('data/pointer_1r.PNG')
self.original = True
# Make our top-right corner the passed-in location:
self.rect = self.image.get_rect()
self.rect.topright = initial_position
self.next_update_time = 0 # update() not called yet
def update(self, current_time, initial_position):
# in case it's time to update:
if self.next_update_time < current_time:
if self.original == True: # if this is the original image
self.image = pygame.image.load('data/pointer_1r_light.PNG')
self.next_update_time = current_time + 75
self.original = False
else:
self.image = pygame.image.load('data/pointer_1r.PNG')
self.next_update_time = current_time + 75
self.original = True