Пример #1
0
 def  read_signal(self, signal):
     if not self.busy:
         if not self.active:
             if signal.type == gsignal.MOVE:
                 self.mouse_over= True
                 
             elif signal.type == gsignal.CLICK:
                 self.busy= True
                 signal= gsignal.build( {
                     "type": gsignal.ACTION ,
                     "target": self } )
                 self.listener.read_signal(signal)
                 
         else:
             if signal.type == gsignal.MOVE:
                 if signal.position.y < self.banner.HEIGTH:
                     self.mouse_over= True
                     
             if signal.type == gsignal.CLICK or signal.type == gsignal.LCLICK:
                 if signal.position.x >= self.banner.STRAP_WIDTH and signal.position.y >= self.banner.HEIGTH:
                     signal= gsignal.edit(signal, ["position", "x"], signal.position.x - self.banner.STRAP_WIDTH)
                     self.body.read_signal(signal)
                 else:
                     self.busy= True
                     signal= gsignal.build( {
                         "type": gsignal.ACTION ,
                         "target": self } )
                     self.listener.read_signal(signal)
Пример #2
0
    def gread(self, signal):
        if signal.type == gsignal.CLICK:
            self.trackablelist.iterator+= 1
            self.trackablelist.iterator%= len(self.trackablelist.content)
            self.retarget()

            signal= gsignal.build( {
                "type": self.signal ,
                "content": self.target } )
            self.gsend(self.listener, signal)
            self.draw()
            
        elif signal.type == gsignal.LCLICK:
            self.trackablelist.iterator-= 1
            self.trackablelist.iterator%= len(self.trackablelist.content)
            self.retarget()

            signal= gsignal.build( {
                "type": self.signal ,
                "content": self.target } )
            self.gsend(self.listener, signal)
            self.draw()

        elif signal.type == gsignal.UPDATE:
            self.update()
Пример #3
0
    def gread(self, signal):
        if not self.busy:
            if not self.active:
                if signal.type == gsignal.MOVE:
                    self.mouse_over = True

                elif signal.type == gsignal.CLICK:
                    self.busy = True
                    signal = gsignal.build({
                        "type": gsignal.ACTION,
                        "target": self
                    })
                    self.gsend(self.display, signal)

            else:
                if signal.type == gsignal.MOVE:
                    if signal.position.y < self.banner.HEIGTH:
                        self.mouse_over = True

                if signal.type == gsignal.CLICK or signal.type == gsignal.LCLICK:
                    if signal.position.x >= self.banner.STRAP_WIDTH and signal.position.y >= self.banner.HEIGTH:
                        signal = gsignal.edit(
                            signal, ["position", "x"],
                            signal.position.x - self.banner.STRAP_WIDTH)
                        self.gsend(self.body, signal)
                    else:
                        self.busy = True
                        signal = gsignal.build({
                            "type": gsignal.ACTION,
                            "target": self
                        })
                        self.gsend(self.display, signal)
Пример #4
0
 def update():
     
     if Mouse.listener != None:
         x, y= pygame.mouse.get_pos()
         
         signal= gsignal.build( {
             "type": gsignal.MOVE ,
             "position": {"x": x, "y": y} } )
             
         
         for event in SysComm.event_stack:
             if  event.type == pygame.MOUSEBUTTONDOWN:
                 if event.button == 1:
                     signal= gsignal.build( {
                         "type": gsignal.CLICK ,
                         "position":  {"x": x, "y": y} } )
                         
                 elif event.button == 3:
                     signal= gsignal.build( {
                         "type": gsignal.LCLICK ,
                         "position":  {"x": x, "y": y} } )
                         
                 elif event.button == 4:
                     signal= gsignal.build( {
                         "type": gsignal.SCROLLDOWN ,
                         "position":  {"x": x, "y": y} } )
                         
                 elif event.button == 5:
                     signal= gsignal.build( {
                         "type": gsignal.SCROLLUP ,
                         "position": {"x": x, "y": y} } )
                 break;
         
         
         Mouse.listener.read_signal(signal)
 def read_signal(signal):
     if signal.type == gsignal.WATCH1:
         CelestialCluster.watchlist[1]= signal.target
         if CelestialCluster.listener:
             signal= gsignal.build( {
                 "type": gsignal.RESET ,
                 "content": CelestialCluster.watchlist[0] } )
             CelestialCluster.listener.read_signal(signal)
     elif signal.type == gsignal.WATCH2:
         CelestialCluster.watchlist[2]= signal.target
         if CelestialCluster.listener:
             signal= gsignal.build( {
                 "type": gsignal.RESET ,
                 "content": CelestialCluster.watchlist[0] } )
             CelestialCluster.listener.read_signal(signal)
     elif signal.type == gsignal.WATCH0:
         CelestialCluster.watchlist[0]= signal.target
         if CelestialCluster.listener:
             signal= gsignal.build( {
                 "type": gsignal.RESET ,
                 "content": CelestialCluster.watchlist[0] } )
             CelestialCluster.listener.read_signal(signal)
         
     elif signal.type == gsignal.COLLISION:
         pass
         #TODO tratar colisão
         
     elif signal.type == gsignal.DELETE:
         CelestialCluster.remove(signal.content)
         
     else:
         print("possible error at celestialcluster")
Пример #6
0
    def update():

        if Mouse.listener != None:
            x, y = pygame.mouse.get_pos()

            signal = gsignal.build({
                "type": gsignal.MOVE,
                "position": {
                    "x": x,
                    "y": y
                }
            })

            for event in SysComm.event_stack:
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if event.button == 1:
                        signal = gsignal.build({
                            "type": gsignal.CLICK,
                            "position": {
                                "x": x,
                                "y": y
                            }
                        })

                    elif event.button == 3:
                        signal = gsignal.build({
                            "type": gsignal.LCLICK,
                            "position": {
                                "x": x,
                                "y": y
                            }
                        })

                    elif event.button == 4:
                        signal = gsignal.build({
                            "type": gsignal.SCROLLDOWN,
                            "position": {
                                "x": x,
                                "y": y
                            }
                        })

                    elif event.button == 5:
                        signal = gsignal.build({
                            "type": gsignal.SCROLLUP,
                            "position": {
                                "x": x,
                                "y": y
                            }
                        })
                    break

            Mouse.listener.read_signal(signal)
    def update_speed(self): 
        #print( type(self.speed.x) )

        for celestial_body in self.celestial_neighbor:

            distance= Cardinal(
                celestial_body.position.x - self.position.x ,
                celestial_body.position.y - self.position.y ,
                celestial_body.position.z - self.position.z )
                
            relative_speed= Cardinal(
                celestial_body.speed.x - self.speed.x ,
                celestial_body.speed.y - self.speed.y ,
                celestial_body.speed.z - self.speed.z )
                
            #if distance.vectorize() > self.radius + celestial_body.radius:
            if distance.vectorize() > ( self.radius + celestial_body.radius ) + relative_speed.vectorize()*gtime.RESOLUTION:
                #Não tou muito confiante nessa checagem de colisão, mas ok
                relative_constant= GRAVCONST*celestial_body.mass/(distance.vectorize()**2)
                
                self.speed.x+= relative_constant*distance.x*gtime.RESOLUTION/distance.vectorize()
                self.speed.y+= relative_constant*distance.y*gtime.RESOLUTION/distance.vectorize()
                self.speed.z+= relative_constant*distance.z*gtime.RESOLUTION/distance.vectorize()
            else:
                #aconteceu uma colisão, tratar aqui
                #print("DEBUG2: Collision")
                CelestialCluster.read_signal( gsignal.build( {
                    "type": gsignal.COLLISION ,
                    "celestial_bodies": [self, celestial_body] } ) )
 def set_listener(listener):
     CelestialCluster.listener= listener
     if not None in CelestialCluster.watchlist:
         signal= gsignal.build( {
             "type": gsignal.RESET ,
             "content": CelestialCluster.watchlist[0] } )
         CelestialCluster.listener.read_signal(signal)
Пример #9
0
    def update():
        if (AudioTrack.mode == 2 and AudioTrack.tick >= 2):
            tmp = AudioTrack.recbuffer[(AudioTrack.tick - 2) *
                                       728:(AudioTrack.tick - 1) * 728]

            if (AudioTrack.tick % 2 == 0):
                content = [item for sublist in tmp for item in sublist]

                tmp = np.fft.rfft(content)
                fourier = []
                for i in tmp:
                    fourier.append(abs(float(i.real)))

                fourier = AudioTrack.normalize(fourier)
                content = AudioTrack.normalize(content)

                AudioTrack.detectTone(fourier)

                if (AudioTrack.displaymode.iterator == 1):
                    content = fourier

                signal = gsignal.build({
                    "type": gsignal.ACTION,
                    "content": content
                })
                AudioTrack.gsend(AudioTrack.listeners[-1], signal)

        AudioTrack.tick += 1
        if (AudioTrack.tick == 660):
            AudioTrack.tick -= 1
            AudioTrack.mode = 0
Пример #10
0
 def read_signal(self, signal):
     if signal.type == gsignal.CLICK:
         signal= gsignal.build( {
             "type": self.signaltype ,
             "content": self.content } )
         self.listener.read_signal(signal)
         
     elif signal.type == gsignal.ACTION:
         self.content= signal.target
Пример #11
0
 def nogoodnameyet(self):
     target= self.scrollist[self.tick]
     if self.return_index:
         target= self.tick
         
     signal= gsignal.build( {
         "type": self.signaltype ,
         "target": self.scrollist[self.tick] } )
     self.send(signal)
     self.draw()
Пример #12
0
    def read_signal(self, signal):
        if signal.type == gsignal.CLICK:
            signal = gsignal.build({
                "type": self.signaltype,
                "content": self.content
            })
            self.listener.read_signal(signal)

        elif signal.type == gsignal.ACTION:
            self.content = signal.target
Пример #13
0
    def nogoodnameyet(self):
        target = self.scrollist[self.tick]
        if self.return_index:
            target = self.tick

        signal = gsignal.build({
            "type": self.signaltype,
            "target": self.scrollist[self.tick]
        })
        self.send(signal)
        self.draw()
 def watch():
     VECTOR= CelestialCluster.watchlist[0]
     CBODY1= CelestialCluster.watchlist[1]
     CBODY2= CelestialCluster.watchlist[2]
     
     if VECTOR == "Distance":
         value= CelestialCluster.distance(CBODY1, CBODY2)
         signal= gsignal.build( {
             "type": gsignal.ACTION ,
             "content": value } )
     
     CelestialCluster.listener.read_signal(signal)
Пример #15
0
    def update(self):

        if self.active:
            if not self.busy:
                if self.mouse_over and self.tick != self.MAX_TICK // 2:
                    self.tick += 1
                elif not self.mouse_over and self.tick != 0:
                    self.tick -= 1

            else:
                if self.tick != self.MAX_TICK:
                    self.tick += 1
                else:
                    self.tick = 0
                    self.active = False
                    self.busy = False

        else:
            if not self.busy:
                if self.mouse_over and self.tick != self.MAX_TICK:
                    self.tick += 1
                elif not self.mouse_over and self.tick != 0:
                    self.tick -= 1

            else:
                if self.tick != self.MAX_TICK:
                    self.tick += 1
                if self.tick2 != self.MAX_TICK2:
                    self.tick2 += 1
                if self.tick == self.MAX_TICK and self.tick2 == self.MAX_TICK2:
                    self.busy = False
                    self.active = True
                    self.tick = 0
                    self.tick2 = 0

                    signal = gsignal.build({
                        "type": gsignal.REINDEX,
                        "target": self
                    })
                    self.gsend(self.display, signal)

        self.mouse_over = False
        self.draw()
        self.body.update()
Пример #16
0
 def update(self):
     
     if self.active:
         if not self.busy:
             if self.mouse_over and self.tick != self.MAX_TICK//2:
                 self.tick+=1
             elif not self.mouse_over and self.tick!= 0:
                 self.tick-=1
         
         else:
             if self.tick!= self.MAX_TICK:
                 self.tick+= 1
             else:
                 self.tick= 0
                 self.active= False
                 self.busy= False
     
     else:
         if not self.busy:
             if self.mouse_over and self.tick != self.MAX_TICK:
                 self.tick+=1
             elif not self.mouse_over and self.tick != 0:
                 self.tick-=1
                 
         else:
             if self.tick != self.MAX_TICK:
                 self.tick+=1
             if self.tick2 != self.MAX_TICK2:
                 self.tick2+= 1
             if self.tick == self.MAX_TICK and self.tick2 == self.MAX_TICK2:
                 self.busy= False
                 self.active= True
                 self.tick= 0
                 self.tick2= 0
                 
                 signal= gsignal.build( {
                     "type": gsignal.REINDEX ,
                     "target": self } )
                 self.listener.read_signal(signal)
     
     self.mouse_over= False
     self.draw()
     self.body.update()
Пример #17
0
 def gread(self, signal):
     if signal.type == gsignal.CLICK:
         signal= gsignal.build( {
             "type": self.signaltype ,
             "content": None } )
         self.gsend(self.listener, signal)