コード例 #1
0
ファイル: button.py プロジェクト: TrueCryer/pyDarts
 def __init__(self, loc, image_master, image_covered):
     self.image_master = pygame.image.load(get_res_path(image_master))
     self.image_covered = pygame.image.load(get_res_path(image_covered))
     self.image = self.image_master
     self.loc = loc
     self.rect = self.image.get_rect()
     self.rect.center = self.loc
コード例 #2
0
ファイル: game.py プロジェクト: TrueCryer/pyDarts
 def __init__(self, turn_number, screen, game_surface, score_surface, score):
     # top-level properties
     self.screen = screen
     self.game_surface = game_surface
     self.score_surface = score_surface
     self.score = score
     # self properties
     self.turn_number = turn_number
     self.active_dart = Dart()
     self.darts_remain = 2  # one is already active
     self.dropped_darts = []
     self.font = pygame.font.Font(get_res_path('EraserRegular.ttf'), 32)
     self.splash_font = pygame.font.Font(
         get_res_path('EraserRegular.ttf'), 52
     )
コード例 #3
0
ファイル: dart.py プロジェクト: TrueCryer/pyDarts
  You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. """

""" dart.py

Includes class Dart to manage darts in game
"""

import random

import pygame

from utils import get_res_path


IMG_DART = pygame.image.load(get_res_path('dart.png'))
IMG_DART_DROPPED = pygame.image.load(get_res_path('dart_dropped.png'))

IN_GAME = 0
IN_FLY = 1
DROPPED = 2

FPS = 30


class Dart(pygame.sprite.Sprite):

    def __init__(self):
        self.image = IMG_DART
        self.base = (0, 0)
        self.loc = (0., 0.)
コード例 #4
0
ファイル: game.py プロジェクト: TrueCryer/pyDarts
from pygame.locals import QUIT, MOUSEBUTTONDOWN, KEYDOWN, K_ESCAPE

from utils import get_res_path

from dart import Dart
from score import Score
from hiscores import HiScores
from button import Button

from globals import CLR_RED


FPS = 30

IMG_DARTSBOARD = pygame.image.load(get_res_path('dartsboard.png'))
IMG_DARTSBOARD_OFF = pygame.image.load(get_res_path('dartsboard_off.png'))
IMG_CHALKBOARD = pygame.image.load(get_res_path('chalkboard.png'))


class GameInterruptedError(BaseException):
    pass


class GameEscapedError(BaseException):
    pass


class Game(object):

    def __init__(self, screen):
コード例 #5
0
ファイル: hiscores.py プロジェクト: TrueCryer/pyDarts
 def __init__(self):
     self.font = pygame.font.Font(get_res_path('EraserRegular.ttf'), 24)
     self.scores = []
     for i in range(10):
         self.scores.append({'name': 'Unknown', 'score': 0})
     self.read()
コード例 #6
0
ファイル: score.py プロジェクト: TrueCryer/pyDarts
 def __init__(self):
     self.total = 0
     self.drops = []
     self.font = pygame.font.Font(get_res_path('EraserRegular.ttf'), 24)