Пример #1
0
    def draw_one_pad(self, index):
        w = variables.notewidth()
        padcolor = variables.notes_colors[index]
        if(self.spacepressedp):
            padcolor = variables.PINK

        # draw the pads
        if variables.settings.dancepadmodep:
            padrect = Rect(Beatmap.screenvaltoxpos(index), variables.getpadypos()-variables.dancearrowwidth(), variables.dancearrowwidth(), variables.dancearrowwidth())
            arrowpic = None
            if self.held_keys[index] != None or self.modifierheldkeys[index] != None:
                arrowpic = dancenamemap[index]
            else:
                arrowpic = dancenamemapdark[index]

            variables.screen.blit(getpicbywidth(arrowpic, variables.dancearrowwidth()), padrect)
            variables.dirtyrects.append(padrect)
        else:
            padrect = Rect(Beatmap.screenvaltoxpos(index)- w / 8, variables.getpadypos() - padheight, w * 1.25, padheight)
            pygame.draw.rect(variables.screen, padcolor, padrect)
            variables.dirtyrects.append(padrect)

        # draw little pads if space pressed
        if self.spacepressedp and not variables.settings.dancepadmodep:
            spacing = w*0.05
            padrect = Rect(Beatmap.screenvaltoxpos(index) - w / 8+ spacing/2, variables.getpadypos() - padheight+spacing/2, w * 1.25-spacing, padheight-spacing)
            pygame.draw.rect(variables.screen, variables.notes_colors[index], padrect)
            variables.dirtyrects.append(padrect)
Пример #2
0
 def tutorialdancetick(self,currentb, dt):
     if self.tutorialstate == "starting":
         if currentb.notetime() > 4:
             skiptutorialp = False
             if self.accidentaltutorialp:
                 skiptutorialp = len(currentb.scores) == 1 and currentb.scores[0] >= variables.ok_value
             else:
                 skiptutorialp = len(currentb.scores) == 2 and (currentb.scores[0] + currentb.scores[1])/2 >= variables.ok_value
             
             #exit the tutorial if the got the first two notes perfectly
             if skiptutorialp:
                 self.exittutorial()
                 # get rid of the third turorial note
                 self.deletetutorialnote()
             else:
                 self.tutorialstate = "first note"
                 currentb.showkeys(self.accidentaltutorialp)
                 maps.engage_conversation(self.tutorialconversations[0], True)
     elif self.tutorialstate == "first note":
         fnote = currentb.notes[0]
         if fnote.pos[1] >= variables.getpadypos() and fnote.time > variables.settings.notes_per_screen + 2:
             self.tutorialstate = "release note"
             maps.engage_conversation(self.tutorialconversations[1], True)
     elif self.tutorialstate == "release note":
         fnote = currentb.notes[0]
         if fnote.pos[1] - fnote.height(currentb.tempo) > variables.getpadypos() and fnote.time > 10:
             self.tutorialstate = "finished first"
             maps.engage_conversation(self.tutorialconversations[2], True)
     elif self.tutorialstate == "finished first":
         fnote = currentb.notes[0]
         if fnote.time >= 24:
             self.tutorialstate = "done"
             currentb.scores = []
             maps.engage_conversation(self.tutorialconversations[3], True)
             self.exittutorial()
Пример #3
0
 def tutorialdancetick(self,currentb, dt):
     if self.tutorialstate == "starting":
         if currentb.notetime() > 4:
             skiptutorialp = False
             if self.accidentaltutorialp:
                 skiptutorialp = len(currentb.scores) == 1 and currentb.scores[0] >= variables.ok_value
             else:
                 skiptutorialp = len(currentb.scores) == 2 and (currentb.scores[0] + currentb.scores[1])/2 >= variables.ok_value
             
             #exit the tutorial if the got the first two notes perfectly
             if skiptutorialp:
                 self.exittutorial()
                 # get rid of the third turorial note
                 self.deletetutorialnote()
             else:
                 self.tutorialstate = "first note"
                 currentb.showkeys(self.accidentaltutorialp)
                 maps.engage_conversation(self.tutorialconversations[0], True)
     elif self.tutorialstate == "first note":
         fnote = currentb.notes[0]
         if fnote.pos[1] >= variables.getpadypos() and fnote.time > variables.settings.notes_per_screen + 2:
             self.tutorialstate = "release note"
             maps.engage_conversation(self.tutorialconversations[1], True)
     elif self.tutorialstate == "release note":
         fnote = currentb.notes[0]
         if fnote.pos[1] - fnote.height(currentb.tempo) > variables.getpadypos() and fnote.time > 10:
             self.tutorialstate = "finished first"
             maps.engage_conversation(self.tutorialconversations[2], True)
     elif self.tutorialstate == "finished first":
         fnote = currentb.notes[0]
         if fnote.time >= 24:
             self.tutorialstate = "done"
             currentb.scores = []
             maps.engage_conversation(self.tutorialconversations[3], True)
             self.exittutorial()
Пример #4
0
    def process_final_score(self, note, endscore):
        final_note_score = None
        if endscore < note.beginning_score:
            final_note_score = endscore
        else:
            final_note_score = note.beginning_score

        note.end_score = endscore

        
        note.ison = False
        # if it was missed in the later half, set the height offset for drawing
        if note.beginning_score != variables.miss_value and endscore == variables.miss_value:
            note.height_offset = note.pos[1] - variables.getpadypos()

        self.appendscore(final_note_score, note)

        if final_note_score == variables.miss_value:
            self.setfeedback(note.getscreenvalue(), "miss")
        elif final_note_score == variables.good_value:
            self.setfeedback(note.getscreenvalue(), "good")
        elif final_note_score == variables.ok_value:
            self.setfeedback(note.getscreenvalue(), "ok")
        elif final_note_score == variables.perfect_value:
            self.setfeedback(note.getscreenvalue(), "perfect")
Пример #5
0
    def draw_pads(self):
        numbertodraw = 8
        if variables.settings.dancepadmodep:
            numbertodraw = 4

        # draw bottom rectangles
        for x in range(numbertodraw):
            self.draw_one_presspad(x)

            self.draw_one_pad(x)

        # draw the feedback (keys then scores, perfect ect)
        for x in range(0, 8):
            blitp = False
            if self.feedback_timers[x] != None:
                if variables.settings.current_time < self.feedback_timers[x]:
                    blitp = True
            else:
                blitp = True

            if blitp:
                bx = Beatmap.screenvaltoxpos(x) - variables.notewidth() / 8
                by = variables.getpadypos() - variables.getpadheight()
                bpic = self.getfeedbackpic(x)
                brect = Rect(bx, by, bpic.get_width(), bpic.get_height())
                variables.screen.blit(self.getfeedbackpic(x), (bx, by))
                variables.dirtyrects.append(brect)
Пример #6
0
    def draw_pads(self):
        numbertodraw = 8
        if variables.settings.dancepadmodep:
            numbertodraw = 4


        # draw bottom rectangles
        for x in range(numbertodraw):
            self.draw_one_presspad(x)

            self.draw_one_pad(x)
            

        # draw the feedback (keys then scores, perfect ect)
        for x in range(0, 8):
            blitp = False
            if self.feedback_timers[x] != None:
                if variables.settings.current_time < self.feedback_timers[x]:
                    blitp = True
            else:
                blitp = True

            if blitp:
                bx = Beatmap.screenvaltoxpos(x) - variables.notewidth() / 8 
                by = variables.getpadypos() - padheight
                bpic = self.getfeedbackpic(x)
                brect = Rect(bx, by, bpic.get_width(), bpic.get_height())
                variables.screen.blit(self.getfeedbackpic(x), (bx, by))
                variables.dirtyrects.append(brect)
Пример #7
0
    def draw_one_pad(self, index):
        w = variables.notewidth()
        padcolor = variables.notes_colors[index]
        if (self.spacepressedp):
            padcolor = variables.PINK

        # draw the pads
        if variables.settings.dancepadmodep:
            padrect = Rect(
                Beatmap.screenvaltoxpos(index),
                variables.getpadypos() - variables.dancearrowwidth(),
                variables.dancearrowwidth(), variables.dancearrowwidth())
            arrowpic = None
            if self.held_keys[index] != None or self.modifierheldkeys[
                    index] != None:
                arrowpic = dancenamemap[index]
            else:
                arrowpic = dancenamemapdark[index]

            variables.screen.blit(
                getpicbywidth(arrowpic, variables.dancearrowwidth()), padrect)
            variables.dirtyrects.append(padrect)
        else:
            padrect = Rect(
                Beatmap.screenvaltoxpos(index) - w / 8,
                variables.getpadypos() - variables.getpadheight(),
                variables.noteendwidth(), variables.getpadheight())
            pygame.draw.rect(variables.screen, padcolor, padrect)
            variables.dirtyrects.append(padrect)

        # draw little pads if space pressed
        if self.spacepressedp and not variables.settings.dancepadmodep:
            spacing = w * 0.05
            padrect = Rect(
                Beatmap.screenvaltoxpos(index) -
                variables.noteendwidthoffset() + spacing / 2,
                variables.getpadypos() - variables.getpadheight() +
                spacing / 2,
                variables.noteendwidth() - spacing,
                variables.getpadheight() - spacing)
            pygame.draw.rect(variables.screen, variables.notes_colors[index],
                             padrect)
            variables.dirtyrects.append(padrect)
Пример #8
0
        def check_note(np):
            if self.notes[np].end_score == None and self.notes[np].beginning_score != None:
                top_of_note = self.notes[np].pos[1] - self.notes[np].height(self.tempo)
                s = self.pos_to_score(top_of_note)

                if s == None and self.notes[np].beginning_score != None:
                    s = variables.miss_value
                    self.notes[np].height_offset = self.notes[np].pos[1] - variables.getpadypos()

                if s != None:
                    self.process_final_score(self.notes[np], s)
Пример #9
0
 def pos_to_score(self, ypos):
     difference = abs(ypos - variables.getpadypos())
     if difference <= variables.getperfectrange():
         return variables.perfect_value
     elif difference <= variables.getgoodrange():
         return variables.good_value
     elif difference <= variables.getokrange():
         return variables.ok_value
     elif difference <= variables.getmissrange():
         return variables.miss_value
     else:
         return None
Пример #10
0
    def ontick(self):
        # update positions of notes
        for n in self.notes:
            n.pos = self.notepos(n)
        # remove notes that are off the screen
        np = 0
        while np < len(self.notes):
            if self.notes[np].pos[1] - self.notes[np].height(
                    self.tempo) > variables.height:
                del self.notes[0]
            else:
                break

        # make the notes not played a miss
        for x in range(len(self.notes)):
            # find whether the miss range or the distance to middle of note is smaller
            h = self.notes[x].height(self.tempo)
            smaller = min(h / 2, variables.getmissrange())

            if self.notes[x].pos[1] - smaller > variables.getpadypos(
            ) and self.notes[x].beginning_score == None:
                if self.notes[x].ison:
                    self.notes[x].beginning_score = variables.miss_value
                    self.process_final_score(self.notes[x],
                                             variables.miss_value)
                elif self.notes[x].pos[1] < 0:
                    # if you are in a part of the list before the screen, don't keep checking
                    # (assuming the list of notes must be ordered by time, of course)
                    break

        # update played notes for looping
        for k in self.held_keys:
            if not k == None:
                update_tone(k, self.enemyspecs["volumeenvelope"],
                            self.numofupdatetones)
                self.numofupdatetones += 1

        # update played notes for looping
        for k in self.modifierheldkeys:
            if not k == None:
                update_tone(k, self.enemyspecs["volumeenvelope"],
                            self.numofupdatetones)
                self.numofupdatetones += 1

        # handle the drum machine
        # now dt is based on starttime
        notetime = self.notetime() + variables.settings.notes_per_screen
        # play a drum sound if it is on the beat, drumcounter increases 4 times per beat
        if (notetime * 4 >= self.drumcounter + 1):
            self.drumcounter += 1

        # reset numofupdatetones for next frame
        self.numofupdatetones = 0
Пример #11
0
 def pos_to_score(self, ypos):
     difference = abs(ypos - variables.getpadypos())
     if difference <= variables.getperfectrange():
         return variables.perfect_value
     elif difference <= variables.getgoodrange():
         return variables.good_value
     elif difference <= variables.getokrange():
         return variables.ok_value
     elif difference <= variables.getmissrange():
         return variables.miss_value
     else:
         return None
Пример #12
0
 def draw_pad_rhythm_rects(self, y_positions_of_approaching_notes):
     for screenval in range(8):
         padx = Beatmap.screenvaltoxpos(screenval)
         for y_pos in y_positions_of_approaching_notes[screenval]:
             good_ranges_away = (variables.getpadypos() -
                                 y_pos) / variables.getgoodrange()
             if good_ranges_away <= 4 and good_ranges_away > 0:
                 padding = good_ranges_away * variables.getpadheight(
                 ) * 0.75
                 ring_rect = Rect(
                     padx - padding - variables.noteendwidthoffset(),
                     variables.getpadypos() - padding -
                     variables.getpadheight(),
                     padding * 2 + variables.noteendwidth(),
                     padding * 2 + variables.getpadheight())
                 pygame.draw.rect(variables.screen, variables.WHITE,
                                  ring_rect, variables.get_border_width())
                 # add some space for dirty rect
                 ring_rect.x -= variables.get_border_width()
                 ring_rect.y -= variables.get_border_width()
                 ring_rect.width += variables.get_border_width() * 2
                 ring_rect.height += variables.get_border_width() * 2
                 variables.dirtyrects.append(ring_rect)
Пример #13
0
        def check_note(np):
            if self.notes[np].end_score == None and self.notes[
                    np].beginning_score != None:
                top_of_note = self.notes[np].pos[1] - self.notes[np].height(
                    self.tempo)
                s = self.pos_to_score(top_of_note)

                if s == None and self.notes[np].beginning_score != None:
                    s = variables.miss_value
                    self.notes[np].height_offset = self.notes[np].pos[
                        1] - variables.getpadypos()

                if s != None:
                    self.process_final_score(self.notes[np], s)
Пример #14
0
    def ontick(self):
        # update positions of notes
        for n in self.notes:
            n.pos = self.notepos(n)
        # remove notes that are off the screen
        np = 0
        while np < len(self.notes):
            if self.notes[np].pos[1] - self.notes[np].height(self.tempo) > variables.height:
                del self.notes[0]
            else:
                break

        # make the notes not played a miss
        for x in range(len(self.notes)):
            # find whether the miss range or the distance to middle of note is smaller
            h = self.notes[x].height(self.tempo)
            smaller = min(h / 2, variables.getmissrange())

            if self.notes[x].pos[1] - smaller > variables.getpadypos() and self.notes[x].beginning_score == None:
                if self.notes[x].ison:
                    self.notes[x].beginning_score = variables.miss_value
                    self.process_final_score(self.notes[x], variables.miss_value)
                elif self.notes[x].pos[1] < 0:
                    # if you are in a part of the list before the screen, don't keep checking
                    # (assuming the list of notes must be ordered by time, of course)
                    break

        
        # update played notes for looping
        for k in self.held_keys:
            if not k == None:
                update_tone(k, self.enemyspecs["volumeenvelope"], self.numofupdatetones)
                self.numofupdatetones += 1

         # update played notes for looping
        for k in self.modifierheldkeys:
            if not k == None:
                update_tone(k, self.enemyspecs["volumeenvelope"], self.numofupdatetones)
                self.numofupdatetones += 1

        # handle the drum machine
        # now dt is based on starttime
        notetime = self.notetime() + variables.settings.notes_per_screen
        # play a drum sound if it is on the beat, drumcounter increases 4 times per beat
        if (notetime*4 >= self.drumcounter+1):
            self.drumcounter += 1

        # reset numofupdatetones for next frame
        self.numofupdatetones = 0
Пример #15
0
    def draw_one_presspad(self, index):
        
        # draw which ones are pressed
        if not variables.settings.dancepadmodep:
            w = variables.notewidth()
            ew = w * 1.25
            padellipseypos = variables.getpadypos() - padheight + padheight / 2 - ew / 4
            padcolor = (180, 180, 180)
            if self.modifierheldkeys[index] != None:
                padcolor = (variables.PINK[0]-70, variables.PINK[1]-30, variables.PINK[2]-70)
            elif self.spacepressedp:
                padcolor = (variables.PINK[0]-70, variables.PINK[1]-30, variables.PINK[2]-70)

            if self.held_keys[index] != None or self.modifierheldkeys[index] != None:
                expos = Beatmap.screenvaltoxpos(index) - w / 8
                pygame.draw.ellipse(variables.screen, padcolor, [expos,
                                                                        padellipseypos,
                                                                        ew, ew / 2])
                variables.dirtyrects.append(Rect(expos, padellipseypos, ew, ew/2))
Пример #16
0
    def draw_one_presspad(self, index):

        # draw which ones are pressed
        if not variables.settings.dancepadmodep:
            w = variables.notewidth()
            ew = w * 1.25
            padellipseypos = variables.getpadypos() - variables.getpadheight(
            ) + variables.getpadheight() / 2 - ew / 4
            padcolor = (180, 180, 180)
            if self.modifierheldkeys[index] != None or self.spacepressedp:
                padcolor = (variables.PINK[0] - 70, variables.PINK[1] - 30,
                            variables.PINK[2] - 70)

            if self.held_keys[index] != None or self.modifierheldkeys[
                    index] != None:
                expos = Beatmap.screenvaltoxpos(index) - w / 8
                pygame.draw.ellipse(variables.screen, padcolor,
                                    [expos, padellipseypos, ew, ew / 2])
                variables.dirtyrects.append(
                    Rect(expos, padellipseypos, ew, ew / 2))
Пример #17
0
def displaywave(buf, channel, drawnsofar):
    if not variables.settings.soundonp():
        return
    
    global furthestdisplaywavex, nextdisplaywavey
    # make it so that each second crosses .2 of the width of the screen
    wavelen = (buf.size/2)/variables.sample_rate * 0.2 * variables.width
    t = displaytuples[channel]
    waveamp = variables.gettextsize() * 0.7
    if t == None:
        if nextdisplaywavey < waveamp:
            nextdisplaywavey = waveamp
            
        # init a new display tuple
        displaytuples[channel] = (furthestdisplaywavex-wavelen, nextdisplaywavey, (random.randint(0,255), random.randint(0,255), random.randint(0,255)))
        
        nextdisplaywavey += waveamp*2
        if nextdisplaywavey > int(variables.getpadypos() -waveamp):
            nextdisplaywavey = waveamp
            
        t = displaytuples[channel]

    wavex = t[0]
    wavey = t[1]
    skiplen = len(buf)/wavelen
    drawwave(buf, skiplen, wavex, wavey, waveamp, wavelen, t[2], False)

    # now just update once and let it stay on screen
    pygame.display.update(Rect(wavex, wavey-waveamp, wavelen, waveamp*2))

    maxwavex = (variables.width*9/12)
    newwavex = wavex+wavelen
    if newwavex > maxwavex:
        newwavex = 0
        furthestdisplaywavex = newwavex
        variables.dirtyrects = [Rect(0,0,variables.width,variables.height)]
    
    displaytuples[channel] = (newwavex, wavey, t[2])
    if newwavex > furthestdisplaywavex:
        furthestdisplaywavex = newwavex    
Пример #18
0
def displaywave(buf, channel, drawnsofar):
    if not variables.settings.soundonp():
        return
    
    global furthestdisplaywavex, nextdisplaywavey
    # make it so that each second crosses .2 of the width of the screen
    wavelen = (buf.size/2)/variables.sample_rate * 0.2 * variables.width
    t = displaytuples[channel]
    waveamp = variables.gettextsize() * 0.7
    if t == None:
        if nextdisplaywavey < waveamp:
            nextdisplaywavey = waveamp
            
        # init a new display tuple
        displaytuples[channel] = (furthestdisplaywavex-wavelen, nextdisplaywavey, (random.randint(0,255), random.randint(0,255), random.randint(0,255)))
        
        nextdisplaywavey += waveamp*2
        if nextdisplaywavey > int(variables.getpadypos() -waveamp):
            nextdisplaywavey = waveamp
            
        t = displaytuples[channel]

    wavex = t[0]
    wavey = t[1]
    skiplen = len(buf)/wavelen
    drawwave(variables.battle_background, buf, skiplen,
             wavex, wavey, waveamp, wavelen, t[2], False)

    maxwavex = (variables.width*9/12)
    newwavex = wavex+wavelen
    if newwavex > maxwavex:
        newwavex = 0
        furthestdisplaywavex = newwavex
        variables.dirtyrects = [Rect(0,0,variables.width,variables.height)]
    
    displaytuples[channel] = (newwavex, wavey, t[2])
    if newwavex > furthestdisplaywavex:
        furthestdisplaywavex = newwavex    
Пример #19
0
    def process_final_score(self, note, endscore):
        final_note_score = None
        if endscore < note.beginning_score:
            final_note_score = endscore
        else:
            final_note_score = note.beginning_score

        note.end_score = endscore

        note.ison = False
        # if it was missed in the later half, set the height offset for drawing
        if note.beginning_score != variables.miss_value and endscore == variables.miss_value:
            note.height_offset = note.pos[1] - variables.getpadypos()

        self.appendscore(final_note_score, note)

        if final_note_score == variables.miss_value:
            self.setfeedback(note.getscreenvalue(), "miss")
        elif final_note_score == variables.good_value:
            self.setfeedback(note.getscreenvalue(), "good")
        elif final_note_score == variables.ok_value:
            self.setfeedback(note.getscreenvalue(), "ok")
        elif final_note_score == variables.perfect_value:
            self.setfeedback(note.getscreenvalue(), "perfect")
Пример #20
0
 def notepos(self, note):
     notetime = self.notetime()
     ypos = (notetime - note.time) * (variables.getpadypos(
     ) / variables.settings.notes_per_screen) + variables.getpadypos()
     return [Beatmap.screenvaltoxpos(note.getscreenvalue()), ypos]
Пример #21
0
    def draw(self):
        if self.current_beatmap<len(self.beatmaps):
            currentb = self.beatmaps[self.current_beatmap]
        else:
            currentb = None
        h = variables.height
        w = variables.width
        b = h * 13 / 16
        p = classvar.player
        # background
        variables.screen.fill(variables.BLACK)

        # draw enemy first
        if self.state != "dance":
            self.enemy.animation.reset() # if not dancing, use first frame
            

        # draw enemy
        self.enemy.animation.draw_topright(variables.screen, enemypic_height())
            
        playerpicandrect = self.getplayerpicandrect()
        

        # draw the player
        if self.state == "dance":
            # draw the special animation behind the player
            self.drawspecialmove()
        variables.screen.blit(playerpicandrect[0], playerpicandrect[1])

        if currentb != None:
            # now draw the combo if necessary
            self.drawcombo()

        if self.enemy.animation.updatealwaysbattle:
            self.updatescreenforenemy()
        
        # draw beatmap
        if self.state == "dance":
            self.beatmaps[self.current_beatmap].draw()
        elif self.state == "attacking":
            self.beatmaps[self.current_beatmap].draw_pads()

        if self.state == "choose":
            # enemy name
            enemyname = variables.font.render("LV " + str(self.enemy.lv) + " " + self.enemy.name + " appears!", 0,
                                              variables.WHITE)
            enemynamescaled = sscale(enemyname)
            variables.screen.blit(enemynamescaled, [w / 2 - (enemynamescaled.get_width() / 2), h / 2])

            self.battlechoice.draw()
            
            # draw the wave above the battlechoice
            wavex = self.battlechoice.buttons[-2].x * variables.width
            # the height of the wave
            waveamp = (self.battlechoice.buttons[-2].height()*3/4) * 0.5
            
            wavelen = self.battlechoice.buttons[-2].width()*3/4
            wavey = self.battlechoice.buttons[-2].y*variables.height-waveamp
            loopbuffer = play_sound.all_tones[variables.settings.soundpack].loopbuffers[0]
            skiplen = (len(loopbuffer)/25)/wavelen
            drawwave(loopbuffer, skiplen, wavex, wavey, waveamp, wavelen, (255,255,255))

            # draw the scale above battlechoice
            firstscalex = self.battlechoice.buttons[-1].x * variables.width
            scalex = firstscalex
            scaley = self.battlechoice.buttons[-1].y*variables.height - self.battlechoice.buttons[-1].height()
            scaleintervals = play_sound.scales[self.getscalename()]
            for i in scaleintervals:
                tpic = getTextPic(str(i)+" ", variables.gettextsize(), variables.WHITE)
                variables.screen.blit(tpic, (scalex, scaley))
                scalex += tpic.get_width()
            variables.dirtyrects.append(Rect(firstscalex, scaley, scalex-firstscalex, self.battlechoice.buttons[-1].height()))

        elif self.state == "lose" or self.state == "win":

            # button
            if self.state == "win":
                conttext = "continue"
                # button coordinates are multipliers of screen width and height
                continuebutton = Button(1 / 2, b/h, conttext, variables.gettextsize()/h)
                continuebutton.iscentered = True
                continuebutton.draw(True)
            else:
                self.retrychoice.draw()

            # text
            text = None
            if self.state == "lose":
                text = variables.font.render("you lost...", 0, variables.WHITE)
            else:
                text = variables.font.render("you win!", 0, variables.WHITE)
            textscaled = sscale(text)
            variables.screen.blit(textscaled, [w / 2 - (textscaled.get_width() / 2), h / 2])
            self.drawscoretable()

        
        elif self.state == "exp" or self.state == "got exp":
            text = "continue"
            # continue button
            continuebutton = Button(1 / 2, b/h, text, variables.gettextsize()/h)
            continuebutton.iscentered = True
            continuebutton.draw(True)

            # text
            text = variables.font.render("EXP", 0, variables.WHITE)
            textscaled = sscale(text)
            exppos = [w / 2 - (textscaled.get_width() / 2), h / 3]
            variables.screen.blit(textscaled, exppos)
            variables.dirtyrects.append(Rect(exppos[0], exppos[1], textscaled.get_width(), textscaled.get_height()))
            text = variables.font.render("Lv " + str(classvar.player.lv()), 0, variables.WHITE)
            textscaled = sscale(text)
            lvpos = [0, h / 3 - textscaled.get_height()]
            variables.screen.blit(textscaled, lvpos)
            variables.dirtyrects.append(Rect(lvpos[0], lvpos[1], textscaled.get_width(), textscaled.get_height()))

            # exp bar
            percentofbar = stathandeling.percentoflevel(p.exp)
            barrect = Rect(0, h/2, w*percentofbar, h/18)
            variables.screen.fill(variables.BLUE, barrect)
            variables.dirtyrects.append(barrect)

            # level up text
            if self.state == "got exp" and stathandeling.explv(self.oldexp) < stathandeling.explv(self.newexp):
                text = variables.font.render(variables.settings.bearname + "'s dance level increased.", 0, variables.GREEN)
                textscaled = sscale(text)
                coordinates = [w / 2 - (textscaled.get_width() / 2), h / 3 - textscaled.get_height()]
                variables.screen.blit(textscaled,
                                      coordinates)
                variables.dirtyrects.append(Rect(coordinates[0], coordinates[1], textscaled.get_width(), textscaled.get_height()))

            self.drawscoretable()

        # player health bar
        playermaxh = stathandeling.max_health(p.lv())
        healthh = h * (1 / 18)
        enemyhealthh = h * (1 / 50)
        
        epich = enemypic_height()
        epicw = self.enemy.animation.pic_width(epich)
        percenthealthlefte = self.enemy.health / stathandeling.max_health(self.enemy.lv)
        healthbarcolor = variables.GREEN
        if p.health != playermaxh:
            percenthealthleft = p.health / playermaxh
            barrect = Rect(w - epicw, epich, epicw * (1 - percenthealthleft),enemyhealthh)
            variables.screen.fill(healthbarcolor, barrect)
            variables.dirtyrects.append(barrect)
        if not percenthealthlefte == 1:
            barrect = Rect(0, h-healthh, w*(1-percenthealthlefte), healthh)
            variables.screen.fill(healthbarcolor, barrect)
            variables.dirtyrects.append(barrect)
        # if they did not miss any in the last beatmap
        if (self.damage_multiplier > variables.perfect_value and self.state == "attacking"):
            punscaled = variables.font.render("PERFECT!", 0, variables.WHITE)
            ptext = sscale_customfactor(punscaled, 1.5)
            coordinates = [(variables.width / 2) - (ptext.get_width() / 2) - epich, variables.getpadypos() - ptext.get_height() - 10]
            variables.screen.blit(ptext, coordinates)
            variables.dirtyrects.append(Rect(coordinates[0], coordinates[1], ptext.get_width(), ptext.get_height()))
Пример #22
0
    def drawnormalmode(self, tempo):
        width = variables.notewidth()
        height = self.height(tempo)
        borderwidth = 0 # zero signals pygame to draw it filled in
        

        # subtract height to y because the pos is the bottom of the rectangle
        if self.ison:
            color = variables.notes_colors[self.screenvalue]
        else:
            color = variables.GREY

        darkercolor = []
        for rgbval in color:
            if rgbval -50 < 0:
                darkercolor.append(0)
            else:
                darkercolor.append(rgbval-50)

        end_height = variables.height / 80

        p = self.pos

        topendy = p[1] - height - end_height
        endx = p[0] - width/8
        endwidth = width * 1.25
        middleofnoteoffset = 0

        if self.scoremultiplier != 1:
            borderwidth = int(end_height/2)
            middleofnoteoffset = int((width-int(width*0.7))/2)
            width = int(width * 0.7)
            
        
        def drawend(x, y, color, endshape):
            if endshape == "square":
                pygame.draw.rect(variables.screen, color,
                                 [x, y, endwidth, end_height], borderwidth)
            elif endshape == "triangle":
                fourthx = endwidth/4
                centery = y + end_height/2
                pygame.draw.polygon(variables.screen, color,
                                    [[x, centery], [x+fourthx, y], [x+3*fourthx, y],
                                     [x+endwidth, centery], [x+3*fourthx, y+end_height], [x+fourthx, y+end_height]], borderwidth)
            elif endshape == "round":
                pygame.draw.ellipse(variables.screen, color,
                                    [x, y, endwidth, end_height], borderwidth)

        def drawmid(y, mheight, color):
            x = p[0] + middleofnoteoffset
            if mheight > 0:
                if self.shape() == "square":
                    pygame.draw.rect(variables.screen, color, [x, y, width, mheight], borderwidth)
                elif self.shape() == "triangle":
                    fourthx = width/4
                    pygame.draw.polygon(variables.screen, color,
                                        [[x+3*fourthx, y], [x+fourthx, y], [x, y + mheight/2],
                                         [x+fourthx, y+mheight], [x+3*fourthx, y+mheight], [x+width, y + mheight/2]],
                                        borderwidth)
                elif self.shape() == "round":
                    ellipsesurface = pygame.Surface((width, mheight), pygame.SRCALPHA)
                    pygame.draw.ellipse(ellipsesurface, color,
                                        [0, -20, width, mheight+40],
                                        borderwidth)
                    variables.screen.blit(ellipsesurface, [x, y])

                # draw the multiplier if it is not 1
                if self.scoremultiplier != 1:
                    scorepic = getTextPic("x" + str(self.scoremultiplier), variables.gettextsize(), variables.WHITE)
                    variables.screen.blit(scorepic, (x, y + mheight/2 - variables.gettextsize()/2))
                    
                # now draw pink line if it is an accidental
                if self.accidentalp:
                    pygame.draw.rect(variables.screen, variables.PINK, [x+width/4, y, width/2, mheight]) # don't change border width
                

        # subtract height from y because the pos is the bottom of the rectangle
        # the first case is if the note is currently being played
        if self.ison and variables.getpadypos() > p[1] - height and self.beginning_score != None and self.end_score == None:
            mheight = height+1 - (p[1]-variables.getpadypos())
            drawmid(p[1]-height-1, mheight, darkercolor)
            drawend(endx, topendy, color, self.secondshape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, mheight+end_height*20))

        # second case is if the note was interrupted in the middle and counted as a miss
        elif not self.height_offset == 0:
            if (height - self.height_offset > 1):
                drawmid(p[1]-height-1, height+1-self.height_offset, darkercolor)
                drawend(endx, topendy, color, self.secondshape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, height+end_height+1+self.height_offset+20))

        # third case is if it has either been missed or has not been played yet (normal draw)
        elif self.beginning_score == None or self.beginning_score == variables.miss_value or self.end_score == variables.miss_value:
            #middle of note
            drawmid(p[1]-height-1, height+2-end_height, darkercolor)
            #top
            drawend(endx, topendy, color, self.secondshape())
            #bottom of note
            drawend(endx, p[1]-end_height, color, self.shape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, height+end_height+2+20))
Пример #23
0
 def height(self, tempo):
     return self.duration * (variables.getpadypos() / variables.settings.notes_per_screen)
Пример #24
0
 def height(self, tempo):
     return self.duration * (variables.getpadypos() / variables.settings.notes_per_screen)
Пример #25
0
    def draw(self):
        if self.current_beatmap < len(self.beatmaps):
            currentb = self.beatmaps[self.current_beatmap]
        else:
            currentb = None
        h = variables.height
        w = variables.width
        b = h * 13 / 16
        p = classvar.player
        # background
        if variables.battle_background != None:
            variables.screen.blit(variables.battle_background, (0, 0))
        else:
            variables.screen.fill(variables.BLACK)

        # draw enemy first
        if self.state != "dance":
            self.enemy.animation.reset()  # if not dancing, use first frame

        # draw enemy
        self.enemy.animation.draw_topright(variables.screen, enemypic_height())

        playerpicandrect = self.getplayerpicandrect()

        # draw the player
        if self.state == "dance":
            # draw the special animation behind the player
            self.drawspecialmove()
        variables.screen.blit(playerpicandrect[0], playerpicandrect[1])

        if currentb != None:
            # now draw the combo if necessary
            self.drawcombo()

        if self.enemy.animation.updatealwaysbattle:
            self.updatescreenforenemy()

        # draw beatmap
        if self.state == "dance":
            self.beatmaps[self.current_beatmap].draw()
        elif self.state == "attacking":
            self.beatmaps[self.current_beatmap].draw_pads()

        if self.state == "choose":
            # enemy name
            enemyname = variables.font.render("LV " + str(self.enemy.lv) + " " + self.enemy.name + " appears!", 0,
                                              variables.WHITE)
            enemynamescaled = sscale(enemyname)
            variables.screen.blit(
                enemynamescaled, [w / 2 - (enemynamescaled.get_width() / 2), h / 2])

            self.battlechoice.draw()

            # draw the wave above the battlechoice
            wavex = self.battlechoice.buttons[-2].x * variables.width
            # the height of the wave
            waveamp = (self.battlechoice.buttons[-2].height()*3/4) * 0.5

            wavelen = self.battlechoice.buttons[-2].width()*3/4
            wavey = self.battlechoice.buttons[-2].y*variables.height-waveamp
            loopbuffer = play_sound.all_tones[variables.settings.soundpack].loopbuffers[0]
            skiplen = (len(loopbuffer)/25)/wavelen
            drawwave(variables.screen, loopbuffer, skiplen, wavex,
                     wavey, waveamp, wavelen, (255, 255, 255))

            # draw the scale above battlechoice
            firstscalex = self.battlechoice.buttons[-1].x * variables.width
            scalex = firstscalex
            scaley = self.battlechoice.buttons[-1].y*variables.height - self.battlechoice.buttons[-1].height()
            scaleintervals = play_sound.scales[self.getscalename()]
            for i in scaleintervals:
                tpic = getTextPic(str(i)+" ", variables.gettextsize(), variables.WHITE)
                variables.screen.blit(tpic, (scalex, scaley))
                scalex += tpic.get_width()
            variables.dirtyrects.append(Rect(firstscalex, scaley, scalex-firstscalex, self.battlechoice.buttons[-1].height()))

        elif self.state == "lose" or self.state == "win":

            # button
            if self.state == "win":
                conttext = "continue"
                # button coordinates are multipliers of screen width and height
                continuebutton = Button(1 / 2, b/h, conttext, variables.gettextsize()/h)
                continuebutton.iscentered = True
                continuebutton.draw(True)
            else:
                self.retrychoice.draw()

            # text
            text = None
            if self.state == "lose":
                text = variables.font.render("you lost...", 0, variables.WHITE)
            else:
                text = variables.font.render("you win!", 0, variables.WHITE)
            textscaled = sscale(text)
            variables.screen.blit(textscaled, [w / 2 - (textscaled.get_width() / 2), h / 2])

        
        elif self.state == "exp" or self.state == "got exp":
            text = "continue"
            # continue button
            continuebutton = Button(1 / 2, b/h, text, variables.gettextsize()/h)
            continuebutton.iscentered = True
            continuebutton.draw(True)

            # text
            text = variables.font.render("EXP", 0, variables.WHITE)
            textscaled = sscale(text)
            exppos = [w / 2 - (textscaled.get_width() / 2), h / 3]
            variables.screen.blit(textscaled, exppos)
            variables.dirtyrects.append(Rect(exppos[0], exppos[1], textscaled.get_width(), textscaled.get_height()))
            text = variables.font.render("Lv " + str(classvar.player.lv()), 0, variables.WHITE)
            textscaled = sscale(text)
            lvpos = [0, h / 3 - textscaled.get_height()]
            variables.screen.blit(textscaled, lvpos)
            variables.dirtyrects.append(Rect(lvpos[0], lvpos[1], textscaled.get_width(), textscaled.get_height()))

            # exp bar
            percentofbar = stathandeling.percentoflevel(p.exp)
            barrect = Rect(0, h/2, w*percentofbar, h/18)
            variables.screen.fill(variables.BLUE, barrect)
            variables.dirtyrects.append(barrect)

            # level up text
            if self.state == "got exp" and stathandeling.explv(self.oldexp) < stathandeling.explv(self.newexp):
                text = variables.font.render(variables.settings.bearname + "'s dance level increased.", 0, variables.GREEN)
                textscaled = sscale(text)
                coordinates = [w / 2 - (textscaled.get_width() / 2), h / 3 - textscaled.get_height()]
                variables.screen.blit(textscaled,
                                      coordinates)
                variables.dirtyrects.append(Rect(coordinates[0], coordinates[1], textscaled.get_width(), textscaled.get_height()))

            self.drawscoretable()

        # player health bar
        playermaxh = stathandeling.max_health(p.lv())
        healthh = h * (1 / 18)
        enemyhealthh = h * (1 / 50)
        
        epich = enemypic_height()
        epicw = self.enemy.animation.pic_width(epich)
        percenthealthlefte = self.enemy.health / stathandeling.max_health(self.enemy.lv)
        healthbarcolor = variables.GREEN
        if p.health != playermaxh:
            percenthealthleft = p.health / playermaxh
            barrect = Rect(w - epicw, epich, epicw * (1 - percenthealthleft),enemyhealthh)
            variables.screen.fill(healthbarcolor, barrect)
            variables.dirtyrects.append(barrect)
        if not percenthealthlefte == 1:
            barrect = Rect(0, h-healthh, w*(1-percenthealthlefte), healthh)
            variables.screen.fill(healthbarcolor, barrect)
            variables.dirtyrects.append(barrect)
        # if they did not miss any in the last beatmap
        if (self.damage_multiplier > variables.perfect_value and self.state == "attacking"):
            punscaled = variables.font.render("PERFECT!", 0, variables.WHITE)
            ptext = sscale_customfactor(punscaled, 1.5)
            coordinates = [(variables.width / 2) - (ptext.get_width() / 2) - epich, variables.getpadypos() - ptext.get_height() - 10]
            variables.screen.blit(ptext, coordinates)
            variables.dirtyrects.append(Rect(coordinates[0], coordinates[1], ptext.get_width(), ptext.get_height()))

        if self.state == "lose" or self.state == "win" or self.state == "exp" or self.state == "got exp":
            self.drawscoretable()
Пример #26
0
 def notepos(self, note):
     notetime = self.notetime()
     ypos = (notetime - note.time) * (variables.getpadypos() / variables.settings.notes_per_screen) + variables.getpadypos()
     return [Beatmap.screenvaltoxpos(note.getscreenvalue()), ypos]
Пример #27
0
    def drawnormalmode(self, tempo):
        width = variables.notewidth()
        height = self.height(tempo)
        borderwidth = 0 # zero signals pygame to draw it filled in

        being_playedp = self.ison and variables.getpadypos() > self.pos[1] - height and self.beginning_score != None and self.end_score == None

        # subtract height to y because the pos is the bottom of the rectangle
        color = variables.GREY
        if self.ison:
            if being_playedp:
                color = variables.darken(variables.notes_colors[self.screenvalue], 10)
            else:
                color = variables.darken(variables.notes_colors[self.screenvalue], 40)
            

        darkercolor = variables.darken(color, 50)

        end_height = variables.getpadheight()


        topendy = self.pos[1] - height - end_height
        endx = self.pos[0] - width/8
        endwidth = width * 1.25
        middleofnoteoffset = 0

        if self.scoremultiplier != 1:
            borderwidth = variables.get_border_width()
            middleofnoteoffset = int((width-int(width*0.7))/2)
            width = int(width * 0.7)
            
        
        def drawend(x, y, color, endshape):
            if endshape == "square":
                pygame.draw.rect(variables.screen, color,
                                 [x, y, endwidth, end_height], borderwidth)
            elif endshape == "triangle":
                fourthx = endwidth/4
                centery = y + end_height/2
                pygame.draw.polygon(variables.screen, color,
                                    [[x, centery], [x+fourthx, y], [x+3*fourthx, y],
                                     [x+endwidth, centery], [x+3*fourthx, y+end_height], [x+fourthx, y+end_height]], borderwidth)
            elif endshape == "round":
                pygame.draw.ellipse(variables.screen, color,
                                    [x, y, endwidth, end_height], borderwidth)

        def drawmid(y, mheight, color):
            x = self.pos[0] + middleofnoteoffset
            if mheight > 0:
                if self.shape() == "square":
                    pygame.draw.rect(variables.screen, color, [x, y, width, mheight], borderwidth)
                elif self.shape() == "triangle":
                    fourthx = width/4
                    pygame.draw.polygon(variables.screen, color,
                                        [[x+3*fourthx, y], [x+fourthx, y], [x, y + mheight/2],
                                         [x+fourthx, y+mheight], [x+3*fourthx, y+mheight], [x+width, y + mheight/2]],
                                        borderwidth)
                elif self.shape() == "round":
                    ellipsesurface = pygame.Surface((width, mheight), pygame.SRCALPHA)
                    pygame.draw.ellipse(ellipsesurface, color,
                                        [0, -20, width, mheight+40],
                                        borderwidth)
                    variables.screen.blit(ellipsesurface, [x, y])

                # draw the multiplier if it is not 1
                if self.scoremultiplier != 1:
                    scorepic = getTextPic("x" + str(self.scoremultiplier), variables.gettextsize(), variables.WHITE)
                    variables.screen.blit(scorepic, (x, y + mheight/2 - variables.gettextsize()/2))
                    
                # now draw pink line if it is an accidental
                if self.accidentalp:
                    pygame.draw.rect(variables.screen, variables.PINK, [x+width/4, y, width/2, mheight]) # don't change border width
                

        # subtract height from y because the pos is the bottom of the rectangle
        # the first case is if the note is currently being played
        if being_playedp:
            mheight = height+1 - (self.pos[1]-variables.getpadypos())
            drawmid(self.pos[1]-height-1, mheight, darkercolor)
            drawend(endx, topendy, color, self.secondshape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, mheight+end_height*20))

        # second case is if the note was interrupted in the middle and counted as a miss
        elif not self.height_offset == 0:
            if (height - self.height_offset > 1):
                drawmid(self.pos[1]-height-1, height+1-self.height_offset, darkercolor)
                drawend(endx, topendy, color, self.secondshape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, height+end_height+1+self.height_offset+20))

        # third case is if it has either been missed or has not been played yet (normal draw)
        elif self.beginning_score == None or self.beginning_score == variables.miss_value or self.end_score == variables.miss_value:
            #middle of note
            drawmid(self.pos[1]-height-1, height+2-end_height, darkercolor)
            #top
            drawend(endx, topendy, color, self.secondshape())
            #bottom of note
            drawend(endx, self.pos[1]-end_height, color, self.shape())
            variables.dirtyrects.append(pygame.Rect(endx, topendy-10, endwidth, height+end_height+2+20))