def prep_ironmans(self): self.ironmans = Group() for ironman_number in range(self.stats.ironman_left): ironman = Ironman(self.ai_settings, self.screen) ironman.rect.x = 10 + ironman_number * ironman.rect.width ironman.rect.y = 10 self.ironmans.add(ironman)
def main(): #starting the game and setting up variables for classes imported to main pygame.init() ai_settings=Settings() screen=pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height)) ironman=Ironman(ai_settings,screen) ultron=Ultron(ai_settings, screen,ironman) stats = Gamestats(ai_settings) sb=Scoreboard(ai_settings,screen,stats) # play music as long as the game is being played music=Music("theme.mp3.mp3",7,0) #setting up the group bullets=Group() ultrons=Group() missiles=Group() #naming the game pygame.display.set_caption("ultron invasion") #displaying background image and drawing it on screen background=pygame.transform.scale(pygame.image.load("background.bmp"),(ai_settings.screen_width,ai_settings.screen_height)) bgrect=background.get_rect() #drawing the start button for the game play_button = Button(ai_settings, screen, "suit-up") #keeping the game looping and running using the while loop while True: gf.check_events(ai_settings,screen,stats,sb,play_button,ironman,ultrons,bullets,music) if stats.game_active: #update the screen ironman.update() bullets.update() gf.update_ultrons(ai_settings,screen,stats,sb,ironman,ultrons,bullets,missiles) gf.update_missiles_ironman_collison(ai_settings,screen,stats,sb,ironman,ultrons,bullets,missiles) gf.update_bullets(ai_settings,screen,stats,sb,ironman,ultrons,bullets) gf.update_missile(ai_settings,screen,stats,sb,ironman,ultrons,missiles) gf.update_screen(ai_settings, screen, stats,sb,ironman,ultrons,background,bgrect,bullets,play_button,missiles)
def start(self): def vision_watcher_unthread(): self.START_TIME_ABSOLUTE = time.time() self.START_TIME = pd.to_datetime(time.time()) for ticker_str in self.watcher.sub(): ticker_dict = self.__build_ticker_dict(ticker_str) # 刷新self.ticker self.__evaluate_ticker(ticker_dict) # 向self.__ticker_list_temp添加ticker数据 self.__ticker_list_temp.append(ticker_dict) # to: 运行数据处理的主要逻辑 # 更新历史数据 # 更新现在的tickers等 self.__perform_data_logic() Ironman.thread(target=vision_watcher_unthread)
# encoding: utf-8 from OKCoin.OkcoinFutureAPI import OKCoinFuture from config import Config from ironman import Ironman ## sprint = lambda string: Ironman.sprint(speaker="交易商", string=string) to_datetime = Ironman.to_datetime now_datetime = Ironman.now_datetime thread = Ironman.thread sign = Ironman.sign get = Ironman.httpGet post = Ironman.httpPost class Broker(object): def __init__(self): sprint("交易商正在链接Restful API。") self.rest = OKCoinFuture(Config()) self.API_URL = "https://www.okex.com/api/v1" self.TRADE_URL = "/api/v1/future_trade.do?" config = Config() self.API_KEY = config.api_key self.SECRET = config.secret_key sprint("交易商准备完毕。") sprint("可以开始交易了。")