Exemple #1
0
 def update(self, world, events):
     if self.contents:
         self.contents.heat()
         if self.contents.contents:
             self.warn = self.contents.contents.warn
             self.progress = self.contents.contents.progress
         else:
             self.warn = False
             self.progress = None
     if not self.moving:
         dx, dy = self.dir if world.button else D.anti(self.dir)
         if self.move(dx, dy, world):
             self.locked = True
         else:
             self.locked = False
Exemple #2
0
 def update(self, world, events):
     if not self.init:
         tx, ty = self.x, self.y
         self.blockchain = []
         while True:
             tx, ty = D.offsetdxy(D.rotdir(self.dir, 1), tx, ty)
             if not world.in_world(tx, ty):
                 break
             o = world.get_o(tx, ty)
             if not o or o.name == "Fixed":
                 break
             self.blockchain.append(o)
         self.init = True
     dx, dy = self.dir if world.button else D.anti(self.dir)
     if not self.moving and self.can_move(dx, dy, world):
         if all([o.can_move(dx, dy, world) for o in self.blockchain]):
             self.ex_move(dx, dy, world)
             for o in self.blockchain:
                 o.ex_move(dx, dy, world)
Exemple #3
0
 def get_other_end(self,ed):
     return D.anti(ed)
Exemple #4
0
 def get_other_end(self,ed):
     if D.get_dir(self.d)!=ed:
         self.d=D.index(ed)
     return D.anti(ed)
Exemple #5
0
    def render_update(self,screen,events):
        for e in events:
            if e.type==pygame.QUIT:
                sys.exit()
            elif e.type==pygame.MOUSEBUTTONDOWN:
                if e.button==1:
                    mx,my=pygame.mouse.get_pos()
                    if all([32<=x<14*32 for x in [mx,my]]):
                        mx,my=[x//32-1 for x in [mx,my]]
                        obj=self.objects[mx][my]
                        if obj:
                            if obj.fixed or obj.filled:
                                continue
                            self.score-=100
                            bexp.play()
                        else:
                            build.play()
                        self.objects[mx][my]=self.nextpipe
                        self.new_pipe()
                elif e.button==3:
                    self.score-=25
                    exp.play()
                    self.new_pipe()
            elif e.type==pygame.KEYDOWN and e.key==pygame.K_ESCAPE:
                self.fail(screen)
                return None
        screen.fill((200,200,200))
        keys=pygame.key.get_pressed()
        speed=keys[pygame.K_LSHIFT]
        for x in range(13):
            for y in range(13):
                obj=self.objects[x][y]
                screen.blit(floors[self.electric][bool(obj and obj.fixed)],(x*32+32,y*32+32))
                if obj:
                    screen.blit(obj.get_cimg() if self.electric else obj.get_img(),(x*32+32,y*32+32))
        mx,my=pygame.mouse.get_pos()
        if all([32<=x<14*32 for x in [mx,my]]):
            mx,my=[x//32-1 for x in [mx,my]]
            screen.blit(self.nimg,(mx*32+32,my*32+32))
        if self.ttgo>0:
            self.ttgo-=10 if speed else 1
            Img.bcentrex(tfont,str(self.ttgo//60),screen,464)
            if self.ttgo<=0:
                self.ttflow=10 if self.electric else 120
                self.objects[self.fx][self.fy].filled=True
                alarm.play()
        elif self.ttflow>0:
            self.ttflow-=10 if speed else 1
        else:
            self.ttflow=10 if self.electric else 120
            obj=None if not self.inworld(self.fx,self.fy) else self.objects[self.fx][self.fy]
            if obj and obj.name=="Resevoir" and obj.filllevel!=7:
                pfill.play()
                obj.filllevel+=1
                self.ttflow=240 if obj.filllevel!=7 else 10 if self.electric else 120
            else:
                tx=self.fx+self.nd[0]
                ty=self.fy+self.nd[1]
                if not (0<=tx<13 and 0<=ty<13):
                    self.fail(screen)
                    return None
                np=self.objects[tx][ty]
                self.nd=D.anti(self.nd)
                if np and self.nd in np.ends:
                    np.fill(self.nd)
                    if np.name=="Drain":
                        for row in self.objects:
                            for obj in row:
                                if obj and not obj.filled and obj.ends and not obj.fixed:
                                    self.score-=50
                        self.win(screen)
                        return None
                    if np.name=="Resevoir":
                        np.filllevel=1
                        self.ttflow=240
                    if np.name=="Teleport":
                        for x,row in enumerate(self.objects):
                            for y,obj in enumerate(row):
                                if obj and obj.name=="Teleport" and obj.ttype!=np.ttype:
                                    self.fx=x
                                    self.fy=y
                                    obj.filled=True
                                    self.nd=obj.ends[0]
                    elif not self.warped and np.name=="OutPipe":
                        self.fx=tx
                        self.fy=ty
                        self.nd=np.get_other_end(self.nd)
                        self.fx,self.fy=self.get_wrap_entry(self.nd in D.hoz,self.fx,self.fy)
                        self.warped=True
                    else:
                        self.fx=tx
                        self.fy=ty
                        self.nd=np.get_other_end(self.nd)
                        self.warped=False
                    bonus=np.bonus
                    self.score+=100+np.bonus
                    if np.name=="XPipe" and np.lfill=="F":
                        self.score+=400
                        bonus=True
                    if not (speed and self.electric):
                        if bonus:
                            bfill.play()
                        else:
                            pfill.play()

                else:
                    self.fail(screen)
                    return None
        screen.blit(tt,(0,448))
        screen.blit(self.nextpipe.get_cimg() if self.electric else self.nextpipe.get_img(),(16,464))
        Img.bcentrex(tfont,"SCORE: "+str(self.score),screen,0,(0,0,0) if self.score>=0 else (255,0,0))
Exemple #6
0
 def update(self, world, events):
     if not self.moving:
         dx, dy = self.dir if world.button else D.anti(self.dir)
         self.move(dx, dy, world)