示例#1
0
    def __init__(self, ID, *url, **kw):
        """
        Instantiates me with an item store keyed to the supplied hashable
        I{ID}.  Ensures that I have access to a class-wide instance of a
        L{Search} object so that I can update the database's full-text index
        when writing values containing text content.

        In addition to any engine-specifying keywords supplied, the following
        are particular to this constructor:

        @param ID: A hashable object that is used as my unique identifier.
        
        @keyword search: Set C{True} if text indexing is to be updated when items
            are added, updated, or deleted.

        @keyword search: Option, default is for no indexing of items' text
            content.

        """
        try:
            self.ID = hash(ID)
        except:
            raise TypeError("Item IDs must be hashable")
        # In-memory Caches
        self.data, self.keyCache = {}, {}
        # For tracking lazy writes
        self.writeTracker = util.DeferredTracker()
        self.deferToWrites = self.writeTracker.deferToAll
        # My very own persistent items store
        if url:
            self.i = items.Items(self.ID, url[0], **kw)
        else:
            self.i = items.Items(self.ID)
示例#2
0
def doEverything(samdb, dbnam, title, subtitle, date):
    print 'ENTERED DOEVERYTHING'
    try:
        ''' Now create the database. '''
        samdb.createDatabase(dbnam)
        print 'Database ' + dbnam + ' created.'
        dd = donors.Donors()
        dd.createDonorsTable(samdb)
        print "Donors table created."
        db = buyers.Buyers()
        db.createBuyersTable(samdb)
        print "Buyers table created."
        di = items.Items()
        di.createItemsTable(samdb)
        print "Items table created."
        ''' The Auction table is special because the data in it are
            entered by the auction manager, rather than by other users
            of the system.  Data for the table will come eventually
            from a GUI.  For the moment, default data are entered
            into the table.  '''
        da = auction.Auction()
        da.createAuctionTable(samdb)
        print "Auction table created."
        print 'ENTERING AUCTION DATA'
        da.addAuctionTitle(samdb, title)
        da.addAuctionSubtitle(samdb, subtitle)
        da.addAuctionDate(samdb, date)
        print 'ADDED AUCTION DATA'
    except MySQLdb.Error, e:
        print "createAuction.doEverything: Error %d: %s" % \
                (e.args[0], e.args[1])
        sys.exit(1)
示例#3
0
 def __init__(self, samdb):
     self.samdb = samdb
     self.auction = auction.Auction()
     self.buyers = buyers.Buyers()
     self.donors = donors.Donors()
     self.items = items.Items()
     self.fname = self.rand_fname('xxx', 8)
     lines = []
示例#4
0
 def set_all_items(self):
     itm = items.Items()
     list_items = itm.get_all_items()
     oper = classes.operations()
     n = oper.check_item_base(len(list_items))
     for x in range(0, n):
         self.main_widget.ids.itembase.add_widget(list_items[x])
     for x in range(n + 1, len(list_items)):
         self.main_widget.ids.itemgrid.add_widget(list_items[x])
示例#5
0
文件: pet.py 项目: DeukYu/CookieRun
    def update(self):
        if interface_state.PetChoice == 0:
            self.frame = (self.frame + STAR_FLOWER_FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % 4
            if get_time() - self.Pet_Time > 5:
                for i in range(0, 10):
                    item = items.Items(random.randint(0, 2), random.randint(100, 700))
                    game_world.add_object(item, 1)
                    self.Pet_Time = get_time()

        elif interface_state.PetChoice == 1:
            self.frame = (self.frame + STAR_FLOWER_FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % 4

        elif interface_state.PetChoice == 2:
            self.frame = (self.frame + STAR_FLOWER_FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % 4
            if get_time() - self.Pet_Time > 15:
                item = items.Items(random.randint(3, 4), 400)
                game_world.add_object(item, 1)
                self.Pet_Time = get_time()

        elif interface_state.PetChoice == 3:
            self.frame = (self.frame + GHOST_FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % 3

        self.y = main_state.cookie.y + 15
示例#6
0
def testConnectAndPopulate():

    profile = profileservices.getProfile()
    samdb = dbservices.Samdb(profile['dbName'], profile['hostName'],
                             int(profile['portNumber']), profile['userName'],
                             profile['password'])
    samdb.useDatabase(profile['dbName'])
    ## Create objects for Auction, Donors, Buyers, Items, and Purchases
    da = auction.Auction()
    dd = donors.Donors()
    db = buyers.Buyers()
    di = items.Items()
    dp = purchases.Purchases()
    populate(samdb, da, dd, db, di, dp)
示例#7
0
def loadItems():
    print "--------------------------"
    print "---    LOADING ITEMS   ---"
    print "--------------------------"
    tempItems = sql.getItems()
    for i in tempItems:
        item.itemStore[i["id"]] = item.Items()
        item.itemStore[i["id"]].id = i["id"]
        item.itemStore[i["id"]].name = i["name"]
        item.itemStore[i["id"]].desc = i["description"]
        item.itemStore[i["id"]].type = i["type"]
        item.itemStore[i["id"]].damage = i["damage"]
        item.itemStore[i["id"]].armor = i["armor"]
        item.itemStore[i["id"]].str = i["str"]
        item.itemStore[i["id"]].vit = i["vit"]
        item.itemStore[i["id"]].wis = i["wis"]
        item.itemStore[i["id"]].trade_value = i["trade_value"]
        print "--- LOADED ITEM: " + item.itemStore[i["id"]].name
示例#8
0
    def __init__(self, parent, samdb):
        super(ItemDeleteForm, self).__init__(parent)
        
        self.samdb = samdb
        self.parent = parent
        self.items = items.Items()
        self.chooserLists = chooserlists.ChooserLists()
        self.con = console.Console()
        
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        
        self.chooserPanel = wx.Panel(self, -1)
        self.BuildChooser(samdb)

        mainSizer.Add(self.chooserPanel)
        
        self.SetSizer(mainSizer)
        mainSizer.Fit(parent)
        mainSizer.SetSizeHints(parent)
 def add_to_multi(self, id_item):
     mutli_object = mul.Items()
     mutli_object.id_items = id_item
     return mutli_object
示例#10
0
文件: context.py 项目: raoulxq/dfhack
    def items(self):
        import items
        if self._item_obj is None:
            self._item_obj = items.Items(libdfhack.Context_getItems(self._c_ptr))

        return self._item_obj
示例#11
0
GAMESIZE = (screenlength,screenlength)
fullscreen = True
pixelperfect = True

screen = pygame.display.set_mode((screenlength,screenlength),pygame.RESIZABLE)
fullscreensize = pygame.display.list_modes()[0]
background = pygame.Surface(screen.get_rect().size)

ROOMNUM = 12
tree = m.generatetree(ROOMNUM)
#starts the player at spawn, with no explored rooms
currentroom = "A"
previousroom = currentroom
exploredlist = []
unlocks = Unlocks()
items = i.Items(unlocks)
itemui = i.Itemview()
#items.add("A",(90,90))

roomdict,specialdict,items = treestorooms(tree,items,True)

coins = i.Coins()

keys = []

clock = pygame.time.Clock()

transition = Roomtransition()

player = platformer.Player()
gun = platformer.Gun(player.pos)
示例#12
0
    def __init__(self, parent, samdb, function):
        super(PurchaseEntryForm, self).__init__(parent)

        self.parent = parent
        self.samdb = samdb
        self.function = function
        self.items = items.Items()
        self.buyers = buyers.Buyers()
        self.purchases = purchases.Purchases()
        self.con = console.Console()

        # First create the controls

        itemNumberLabel = wx.StaticText(self, -1, "Item #:")
        self.itemNumberTC = wx.TextCtrl(self, -1, "", size=(40, -1), \
                                        style=wx.TE_RIGHT)

        buyerNumberLabel = wx.StaticText(self, -1, "Buyer #:")
        self.buyerNumberTC = wx.TextCtrl(self, -1, "", size=(40, -1), \
                                        style=wx.TE_RIGHT)

        winningBidLabel = wx.StaticText(self, -1, "Winning Bid:")
        self.winningBidTC = wx.TextCtrl(self, -1, "", size=(50, -1), \
                                         style=wx.TE_RIGHT)

        cancelButton = wx.Button(self, -1, "Cancel")
        self.Bind(wx.EVT_BUTTON, self.onCancelButton, cancelButton)

        saveButton = wx.Button(self, -1, "Save")
        self.Bind(wx.EVT_BUTTON, self.onSaveButton, saveButton)

        # Now do the layout.

        # mainSizer is the top-level one that manages everything
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # addrSizer is a grid that holds all of the item info
        addrSizer = wx.GridBagSizer(5, 5)
        #addrSizer.AddGrowableCol(1)

        addrSizer.Add(itemNumberLabel, (0, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.itemNumberTC, (0, 1), (1, 1))

        addrSizer.Add(buyerNumberLabel, (1, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.buyerNumberTC, (1, 1), (1, 1))

        addrSizer.Add(winningBidLabel, (2, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.winningBidTC, (2, 1), (1, 1))

        mainSizer.Add(addrSizer, 0, wx.EXPAND | wx.ALL, 10)

        # Now a buttonSizer for the two buttons.
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add((20, 20), 1)
        buttonSizer.Add(cancelButton)
        buttonSizer.Add((20, 20), 1)
        buttonSizer.Add(saveButton)
        buttonSizer.Add((20, 20), 1)

        # Now add the addrSizer to the mainSizer
        mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.BOTTOM, 10)

        self.SetSizer(mainSizer)

        # Fit the frame to the needs of the sizer.  The frame will
        # automatically resize the panel as needed.  Also prevent the
        # frame from getting smaller than this size.
        mainSizer.Fit(parent)
        mainSizer.SetSizeHints(parent)
示例#13
0
    def update(self):
        if self.operation:
            if self.Bx1_1 <= -400:
                self.Bx1_1 = 1200
                self.Bx1_1 -= 10 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Bx1_1 -= 10 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if self.Bx1_2 <= -400:
                self.Bx1_2 = 1200
                self.Bx1_2 -= 10 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Bx1_2 -= 10 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if self.Fx1_1 <= -700:
                self.Fx1_1 = self.Fx1_2 + 1400
                self.Fx1_1 -= 350 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Fx1_1 -= 350 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if self.Fx1_2 <= -700:
                self.Fx1_2 = self.Fx1_1 + 1400
                self.Fx1_2 -= 350 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Fx1_2 -= 350 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if self.Bottomx1_1 <= -400:
                self.Bottomx1_1 = 1200
                self.Bottomx1_1 -= 250 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Bottomx1_1 -= 250 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if self.Bottomx1_2 <= -400:
                self.Bottomx1_2 = 1200
                self.Bottomx1_2 -= 250 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)
            else:
                self.Bottomx1_2 -= 250 * game_framework.frame_time * (
                    main_state.cookie.pace + main_state.pet.speed)

            if get_time() - self.Effect_item_Time > 0.2:
                item = items.Items(random.randint(0, 2), 800)
                game_world.add_object(item, 1)
                self.Effect_item_Time = get_time()

            if get_time() - self.Score_item_Time > random.randint(8, 20):
                item = items.Items(random.randint(3, 4), 800)
                game_world.add_object(item, 1)
                self.Score_item_Time = get_time()

            if get_time() - self.Obstacle_Time > random.randint(5, 10):
                obstacle = obstacles.Obstacles(random.randint(0, 4))
                game_world.add_object(obstacle, 1)
                self.Obstacle_Time = get_time()
示例#14
0
    def __init__(self, parent, samdb, function):
        super(itementryform, self).__init__(parent)

        self.samdb = samdb
        self.function = function
        self.items = items.Items()
        self.donors = donors.Donors()
        self.con = console.Console()

        # First create the controls

        itemNumberLabel = wx.StaticText(self, -1, "Item #:")
        if function == 'add':
            self.itemNumberTC = wx.TextCtrl(self, -1, "", size=(40, -1), \
                                        style = wx.TE_RIGHT)
        else:
            self.itemNumberTC = wx.TextCtrl(self, -1, "", size=(40, -1), \
                                        style = wx.TE_RIGHT | wx.TE_READONLY)

        itemDescriptionLabel = wx.StaticText(self, -1, "Description:")
        #self.itemDescriptionTC = wx.TextCtrl(self, -1, "", size=(200, -1))
        self.itemDescriptionTC = wx.TextCtrl(self, -1, "")

        donorNumberLabel = wx.StaticText(self, -1, "Donor #:")
        self.donorNumberTC = wx.TextCtrl(self, -1, "", size=(40,-1), \
                                         style = wx.TE_RIGHT)

        retailPriceLabel = wx.StaticText(self, -1, "Retail Price:")
        self.retailPriceTC = wx.TextCtrl(self, -1, "", size=(50, -1), \
                                         style = wx.TE_RIGHT)

        minimumBidLabel = wx.StaticText(self, -1, "Minimum Bid:")
        self.minimumBidTC = wx.TextCtrl(self, -1, "", size=(50, -1), \
                                        style = wx.TE_RIGHT)

        incrementLabel = wx.StaticText(self, -1, "Increment:")
        self.incrementTC = wx.TextCtrl(self, -1, "", size=(50, -1), \
                                        style = wx.TE_RIGHT)

        cancelButton = wx.Button(self, -1, "Cancel")
        self.Bind(wx.EVT_BUTTON, self.onCancelButton, cancelButton)

        saveButton = wx.Button(self, -1, "Save")
        self.Bind(wx.EVT_BUTTON, self.onSaveButton, saveButton)

        # Now do the layout.

        # mainSizer is the top-level one that manages everything
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # addrSizer is a grid that holds all of the item info
        addrSizer = wx.GridBagSizer(5, 5)
        #addrSizer.AddGrowableCol(1)

        addrSizer.Add(itemNumberLabel, (0, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.itemNumberTC, (0, 1), (1, 1))

        addrSizer.Add(itemDescriptionLabel, (1, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.itemDescriptionTC, (1, 1), (1, 5), wx.EXPAND)

        addrSizer.Add(donorNumberLabel, (2, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.donorNumberTC, (2, 1), (1, 1))

        addrSizer.Add(retailPriceLabel, (3, 0), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.retailPriceTC, (3, 1), (1, 1))

        addrSizer.Add(minimumBidLabel, (3, 2), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.minimumBidTC, (3, 3), (1, 1))

        addrSizer.Add(incrementLabel, (3, 4), (1, 1), wx.ALIGN_RIGHT,
                      wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.incrementTC, (3, 5), (1, 1))

        mainSizer.Add(addrSizer, 0, wx.EXPAND | wx.ALL, 10)

        # Now a buttonSizer for the two buttons.
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add((20, 20), 1)
        buttonSizer.Add(cancelButton)
        buttonSizer.Add((20, 20), 1)
        buttonSizer.Add(saveButton)
        buttonSizer.Add((20, 20), 1)

        # Now add the addrSizer to the mainSizer
        mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.BOTTOM, 10)

        self.SetSizer(mainSizer)

        # Fit the frame to the needs of the sizer.  The frame will
        # automatically resize the panel as needed.  Also prevent the
        # frame from getting smaller than this size.
        mainSizer.Fit(parent)
        mainSizer.SetSizeHints(parent)
示例#15
0
def main():

    #database
    record_switch = False
    text_rank = []
    textpos_rank = []

    #start music
    pygame.mixer.music.load('./media/background.wav')
    pygame.mixer.music.play(-1)

    #initialize objects.
    clock = pygame.time.Clock()
    running = True
    font = pygame.font.Font(None, 32)
    car = player.Player()
    cam = camera.Camera()
    target = gamemode.Finish()
    item = []
    traffics = []
    bound_alert = bounds.Alert()
    time_alert = timeout.Alert()
    info = menu.Alert()
    pointer = direction.Tracker(int(CENTER_W * 2), int(CENTER_H * 2))
    #create sprite groups.
    map_s = pygame.sprite.Group()
    player_s = pygame.sprite.Group()
    traffic_s = pygame.sprite.Group()
    tracks_s = pygame.sprite.Group()
    target_s = pygame.sprite.Group()
    item_s = pygame.sprite.Group()
    pointer_s = pygame.sprite.Group()
    timer_alert_s = pygame.sprite.Group()
    bound_alert_s = pygame.sprite.Group()
    menu_alert_s = pygame.sprite.Group()

    #generate tiles     기본 맵 초원
    for tile_num in range(0, len(maps.map_tile[0])):
        maps.map_files.append(load_image(maps.map_tile[0][tile_num], False))
    for x in range(0, 10):
        for y in range(0, 10):
            map_s.add(
                maps.Map(maps.map_1[x][y], x * 1000, y * 1000,
                         maps.map_1_rot[x][y]))

#load tracks
    tracks.initialize()
    #load finish
    target_s.add(target)
    #load items
    items.initialize()
    for count in range(0, ITEM_COUNT):
        item.append(items.Items())
        item_s.add(item[count])
#load direction
    pointer_s.add(pointer)
    #load alerts
    timer_alert_s.add(time_alert)
    bound_alert_s.add(bound_alert)
    menu_alert_s.add(info)
    #load traffic
    traffic.initialize(CENTER_W, CENTER_H)
    for count in range(0, TRAFFIC_COUNT):
        traffics.append(traffic.Traffic())
        traffic_s.add(traffics[count])

    player_s.add(car)

    cam.set_pos(car.x, car.y)

    while running:
        #Render loop.

        #Check for menu/reset, (keyup event - trigger ONCE)
        for event in pygame.event.get():
            if event.type == pygame.KEYUP:
                if keys[K_m]:
                    if (info.visibility == True):
                        info.visibility = False
                    else:
                        info.visibility = True

                if info.visibility == True:
                    if (keys[K_p]):
                        car.reset()
                        target.reset()
                        for i in range(0, ITEM_COUNT):
                            item[i].reset
                        record_switch = False

                    if (keys[K_q]):
                        pygame.quit()
                        sys.exit(0)

                    if (keys[K_1]):
                        change_map(map_s, maps, 0)
                        car.reset()
                        target.reset()
                        for i in range(0, ITEM_COUNT):
                            item[i].reset

                    if (keys[K_2]):
                        change_map(map_s, maps, 1)
                        car.reset()
                        target.reset()
                        for i in range(0, ITEM_COUNT):
                            item[i].reset

                    if (keys[K_3]):
                        change_map(map_s, maps, 2)
                        car.reset()
                        target.reset()
                        for i in range(0, ITEM_COUNT):
                            item[i].reset

            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                running = False
                break

#Check for key input. (KEYDOWN, trigger often)
        keys = pygame.key.get_pressed()
        if (target.timeleft > 0):
            if keys[K_LEFT]:
                car.steerleft()
            if keys[K_RIGHT]:
                car.steerright()
            if keys[K_UP]:
                car.accelerate()
            else:
                car.soften()
            if keys[K_DOWN]:
                car.deaccelerate()

        cam.set_pos(car.x, car.y)

        #Show text data.
        text_fps = font.render('FPS: ' + str(int(clock.get_fps())), 1,
                               (224, 16, 16))
        textpos_fps = text_fps.get_rect(centery=175, centerx=260)

        text_score = font.render('Score: ' + str(target.score), 1,
                                 (224, 16, 16))
        textpos_score = text_fps.get_rect(centery=205, centerx=260)

        text_timer = font.render(
            'Timer: ' + str(int((target.timeleft / 60) / 60)) + ":" +
            str(int((target.timeleft / 60) % 60)), 1, (224, 16, 16))
        textpos_timer = text_fps.get_rect(centery=235, centerx=260)

        text_red_ball = font.render(
            'Red Ball: ' + str(int(car.red_timer / 64)), 1, (224, 16, 16))
        textpos_red_ball = text_fps.get_rect(centery=265, centerx=260)

        text_blue_ball = font.render(
            'Blue Ball: ' + str(int(car.blue_timer / 64)), 1, (224, 16, 16))
        textpos_blue_ball = text_fps.get_rect(centery=295, centerx=260)

        text_green_ball = font.render(
            'Green Ball: ' + str(int(car.green_timer / 64)), 1, (224, 16, 16))
        textpos_green_ball = text_fps.get_rect(centery=325, centerx=260)

        text_ranking = font.render('TOP 5 Ranking', 1, (16, 224, 16))
        textpos_ranking = text_fps.get_rect(centery=CENTER_H,
                                            centerx=CENTER_W - 20)

        text_boundtimer = font.render(
            'Game over After ' + str(int(bound_alert.timeleft / 64)) +
            ' Second.', 1, (224, 16, 16))
        textpos_boundtimer = text_fps.get_rect(centery=CENTER_H + 30,
                                               centerx=CENTER_W - 100)

        #Render Scene.
        screen.blit(background, (0, 0))

        #cam.set_pos(car.x, car.y)

        map_s.update(cam.x, cam.y)
        map_s.draw(screen)

        #Conditional renders/effects
        car.grass(screen.get_at(((int(CENTER_W - 5), int(CENTER_H - 5)))).g)
        if (car.tracks):
            tracks_s.add(
                tracks.Track(cam.x + CENTER_W, cam.y + CENTER_H, car.dir))

#Just render..
        tracks_s.update(cam.x, cam.y)
        tracks_s.draw(screen)

        player_s.update(cam.x, cam.y)
        player_s.draw(screen)

        traffic_s.update(cam.x, cam.y)
        traffic_s.draw(screen)

        target_s.update(cam.x, cam.y)
        target_s.draw(screen)

        item_s.update(cam.x, cam.y)
        item_s.draw(screen)

        pointer_s.update(car.x + CENTER_W, car.y + CENTER_H, target.x,
                         target.y)
        pointer_s.draw(screen)

        #Conditional renders.

        if (bounds.breaking(car.x + CENTER_W, car.y + CENTER_H) == True):
            bound_alert_s.update()
            bound_alert_s.draw(screen)
            bound_alert.update()
            screen.blit(text_boundtimer, textpos_boundtimer)
            if (bound_alert.timeleft == 0):
                target.timeleft = 0

        else:
            bound_alert.timeleft = 640

        if (target.timeleft == 0):
            timer_alert_s.draw(screen)
            car.speed = 0
            text_score = font.render('Your Score: ' + str(target.score), 1,
                                     (224, 16, 16))
            textpos_score = text_fps.get_rect(centery=CENTER_H - 56,
                                              centerx=CENTER_W - 20)

            if record_switch == False:
                cur.execute("SELECT * From rank ORDER BY Point DESC")
                dataList = []
                dataList = cur.fetchall()
                rank = 0

                if len(dataList) == 0:
                    cur.execute("INSERT INTO rank VALUES(?,?)",
                                (1, target.score))

                elif len(dataList) < 5:
                    for i in dataList:
                        if i[1] < target.score:
                            rank = i[0]
                            break

                    if rank != 0:
                        cur.execute(
                            "UPDATE rank SET Rank=Rank+1 WHERE Point < %d" %
                            (target.score))
                        cur.execute("INSERT INTO rank VALUES(?,?)",
                                    (rank, target.score))

                    else:
                        cur.execute("INSERT INTO rank VALUES(?,?)",
                                    (len(dataList) + 1, target.score))

                elif len(dataList) >= 5:
                    for i in dataList:
                        if i[1] < target.score:
                            rank = i[0]
                            break

                    if rank != 0:
                        cur.execute(
                            "UPDATE rank SET Rank=Rank+1 WHERE Point<%d" %
                            (target.score))
                        cur.execute("INSERT INTO rank VALUES(?,?)",
                                    (rank, target.score))
                        cur.execute("DELETE FROM rank WHERE Rank > 5")

                con.commit()
                cur.execute("SELECT * From rank ORDER BY Rank ASC")
                dataList = cur.fetchall()

                cnt = 0

                text_rank.clear()
                textpos_rank.clear()

                for i in dataList:
                    cnt = cnt + 1
                    text_rank.append(
                        font.render(
                            str(i[0]) + '. ' + str(i[1]), 1, (16, 224, 16)))
                    textpos_rank.append(
                        text_fps.get_rect(centery=CENTER_H + 25 + cnt * 25,
                                          centerx=CENTER_W - 20))

                record_switch = True

        if (info.visibility == True):
            menu_alert_s.draw(screen)

#Blit Blit..
        screen.blit(text_fps, textpos_fps)
        screen.blit(text_score, textpos_score)
        screen.blit(text_timer, textpos_timer)
        screen.blit(text_red_ball, textpos_red_ball)
        screen.blit(text_blue_ball, textpos_blue_ball)
        screen.blit(text_green_ball, textpos_green_ball)
        if record_switch == True:

            screen.blit(text_ranking, textpos_ranking)
            for i in range(0, cnt):
                screen.blit(text_rank[i], textpos_rank[i])
        pygame.display.flip()

        #Check collision!!!

        #traffic 과의 충돌 확인. 블루볼 먹었을 시에는 충돌 없음
        for i in range(0, TRAFFIC_COUNT):
            if traffics[i].collision_check(car) == True:
                if car.blue_ball == True:
                    pygame.mixer.Sound.play(point_sound)
                    traffics[i].respawn()
                else:
                    car.impact()
                    target.car_crash()

        if pygame.sprite.spritecollide(car, target_s, True):
            pygame.mixer.Sound.play(point_sound)
            target.claim_flag()
            target.generate_finish()
            target_s.add(target)

        for i in range(0, ITEM_COUNT):
            if item[i].collision_check(car) == True:
                pygame.mixer.Sound.play(point_sound)
                car.get_item(item[i].color)
                item[i].generate_items()
                item_s.add(item[i])

        clock.tick(64)
示例#16
0
                    and toppos > tale[tales].botpos + 2) and tales > 2 and not (tales == items.itemattributes_current['tales'] - 1):
                stopplay = 1
        for tales in range(items.itemattributes_current['tales']):
            tale[items.itemattributes_current['tales'] - 1 - tales].drawtale(tale[items.itemattributes_current['tales'] - 1 - tales].midtpos)
        character.drawplayer(norm.pos())

        # ##########Items########## #
        # Lager item
        if item_create:
            itemattributes_previous = items.itemattributes_current.copy()
            while True:
                item_create = 0
                pen5.clear()
                items.att1 = itemattributes_previous.copy()
                items.att2 = itemattributes_previous.copy()
                item = items.Items(border, 1)
                item2 = items.Items(border, 2)
                if (item.itemname == item2.itemname) \
                        or (leftpos - 10 <= item.area[0][1] and rightpos + 10 >= item.area[0][0] and botpos - 10 <=
                            item.area[1][1] and toppos - 10 >= item.area[1][0]) \
                        or (leftpos - 10 <= item2.area[0][1] and rightpos + 10 >= item2.area[0][0] and botpos - 10 <=
                            item2.area[1][1] and toppos + 10 >= item2.area[1][0]):
                    continue
                else:
                    break

        # Hendelse ved kollisjon mellom character og item
        if leftpos <= item.area[0][1] and rightpos >= item.area[0][0] and botpos <= item.area[1][1] and toppos >= \
                item.area[1][0] and not item_create:
            items.itemattributes_current = items.att1.copy()
            item_create = 1