Exemplo n.º 1
0
 def render(self,p,screen):
     screenrect=screen.get_rect()
     sh,sw=screenrect.h,screenrect.w
     awscale=scales[self.wscale]
     aiscale=scales[self.invscale]
     riscale=self.invscale+1
     m=(sw/float(awscale)+1)/2.0
     rm=int(ceil(m))
     wconvmult=awscale/64.0
     if not (p.shop or (p.dead and not p.dt)):
         asx=p.x*awscale+ir(p.xoff)*wconvmult-(m-1)*awscale
         asy=p.y*awscale+ir(p.yoff)*wconvmult-(m-1)*awscale-aiscale
         r=(p.rumbling-1)//10+1
         rx=randint(-r,r)
         ry=randint(-r,r)
         sx=p.x
         sy=p.y
         for y in range(sy-rm-1,sy+rm+1):
             for x in range(sx-rm-1,sx+rm+1):
                 screen.blit(Tiles.tiles[self.get_t(x,y)].get_img()[self.wscale],(x*awscale-asx+rx,y*awscale-asy+ry))
         for y in range(sy-rm-1,sy+rm+1):
             for x in range(sx-rm-1,sx+rm+1):
                 objs=self.get_os(x,y)
                 for o in objs:
                     if not o.is_hidden(self,p):
                         screen.blit(o.get_img(self)[self.wscale],(x*awscale+ir(o.xoff)*wconvmult-asx+rx,y*awscale+ir(o.yoff)*wconvmult-asy-o.o3d*(self.wscale+1)+ry))
         pygame.draw.rect(screen,(200,200,200),pygame.Rect(0,0,sw,aiscale))
         for n,i in enumerate(p.iinv.inv if p.iinv else p.inv):
             screen.blit(i.get_img(p,self)[self.invscale],(n*aiscale,0))
             if i.stack>1:
                 screen.blit(numerals[i.stack-2][self.invscale],(n*aiscale+(11 if i.stack<10 else 9)*(self.invscale+1),36))
             if n==p.isel:
                 pygame.draw.rect(screen,p.col,pygame.Rect(n*aiscale,15*riscale,aiscale,riscale))
         if p.statuseffects:
             maxt=max([se[1] for se in p.statuseffects])
             maxse=[se for se in p.statuseffects if se[1]==maxt][0]
             pygame.draw.rect(screen,p.col,pygame.Rect(0,sh-9,maxt*sw//Players.etimes[maxse[0]],12))
     elif p.shop:
         screen.fill((150,150,150))
         pygame.draw.rect(screen,(200,200,200),pygame.Rect(0,0,sw,64))
         Img.bcentrex(bcfont,p.shop.title,screen,-16)
         for n,i in enumerate(p.shop.items):
             Img.cxblit(i[0].img[self.invscale],screen,n*aiscale+aiscale,-8*riscale)
             Img.bcentrex(cashfont,str(i[1]),screen,n*aiscale+aiscale,(255,255,0),8*riscale)
         screen.blit(p.simg[self.invscale],(0,p.ssel*aiscale+aiscale))
     else:
         p.dead.render(screen)
     Img.bcentrex(cashfont,str(p.cash),screen,sh-48,(255,255,0))
     pygame.draw.rect(screen,p.col,pygame.Rect(0,0,sw,sh),2)
Exemplo n.º 2
0
     if event.type == pygame.QUIT:
         sys.exit()
     elif event.type == pygame.MOUSEBUTTONDOWN and len(rsps)>1:
         breaking = True
 for n,c in enumerate(activecons):
     if c.get_buttons(gevents)[0]:
         if acps[n] not in rsps:
             rsps.append(acps[n])
             rsc.append(c)
 for c in controllers[:]:
     if c.get_buttons(gevents)[0]:
         activecons.append(c)
         acps.append(0)
         controllers.remove(c)
 screen.fill((0, 0, 0))
 Img.bcentrex(tfont,"PLAYER SELECT",screen,0,(255,255,255))
 n=-1
 for n,c in enumerate(activecons):
     if c not in rsc:
         cdir=c.get_dir_pressed(gevents)
         if (1,0) == cdir:
             acps[n]=(acps[n]+1)%len(pimgs)
         elif (-1,0) == cdir:
             acps[n]=(acps[n]-1)%len(pimgs)
         screen.blit(pimgs[acps[n]],(304,n*32+94))
         if acps[n] in rsps:
             screen.blit(crossimg,(336,n*32+94))
     else:
         screen.blit(pimgs[acps[n]],(304,n*32+94))
         screen.blit(tickimg,(336,n*32+94))
 Img.bcentrex(sfont,"Press <bomb> to join",screen,n*32+128,(255,255,255))
Exemplo n.º 3
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))
Exemplo n.º 4
0
     if event.type == pygame.QUIT:
         sys.exit()
     elif event.type == pygame.MOUSEBUTTONDOWN and len(rsps) > 1:
         breaking = True
 for n, c in enumerate(activecons):
     if c.get_buttons(gevents)[0]:
         if acps[n] not in rsps:
             rsps.append(acps[n])
             rsc.append(c)
 for c in controllers[:]:
     if c.get_buttons(gevents)[0]:
         activecons.append(c)
         acps.append(0)
         controllers.remove(c)
 screen.fill((0, 0, 0))
 Img.bcentrex(tfont, "PLAYER SELECT", screen, 0, (255, 255, 255))
 n = -1
 for n, c in enumerate(activecons):
     if c not in rsc:
         cdir = c.get_dir_pressed(gevents)
         if (1, 0) == cdir:
             acps[n] = (acps[n] + 1) % len(pimgs)
         elif (-1, 0) == cdir:
             acps[n] = (acps[n] - 1) % len(pimgs)
         screen.blit(pimgs[acps[n]], (304, n * 32 + 94))
         if acps[n] in rsps:
             screen.blit(crossimg, (336, n * 32 + 94))
     else:
         screen.blit(pimgs[acps[n]], (304, n * 32 + 94))
         screen.blit(tickimg, (336, n * 32 + 94))
 Img.bcentrex(sfont, "Press <bomb> to join", screen, n * 32 + 128,