From: pin Date: Thu, 18 Feb 2010 13:10:44 +0000 (+0000) Subject: Ajout playinscreen.py X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/commitdiff_plain/2b9d34e4fd258c988ccb7796d918fdf40f4d9937?ds=sidebyside Ajout playinscreen.py git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@39 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py new file mode 100755 index 0000000..f65d8e5 --- /dev/null +++ b/src/app/widgets/playingscreen.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +""" +Écran de jeu MinWii : +bandes arc-en-ciel représentant un clavier. + +$Id$ +$URL$ +""" +import pygame +# TODO : positionner cette constance en fonction de la résolution d'affichage +BORDER = 5 # 5px + +class _PlayingScreenBase(object) : + def __init__(self, distinctNotes=[]) : + """ + distinctNotes : notes disctinctes présentes dans la chanson + triées du plus grave au plus aigu. + """ + self.distinctNotes = distinctNotes + self.keyboardRects = [] + self._initRects() + self.drawColumns() + + + def _initRects(self) : + """ création des espaces réservés pour + afficher les colonnes. + """ + ambitus = self.distinctNotes[-1].midi - self.distinctNotes[0].midi + if ambitus <= 12 : + keyboardLength = 8 + else : + keyboardLength = 11 + + screen = pygame.display.get_surface() + + # taille de la zone d'affichage utile (bordure autour) + dispWidth = screen.get_width() - 2 * BORDER + dispHeight = screen.get_height() - 2 * BORDER + + columnWidth = int(round(float(dispWidth) / keyboardLength)) + + rects = [] + for i in range(keyboardLength) : + upperLeftCorner = (i*columnWidth + BORDER, BORDER) + rect = pygame.Rect(upperLeftCorner, (columnWidth, dispHeight)) + rects.append(rect) + + self.keyboardRects = rects + + + def drawColumns(self) : + pass + + def highLightColumn(self) : + pass + + +class SongPlayingScreen(_PlayingScreenBase) : + + def __init__(self, song) : + super(SongPlayingScreen, self).__init__(song.) + self.song = song + + + +class Column(pygame.sprite.Sprite) : + + def __init__(self, color) : + pass \ No newline at end of file