def __init__(self, cpu, instructions, data): self.cpu = cpu self.instr = [] self.data = [] self.main_memory_access_time = 3 self.__load_instructions(instructions) self.__load_data(data) self.sb = score_board.ScoreBoard(self)
def setUp( self ): self.expected_x = 125 self.expected_y = 250 self.expected_width = 400 self.expected_height = 200 self.board = score_board.ScoreBoard( self.expected_x, self.expected_y, self.expected_width, self.expected_height ) return
def __init__(self, width, height): self.mWidth = width self.mHeight = height score_width = 80 score_height = 40 score_x = self.mWidth / 2 - score_width / 2 score_y = 40 self.mScoreBoard = score_board.ScoreBoard( score_x, score_y, score_width, score_height) wall_size = 10 self.mLeftWall = wall.Wall(0, 0, wall_size, self.mHeight) self.mRightWall = wall.Wall( self.mWidth-wall_size, 0, wall_size, self.mHeight) self.mTopWall = wall.Wall(0, 0, self.mWidth, wall_size) self.mBottomWall = wall.Wall( 0, self.mHeight-wall_size, self.mWidth, wall_size) paddle_margin = 20 paddle_width = 20 paddle_height = 100 paddle_speed = self.mHeight / 1.25 self.mLeftPaddle = paddle.Paddle(self.mLeftWall.getRightX() + paddle_margin, self.mHeight / 2 - paddle_height / 2, paddle_width, paddle_height, paddle_speed, self.mTopWall.getBottomY(), self.mBottomWall.getY()) self.mLeftPaddle.setColor(( 0, 89, 179)) self.mRightPaddle = paddle.Paddle(self.mRightWall.getX() - paddle_margin - paddle_width, self.mHeight / 2 - paddle_height / 2, paddle_width, paddle_height, paddle_speed, self.mTopWall.getBottomY(), self.mBottomWall.getY()) self.mRightPaddle.setColor((196, 2, 51)) size = 20 self.mBall = ball.Ball(size, self.mLeftWall.getRightX(), self.mRightWall.getX(), self.mTopWall.getBottomY(), self.mBottomWall.getY(), self.mLeftPaddle.getRightX(), self.mRightPaddle.getX()) self.serveBall() self.mBall.setLeftPaddleY( self.mLeftPaddle.getY(), self.mLeftPaddle.getBottomY()) self.mBall.setRightPaddleY( self.mRightPaddle.getY(), self.mRightPaddle.getBottomY()) return
x = 800 y = 800 # set the x,y coordinates for the checkpoints (separated by horizontal and vertical road checkpoints) checks_hor = [[width - 50, height + 197], [width - 346, height - 72], [width - 100, height - 316], [width + 300, height - 120]] checks_ver = [[width - 339, height + 100], [width - 441, height - 150], [width + 125, height - 170], [width + 373, height + 100]] # create the player object player = Car(width + 150, height + 230, 310, 0) # Player info name = "" time = 0 # Time of round (divide by frame_rate to get time in seconds) scores = score_board.ScoreBoard("score_board.txt") # set the phase for checking the checkpoints check_phase = 1 # create an instance for the game over function gameover = GameOver.Game_Over() # Buttons play_button = button.Button(pygame.image.load("graphics/play_button.png"), screen_width // 2, screen_height // 2 + 120, 400, 160) exit_button = button.Button(pygame.image.load("graphics/exit_button.png"), screen_width // 2, screen_height // 2 + 320, 400, 160) okay_button = button.Button(pygame.image.load("graphics/okay_button.png"),