~ubuntu-branches/ubuntu/vivid/magicor/vivid

« back to all changes in this revision

Viewing changes to magicor/sprites/fires.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2010-01-02 13:18:28 UTC
  • mfrom: (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100102131828-o4p3gthk8m1dopv5
Tags: 1.1-1ubuntu1
* Merge with Debian testing. Remaining changes: 
  + debian/control: As Ubuntu's cdbs symlinks identical files, magicor needs
    a strict versioned Depends on magicor-data for the symlinked files to be
    in the same version.
* debian/magicor.install: Update to also work for Python 2.6. 
* debian/magicor.dirs: Unneeded as Makefile.debian creates them too.
* debian/Makefile.debian: Use /usr/share/python/python.mk to determine the
  correct Python library directory.
* debian/control: Update python dependency to >= 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
from magicor.sprites import *
10
10
from magicor.sprites.lights import YellowLight, YellowSpark
11
11
from magicor.sprites.blocks import Ice
 
12
from magicor import g_groups
 
13
from magicor.sprites.seekers import Seeker
12
14
 
13
15
class Fire(PhysicsSprite):
14
16
 
29
31
        self.players = players
30
32
        self.light = YellowLight(x - 32, y - 32)
31
33
        self.canFall = canFall
 
34
        self.followMe = None
32
35
        lightsGroup.add(self.light)
33
36
        self.lightsGroup = lightsGroup
34
37
 
42
45
            self.lightsGroup.add(YellowSpark(self.x - 32, self.y - 32, dx, dy))
43
46
 
44
47
    def physics(self):
45
 
        for s in self.blocksGroup.sprites():
46
 
            if isinstance(s, Ice) and s.x == self.x and s.y == self.y:
47
 
                s.kill()
48
 
                self.resources.playSound("samples/bonus")
49
 
                self.kill()
50
 
                break
51
 
        for player in self.players.sprites():
52
 
            if player.x == self.x and player.y == self.y and not player.dead:
53
 
                player.die()
54
 
        if self.canFall and not self.blockedBelow():
55
 
            self.y += 4
56
 
        self.light.x = self.x - 32 + random.randint(-4, 4)
57
 
        self.light.y = self.y - 32 + random.randint(-4, 4)
 
48
        if self.followMe is not None:
 
49
            #sliding
 
50
            if not self.followMe.alive():
 
51
                #the iceblock was killed
 
52
                self.x = self.x/32*32
 
53
                self.followMe = None
 
54
            else:
 
55
                prev_x=self.x
 
56
                self.x = self.followMe.x
 
57
                if self.followMe.falling or not self.followMe.moving:
 
58
                    self.x = self.x/32*32
 
59
                    self.followMe=None
 
60
                for s in pygame.sprite.spritecollide(self, self.blocksGroup, False): # usar sprite collision ?
 
61
                    if isinstance(s, Ice):
 
62
                        if s.falling and s.x == self.x and s.y == self.y:
 
63
                            s.kill()
 
64
                            self.resources.playSound("samples/bonus")
 
65
                            self.kill()
 
66
                            break
 
67
                        else:
 
68
                            self.x = (prev_x+self.width/2)/32*32
 
69
                            self.followMe = None
 
70
                #check world colisions
 
71
                if self.followMe is not None:
 
72
                    if self.followMe.moving>0:
 
73
                        if self.level[(self.x+self.width)/32,(self.y+self.height/2)/32]:
 
74
                            self.x = self.x/32*32
 
75
                            self.followMe = None
 
76
                    else:    
 
77
                        if self.level[self.x/32,(self.y+self.height/2)/32]:
 
78
                            self.x = (self.x/32+1)*32
 
79
                            self.followMe = None
 
80
                #enemies are not checked, they need to be flying enemies wich
 
81
                #can take damage from fire.
 
82
                self.light.x = self.x - 32 + random.randint(-4, 4)
 
83
                self.light.y = self.y - 32 + random.randint(-4, 4)
 
84
        else:
 
85
            #static or falling
 
86
            for s in self.blocksGroup.sprites():
 
87
                if isinstance(s, Ice) and s.x == self.x and s.y == self.y:
 
88
                    s.kill()
 
89
                    self.resources.playSound("samples/bonus")
 
90
                    self.kill()
 
91
                    break
 
92
            for player in self.players.sprites():
 
93
                if player.x == self.x and player.y == self.y and not player.dead:
 
94
                    player.die()
 
95
            if self.canFall and not self.blockedBelow():
 
96
                self.y += 4
 
97
                if 9>self.level.height*30-self.y>4:
 
98
                    # fire falling out of the level, lauch seekers to kill players
 
99
                    x=self.x+self.width/2.; y=self.y; da=math.radians(360./16.)
 
100
                    for s in g_groups['players']:
 
101
                        target = s
 
102
                        break
 
103
                    for i in range(0,16):
 
104
                        heading = [math.cos(i*da),math.sin(i*da)]
 
105
                        g_groups['stones'].add(Seeker(x+heading[0]*4., y+heading[1]*4., heading,3.,target))
 
106
            self.light.x = self.x - 32 + random.randint(-4, 4)
 
107
            self.light.y = self.y - 32 + random.randint(-4, 4)
 
108