Ejemplo n.º 1
0
def select_object(kind):
    global classType, PreyObj, special_on
    allSims = all_sim(Black_Hole.__bases__[0])
    for name in allSims:
        if name.__name__ == kind:
            classType = name
        if name.__name__ == "Prey":
            PreyObj = name
    if kind == "Remove":
        classType = kind
    elif kind == "Special":
        if special_on == False:
            special_on = True
            for s in sim:
                if isinstance(s, Hunter):
                    x, y = s.get_location()
                    w, h = s.get_dimension()
                    specialOb = Special(x, y)
                    specialOb.set_dimension(w, h)
                    sim.add(specialOb)
                    controller.the_canvas.delete(s)
                    sim.remove(s)

        else:
            special_on = False
            for s in sim:
                if isinstance(s, Special):
                    x, y = s.get_location()
                    w, h = s.get_dimension()
                    hunterOb = Hunter(x, y)
                    hunterOb.set_dimension(w, h)
                    sim.add(hunterOb)
                    controller.the_canvas.delete(s)
                    sim.remove(s)
Ejemplo n.º 2
0
 def get_specials(self, day):
     cursor = self.mongo.db.Bars.find({})
     specials = []
     for bar in cursor:
         for spec in bar['specials'][day]:
             to_add = Special(spec['special_id'],
                              spec['special_name'],
                              spec['description'],
                              spec['bar_id'],
                              object=spec['object'])
             specials.append(to_add.serialize())
     return specials
def mouse_click(x,y):
    global big_bang
    if selected != 'Special' and selected != 'Remove':
        add(eval(selected+'(' + str(x) + ',' + str(y) + ')'))
    elif selected == 'Special':
        if big_bang == None:
            print('Big Bang Started')
            big_bang = Special(x,y)
    else:
        removeset = find(lambda item:True if item.contains((x,y)) else False)
        for item in removeset:
            remove(item)
        if big_bang != None:
            if big_bang.contains((x,y)):
                print('Big Bang Stopped')
                big_bang = None
Ejemplo n.º 4
0
def create_specials(input_specials):
    specials = []
    for special in input_specials:
        specials.append(
            Special(special['special_id'], special['special_name'],
                    special['description'], special['bar_id'],
                    special['object']))
    return specials
Ejemplo n.º 5
0
 def create_special(self, bar_id, special, day):
     bar = self.mongo.db.Bars.find_one({'bar_id': bar_id})
     specials = bar['specials'][day]
     total = 0
     for l in bar['specials']:
         for s in l:
             total = max(total, s['special_id'])
     special['special_id'] = total + 1
     to_add = Special(special['special_id'],
                      special['special_name'],
                      special['description'],
                      special['bar_id'],
                      object=special['object'])
     specials.append(to_add.serialize())
     update = self.mongo.db.Bars.update_one(
         {'bar_id': bar_id}, {'$set': {
             'specials': bar['specials']
         }})
Ejemplo n.º 6
0
    def load_specials(self):
        """Load the special data for the level."""
        f, o = self.f, self.offset

        # Special count
        f.seek(o)
        specialCount = ord(f.read(1))
        o += 1

        print "There are", specialCount, "specials."

        self.specials = list()
        for i in range(specialCount):
            f.seek(o)
            s = Special(f, o)
            self.specials.append(s)
            o = s.get_offset()

        self.offset = o
Ejemplo n.º 7
0
 def launch_special(self):
     """
     Launches special shot from current position
     of the space ship.
     :return:
     """
     #  Get launch parameters from current
     #  position and angle of the ship
     position = self.__ship.get_position()
     for i in range(5):
         special = Special(position, [
             SPECIAL_FACTOR * math.sin((i * 360 / 5) / 360 * 2 * math.pi),
             SPECIAL_FACTOR * math.cos((i * 360 / 5) / 360 * 2 * math.pi)],
                           i * 360 / 5)
         self.__specials.append(special)
         self.__screen.register_torpedo(special)
Ejemplo n.º 8
0
def mouse_click(x, y):
    if button == 'Ball':
        simulation.add(Ball(x, y))
    elif button == 'Floater':
        simulation.add(Floater(x, y))
    elif button == 'Black_Hole':
        simulation.add(Black_Hole(x, y))
    elif button == 'Pulsator':
        simulation.add(Pulsator(x, y))
    elif button == 'Hunter':
        simulation.add(Hunter(x, y))
    elif button == 'Special':
        simulation.add(Special(x, y))
    elif button == 'Remove':
        for i in simulation.copy():
            if i.distance((x, y)) < i.radius:
                remove(i)
Ejemplo n.º 9
0
def mouse_click(x,y):
    global selection, simultons
    if selection == 'Remove': #Need to finish
        for sim in simultons.copy():
            if sim.contains( (x,y) ):
                remove(sim)
    elif selection == 'Ball':
        add( Ball(x,y,5,5,0,5) )
    elif selection == 'Floater':
        add( Floater(x,y,5,5,0,5) )
    elif selection == 'Black_Hole':
        add( Black_Hole(x,y,20,20) )
    elif selection == 'Pulsator':
        add( Pulsator(x,y,20,20) )
    elif selection == 'Hunter':
        add( Hunter(x,y,20,20,0,5) )
    elif selection == 'Special':
        add( Special(x,y,5,5,0,10) )
Ejemplo n.º 10
0
def mouse_click(x,y):
    try:
        if object_name == 'Ball':
            balls.add(Ball(x,y))
        elif object_name == 'Floater':
            balls.add(Floater(x,y))
        elif object_name == 'Black_Hole':
            balls.add(Black_Hole(x,y))
        elif object_name == 'Pulsator':
            balls.add(Pulsator(x,y))
        elif object_name == 'Hunter':
            balls.add(Hunter(x,y))  
        elif object_name == 'Special':
            balls.add(Special(x,y))
  
        elif object_name == 'Remove':
            for i in find(lambda a: a.contains((x,y))):
                balls.remove(i)      
        
    except:
        pass
Ejemplo n.º 11
0
def mouse_click(x, y):
    global balls
    if select_kind == 'Remove':
        for b in balls:
            coor = b.get_location()
            if coor[0] - 5 < x and x < coor[0] + 5 and coor[
                    1] - 5 < y and y < coor[1] + 5:
                remove(b)
                break
    elif select_kind == 'Ball':
        add(Ball(x, y))
    elif select_kind == 'Floater':
        add(Floater(x, y))
    elif select_kind == 'Black_Hole':
        add(Black_Hole(x, y))
    elif select_kind == 'Pulsator':
        add(Pulsator(x, y))
    elif select_kind == 'Hunter':
        add(Hunter(x, y))
    elif select_kind == 'Special':
        add(Special(x, y))
Ejemplo n.º 12
0
def mouse_click(x,y):
    global balls, click, remove_set
    if str(click) == "Remove":
        try:
            for ele in balls:
                if ele.contains((x,y)):
                    remove(ele) 
        except:
            pass
    else:
        if str(click) == "Ball":
            add(Ball(x,y))
        elif str(click) == 'Black_Hole':
            add(Black_Hole(x,y))
        elif str(click) == 'Floater':
            add(Floater(x,y))
        elif str(click) == 'Hunter':
            add(Hunter(x,y))
        elif str(click) == 'Pulsator':
            add(Pulsator(x,y))
        elif str(click) == "Special":
            add(Special(x,y))
Ejemplo n.º 13
0
 def gl_init(self):
   Special.init()
   [thing.gl_init() for thing in self.contents]