Exemple #1
0
def run_game():
    pygame.init()
    stg = Settings()
    stats = GameStats(stg)
    screen = pygame.display.set_mode((stg.screen_width, stg.screen_height))
    clock = pygame.time.Clock()
    pygame.display.set_caption("Super Moon Attack")
    #bg_color = stg.bg_color
    p_shot = Group()
    aliens_1 = Group()
    #initialize player character
    sb = Scoreboard(stg, screen, stats)
    button = Button(stg, screen)
    player = PlayerShip(stg, screen)

    gf.create_alien_1(stg, screen, aliens_1)

    while True:
        clock.tick(stg.fps)
        #screen.blit(stg.bg_img, stg.bg_rect)
        gf.bg_scroll(stg, screen)

        ctrl.check_events(stg, screen, stats, player, p_shot, sb, button, aliens_1)
        gf.alien_1_random(stg, screen, aliens_1)


        gf.p_shot_update(stg, screen, player, p_shot, aliens_1, stats)
        '''break order and put enemies at end. *arg will recieve list'''
        gf.update_aliens(stg, screen, player, p_shot, stats, sb, aliens_1)
        player.update()
        gf.update_aliens_1(stg, screen, aliens_1)
        sb.prep_score()
        gf.update_screen(stg, screen, player, p_shot, aliens_1, sb)
Exemple #2
0
 def __init__(self, settings=None):
     """
     Class constructor.
     """
     if settings is None:
         settings = Settings()
     self.settings = settings
Exemple #3
0
 def __init__(self, *args, **kwargs):
     self._db = kwargs["db"]
     self.uptime = datetime.datetime.utcnow()
     self.settings = Settings()
     self.self_bot = False
     self._intro_displayed = False
     self.auto_restart = True
     self.last_added = None
     super().__init__(*args, **kwargs)
Exemple #4
0
 def __init__(self, settings=None):
     """
     Class constructor.
     :param settings: (Settings) MOPA's settings object.
     """
     if settings is None:
         # the option of a settings rather than a new instance of Settings is given
         # in order to allow custom settings later on.
         settings = Settings()
     self.settings = settings
Exemple #5
0
 def __init__(self, parent=None, settings=None):
     """
     Class constructor.
     :param parent: (QWidget) any widget from Qt5 parent to this dialog.
     :param settings: (Settings) MOPA's settings database manager.
     """
     super(ObservationWidget, self).__init__(parent)
     self.setupUi(self)
     self.parent = parent
     self.settings = settings if settings is not None else Settings()
     self._obsManager = ObservationsManager(self.settings)
     self.refresh(obsList=[])
Exemple #6
0
    def pause_menu(self):
        """
        This is the pause menu that controls the user actions
        """
        running = True

        screen_title = Text(self.screen)
        unpause_button = SquareButton(self.screen, 100, 200, 150, 50, WHITE,
                                      LIGHT_GREY, text_button_stop_pause)
        settings_button = SquareButton(self.screen, 100, 300, 150, 50, WHITE,
                                       LIGHT_GREY, text_button_settings)
        back_to_menu = SquareButton(self.screen, 100, 400, 150, 50, WHITE,
                                    LIGHT_GREY, text_button_back_to_menu)
        quit_button = SquareButton(self.screen, 100, 500, 150, 50, WHITE,
                                   LIGHT_GREY, text_button_exit)

        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        running = False
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if unpause_button.is_hover():
                        running = False
                    if settings_button.is_hover():
                        Settings(self.screen)
                    if back_to_menu.is_hover():
                        Menu(self.screen)
                    if quit_button.is_hover():
                        pygame.quit()
                        quit()

            screen_title.draw_text_raw(text_game_paused,
                                       540,
                                       100,
                                       50,
                                       font_color=WHITE)
            unpause_button.draw_button()
            settings_button.draw_button()
            back_to_menu.draw_button()
            quit_button.draw_button()

            pygame.display.update()
def ran_game():
    #初始化游戏并且创建一屏幕个对象
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Alien Invasion")
    #设置背景颜色
    bg_color = (ai_settings.bg_color)
    #创建一艘飞船
    ship = Ship(ai_settings, screen)

    #开始游戏的主循环
    while True:
        #监视键盘和鼠标事件
        game_functions.check_events(ship)
        ship.update()
        #每次循环都重绘制屏幕
        game_functions.update_screen(ai_settings, screen, ship)
Exemple #8
0
    def pause_menu(self):
        running = True

        unpause_button = SquareButton(self.screen, 100, 200, 150, 50, WHITE,
                                      LIGHT_GREY, text_button_stop_pause)
        settings_button = SquareButton(self.screen, 100, 300, 150, 50, WHITE,
                                       LIGHT_GREY, text_button_settings)
        back_to_menu = SquareButton(self.screen, 100, 400, 150, 50, WHITE,
                                    LIGHT_GREY, text_button_back_to_menu)
        quit_button = SquareButton(self.screen, 100, 500, 150, 50, WHITE,
                                   LIGHT_GREY, text_button_exit)
        quit_popup = Popup(self.screen)

        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if unpause_button.is_hover():
                        running = False
                    if settings_button.is_hover():
                        Settings(self.screen)
                    if back_to_menu.is_hover():
                        Menu(self.screen)
                    if quit_button.is_hover():
                        quit_popup.yes_no_popup(
                            "Are you sure you want to quit?")
                        pygame.quit()
                        quit()

            unpause_button.draw_button()
            settings_button.draw_button()
            back_to_menu.draw_button()
            quit_button.draw_button()

            pygame.display.flip()
Exemple #9
0
 def __init__(self):
     self.set = Settings()
     self.Accset = AccountSettings()
Exemple #10
0
        lin = dem.height() - 1
    elif lin < 0:
        lin = 0
    y, x = dem.pixelToCoordinates(col, lin)
    z = dem.bands()[col][lin]
    sensorY, sensorX, sensorZ = sensor['coordinates']
    dx, dy, dz = x - sensorX, y - sensorY, z - sensorZ
    if dem.isGeographic():
        # the more appropriate conversion would be a geodesic line - curve geometry
        dx = np.deg2rad(dx) * Enums.EARTH_RADIUS
        dy = np.deg2rad(dy) * np.pi * Enums.EARTH_RADIUS / 180
    azimuth = np.rad2deg(np.arctan2(np.sqrt(dy**2 + dz**2), dx))
    zenith = np.rad2deg(np.arctan2(dx, dz))
    om = ObservationsManager()
    om.addObservation(azimuth, zenith, sensor['id'])
    return zenith, azimuth


s = Settings()
sm = SensorsManager(s)
sensor = sm.getSensorFromId(3)
om = ObservationsManager(s)

demPath = ".dev/testing_data/sf-23-z-b/rj_srtm_90m_sirgas2000-23s.tif"
dem = RasterLayer(demPath)
generateObsAtPixel(dem, sensor, 102, 101)
obs = om.getObservationsFromSensor(3)[17]
sf = ShooterFinder(s)
sf.findShooter(1, sensor, obs, dem)
print(om.getObservationsFromSensor(3))
Exemple #11
0
"""
@version: v1.0
@author: Bryan.Lan
@contact: [email protected]
@site: http://http://blog.csdn.net/weixin_36650524
@time: 2017/11/9 15:07
"""

import os
import time
import unittest
from Settings.settings import Settings
import HTMLTestRunner

set = Settings()
base_path = os.path.dirname(os.path.realpath(__file__))
print(base_path)
case_dir = base_path + r"\TestCase"
result_path = base_path + r"\result"

def Create_Suite():
    """
    创建测试套件
    :return:
    """
    testunit = unittest.TestSuite()
    # discover方法定义
    discover = unittest.defaultTestLoader.discover(case_dir, pattern=set.caseName, top_level_dir=None)

    print(discover)
Exemple #12
0
from Domain.student import Student_Validator
from UI.gui import GUI
from Service.studentService import studentService
from Service.assignmentService import assignmentService
from Domain.grade import Grade_Validator
from Service.gradeService import gradeService
from Service.UndoService import UndoService
from Repository.Repository import Repository, RepositoryException
from Repository.studentTextRepo import StudentTextRepo
from Repository.assignmentTextRepo import AssignmentTextRepo
from Repository.gradeTextRepo import GradeTextRepo
from Settings.settings import Settings

if __name__ == '__main__':
    filename = "Settings/settings.properties"
    repoSetUp = Settings(filename)
    # we set up the settings class
    student_repo, assignment_repo, grade_repo = None, None, None

    # we prepare the repo by selecting the mode in the settings properties
    # in case there is an error with initializing the repo, than we print a message and exit the program
    # in order to prevent further crashes
    try:
        if repoSetUp.get_mode == "inmemory":
            student_repo = Repository()
            assignment_repo = Repository()
            grade_repo = Repository()
        elif repoSetUp.get_mode == "textfiles":
            student_repo = StudentTextRepo(repoSetUp.get_studentfile)
            assignment_repo = AssignmentTextRepo(repoSetUp.get_assignmentfile)
            grade_repo = GradeTextRepo(repoSetUp.get_gradesfile)