class UI(BaseUI): TITLE = "7 Days to Rigel" FONT = ROOT_DIR / 'assets' / 'terminal.png' SPLASH_SCREEN = SplashScreen( title=f"v{__version__}. Developed for 7DRL'19.", # title_art=SPLASH_SCREEN, logo=ROOT_DIR / 'assets' / '7dtr_logo.png', credits=CREDITS, title_color=Color(129, 162, 190), credits_color=Color(197, 200, 198), credits_format_colors=CREDITS_COLORS) def __init__(self, game: BaseGame, default_bg_color: Color = None, default_fg_color: Color = None, default_void_color: Color = None): super().__init__(game, default_bg_color, default_fg_color, default_void_color, main_menu_options=OrderedDict(( (' Start Game ', (Color(204, 102, 102), self.start_game)), (' Options ', (Color(197, 200, 198), print)), (' Exit ', (Color(197, 200, 198), self.close_window)), )))
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() fw, fh = 500, 650 frame = GUIRect((w - fw) * 0.5, (h - fh) * 0.5, fw, fh, Color(250, 150, 150)) frame.draw(canvas, **kwargs) head = GUIText("Help", w * 0.5, (h - fh) * 0.5 + 30, 30, Color(100, 100, 100)) head.draw(canvas, **kwargs) text = GUIText( "Welcome to 3d Tetris! This game is all about\n" "procrastination, so please don't play it if there is\n" "something you really needs to get done.\n\n" "If somehow this is your first Tetris experience\n" "then you're probably an alien, so welcome to earth!\n" "The game rules are simple: you earn points by filling\n" "up surfaces. When a surface is completely full, the\n" "blocks of this surface will disappear, and you will earn\n" "points. If you fill up 2 or more surfaces with a single\n" "block, you'll get even more points. The game difficulty\n" "level also affects the amount of points you'll get.\n\n" "> Use the arrow keys to move blocks around.\n" "> Use the w, s keys to rotate blocks in the pitch axis.\n" "> Use the a, d keys to rotate blocks in the yaw axis.\n" "> Use the q, e keys to rotate blocks in the roll axis.\n" "> Use the z, x keys to rotate the cameras.\n" "> Use the space key to speed up the falling blocks\n" "> Use the p key to pause the game.\n\n" "TIP1: motion and rotation are always relative to\n" "current camera angle.\n" "TIP2: rotate the camera A LOT, it's really useful!\n\n" "<ENTER> to return...", w * 0.5, (h + fh) * 0.5 - 300, 14, Color(100, 100, 100)) text.draw(canvas, **kwargs)
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() wf, hf = 240, 80 frame = GUIRect((w - wf) * 0.5, (h - hf) * 0.5, wf, hf, Color(250, 150, 150)) frame.draw(canvas, **kwargs) text = GUIText("Pause", w * 0.5, h * 0.5, 50, Color(100, 100, 100)) text.draw(canvas, **kwargs)
def __init__(self): super().__init__( Rect(0, Window.Instance.height * 2 / 3, Window.Instance.width, Window.Instance.height / 3)) self.set_color(Color(40, 40, 40, 230)) self.title = Label( Loader.get_font("ALoveOfThunder.ttf", 200).render("WEAPONS", False, (180, 10, 0))) self.title.constraints.add_width_constraint( RelativeMultConstraint(0.25)) self.title.constraints.add_height_constraint(AspectConstraint()) self.title.constraints.add_x_constraint(RelativeMultConstraint(1)) self.title.constraints.add_y_constraint(RelativeMultConstraint(1)) self.add_element(self.title) self.weaponListContainer = Container() self.weaponListContainer.set_color(Color(35, 35, 35, 230)) self.weaponListContainer.constraints.add_x_constraint( RelativeMultConstraint(1)) self.weaponListContainer.constraints.add_y_constraint( RelativeMultConstraint(1.15)) self.weaponListContainer.constraints.add_width_constraint( RelativeMultConstraint(1)) self.weaponListContainer.constraints.add_height_constraint( RelativeMultConstraint(0.85)) self.add_element(self.weaponListContainer) for i, weapon in enumerate(Weapons): weapon_img = weapon.HoldImage.copy() pygame.draw.rect(weapon_img, (255, 0, 0), weapon_img.get_rect(), 1) weapon_btn = Button(weapon_img) x = i // 2 * 0.05 + 0.15 y = 0.5 if i % 2 == 1 else 0.1 weapon_btn.constraints.add_x_constraint(RelativeAddConstraint(x)) weapon_btn.constraints.add_y_constraint(RelativeAddConstraint(y)) weapon_btn.constraints.add_width_constraint( RelativeMultConstraint(0.045)) weapon_btn.constraints.add_height_constraint(AspectConstraint()) weapon_btn.set_click_function(self.set_id_wrapper(i)) self.weaponListContainer.add_element(weapon_btn) self.explodeTimeLabel = Label( Loader.get_font("ALoveOfThunder.ttf", 200).render("3", False, (180, 10, 0))) self.explodeTimeLabel.constraints.add_x_constraint( RelativeAddConstraint(0.05)) self.explodeTimeLabel.constraints.add_y_constraint( RelativeAddConstraint(0.1)) self.explodeTimeLabel.constraints.add_width_constraint( RelativeMultConstraint(0.035)) self.explodeTimeLabel.constraints.add_height_constraint( AspectConstraint()) self.weaponListContainer.add_element(self.explodeTimeLabel) self.lastSelectedWeaponID = 0
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() wf, hf = 450, 110 frame = GUIRect((w - wf) * 0.5, (h - hf) * 0.5, wf, hf, Color(250, 150, 150)) frame.draw(canvas, **kwargs) head = GUIText("Game Over", w * 0.5, (h - hf) * 0.5 + 35, 40, Color(100, 100, 100)) head.draw(canvas, **kwargs) cont = GUIText("<ENTER> to continue...", w * 0.5, (h - hf) * 0.5 + 85, 15, Color(100, 100, 100)) cont.draw(canvas, **kwargs)
def __init__(self, obj): self.obj = obj obj.parent = self self.dir = None self.sleeping = False self.sleep_const = 2 self.sleep_time = self.sleep_const self.speed = 3 self.obj.mesh.faces[0].material = Color.Material(Color.white) self.obj.mesh.faces[1].material = Color.Material(Color.black) self.obj.mesh.faces[2].material = Color.Material(Color.red) self.obj.mesh.faces[3].material = Color.Material(Color.black) all_targets.append(self)
def show_colors(self): self.init() print("Fonts:", pygame.font.get_fonts()) n = len(Color.colors()) self.view.set_size(n+1, 1) for i in range(n): self.view.render_tile(i + 1, 0, Color.colors()[i]) self.view.show() while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()
def __init__(self, game: BaseGame, default_bg_color: Color = None, default_fg_color: Color = None, default_void_color: Color = None): super().__init__(game, default_bg_color, default_fg_color, default_void_color, main_menu_options=OrderedDict(( (' Start Game ', (Color(204, 102, 102), self.start_game)), (' Options ', (Color(197, 200, 198), print)), (' Exit ', (Color(197, 200, 198), self.close_window)), )))
def __init__(self, rect=None): Element.__init__(self) self._color = Color(255, 255, 255, 0) if rect is not None: self._rect = rect self._image: pygame.Surface = None self.apply_rect() self._elements: List[Element] = []
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() fw, fh = 440, 305 frame = GUIRect((w - fw) * 0.5, (h - fh) * 0.5, fw, fh, Color(250, 150, 150)) frame.draw(canvas, **kwargs) head = GUIText("Welcome to 3d Tetris!", w * 0.5, (h - fh) * 0.5 + 30, 30, Color(100, 100, 100)) head.draw(canvas, **kwargs) text = GUIText( "Current game level is %d (%s).\n\n" "<S> Start the game\n" "<1> Change game level to 1\n" "<2> Change game level to 2\n" "<3> Change game level to 3\n" "<H> Display help (please read if\n" " it's your first time playing!)" % (self._game.level() + 1, StartGame.LEVEL_STR[self._game.level()]), w * 0.5, (h - fh) * 0.5 + 180, 18, Color(100, 100, 100)) text.draw(canvas, **kwargs)
def __init__(self, location: Pointlike): super().__init__( name="you", description="What a sexy beast you are.", location=location, # ToDo available_actions={'FIX ME!'}, blocks_movement=False, blocks_sight=False, acts=True, character=ord('@'), color=Color(255, 255, 255))
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() fw, fh = 500, 200 frame = GUIRect((w - fw) * 0.5, (h - fh) * 0.5, fw, fh, Color(250, 150, 150)) frame.draw(canvas, **kwargs) head_space = 35 head = GUIText("New High Score!", w * 0.5, (h - fh) * 0.5 + head_space, 30, Color(100, 100, 100)) head.draw(canvas, **kwargs) time_l = GUIText(self._text, w * 0.5, h * 0.5, 20, Color(100, 100, 100), GUIText.CENTER) time_l.draw(canvas, **kwargs) cont_space = 35 cont = GUIText("Enter your name and then <ENTER> to continue...", w * 0.5, (h + fh) * 0.5 - cont_space, 15, Color(100, 100, 100)) cont.draw(canvas, **kwargs)
def draw(self, canvas, **kwargs): w, h = canvas.winfo_width(), canvas.winfo_height() fw, fh = 500, 400 frame = GUIRect((w - fw) * 0.5, (h - fh) * 0.5, fw, fh, Color(250, 150, 150)) frame.draw(canvas, **kwargs) head_space = 35 head = GUIText("High Scores", w * 0.5, (h - fh) * 0.5 + head_space, 30, Color(100, 100, 100)) head.draw(canvas, **kwargs) table_space = 205 rank = "\n".join(str(i) for i in range(1, 11)) names = "\n".join(self._table.names()) time = "\n".join(self._table.times()) score = "\n".join(str(s) for s in self._table.scores()) rank_l = GUIText(rank, (w - fw) * 0.5 + 30, (h - fh) * 0.5 + table_space, 18, Color(100, 100, 100), GUIText.RIGHT) names_l = GUIText(names, (w - fw) * 0.5 + 115, (h - fh) * 0.5 + table_space, 18, Color(100, 100, 100), GUIText.LEFT) time_l = GUIText(time, w * 0.5, (h - fh) * 0.5 + table_space, 18, Color(100, 100, 100), GUIText.CENTER) score_l = GUIText(score, (w + fw) * 0.5 - 30, (h - fh) * 0.5 + table_space, 18, Color(100, 100, 100), GUIText.RIGHT) rank_l.draw(canvas, **kwargs) names_l.draw(canvas, **kwargs) time_l.draw(canvas, **kwargs) score_l.draw(canvas, **kwargs) cont_space = 35 cont = GUIText("<ENTER> to continue...", w * 0.5, (h + fh) * 0.5 - cont_space, 15, Color(100, 100, 100)) cont.draw(canvas, **kwargs)
game_exit = False """********************************************************************************** ********************************************************************************** ***********************************MAIN******************************************* ********************************************************************************** **********************************************************************************""" walk_speed = 1.5 run_speed = 3 crouch_speed = 0.8 crouching = False mouse_sensivity = 0.15 room = Importer.Import_obj("Room.obj", (0, 0, 0)) room.Set_material(Color.Material(Color.grey)) room.collider = None room.rigidbody = None room.mesh.faces[0].material = Color.Material(Color.white) room.mesh.faces[1].material = Color.Material(Color.white) room.mesh.faces[2].material = Color.Material(Color.grey) room.mesh.faces[3].material = Color.Material(Color.grey) room.mesh.faces[4].material = Color.Material(Color.grey) room.mesh.faces[5].material = Color.Material(Color.dark_grey) room.mesh.faces[6].material = Color.Material(Color.dark_grey) room.mesh.faces[7].material = Color.Material(Color.dark_grey) room.mesh.faces[8].material = Color.Material(Color.dark_grey) for i in range(0, len(Mesh.all_faces)):
# ↪ Images BACKGROUND: str = "img/bg/bg.jpg" GAME_SPRITESHEET: str = "img/game_spritesheet.png" NAME_SPRITESHEET: str = "img/names_spritesheet.png" # ↪ Datafiles SPRITES_DATAFILE: str = "sprites.json" CITIES_DATAFILE: str = "city_names.json" CITY_POS_DATAFILE: str = "cities.json" CONNECTIONS_DATAFILE: str = "connections.json" # Literals --------------------------------------------------------------------| # ↪ Keys SPRITE_ICON: str = "sprite_icon" SPRITE_ID: str = "sprite_id" POSITION: str = "position" CONNECTION: str = "connection" CONNECTION_LOOP: str = "loop" # Parameters ------------------------------------------------------------------| # ↪ Graphics CITYSPACE_SIZE: int = 50 CITYTEXT_WIDTH: int = 150 CITYTEXT_HEIGHT: int = 24 CITYTEXT_UPSHIFT: int = 10 LINE_WIDTH: int = 3 # Colors ----------------------------------------------------------------------| # ↪ Graphics LINE_COLOR: Color = Color(160, 255, 255)
def Kill(self): self.obj.mesh.faces[0].material = Color.Material(Color.very_dark_grey) self.obj.mesh.faces[1].material = Color.Material(Color.black) self.obj.mesh.faces[2].material = Color.Material(Color.dark_red) self.obj.mesh.faces[3].material = Color.Material(Color.black)
((0, 0, 0), (0, 0, 0), (0, 0, 0)))) SHAPE5 = np.array((((0, 1), (0, 0)), ((1, 1), (0, 1)))) SHAPE6 = np.array((((1, 0), (1, 1)), ((0, 0), (1, 0)))) SHAPE7 = np.array( (((0, 0, 0), (0, 0, 0), (0, 0, 0)), ((0, 0, 0), (1, 1, 0), (0, 1, 1)), ((0, 0, 0), (0, 0, 0), (0, 0, 0)))) SHAPE8 = np.array( (((0, 0, 0), (0, 0, 0), (0, 0, 0)), ((0, 1, 0), (0, 1, 0), (0, 0, 0)), ((0, 1, 0), (0, 1, 0), (0, 0, 0)))) SHAPE9 = np.array( (((0, 0, 0), (0, 0, 0), (0, 0, 0)), ((0, 0, 0), (1, 1, 0), (0, 1, 1)), ((0, 0, 0), (0, 0, 0), (0, 0, 0)))) SHAPE10 = np.array( (((0, 0, 0), (0, 0, 0), (0, 0, 0)), ((0, 1, 0), (0, 1, 0), (0, 1, 0)), ((0, 0, 0), (0, 1, 0), (0, 0, 0)))) SHAPES = (SHAPE1, SHAPE2, SHAPE3, SHAPE4, SHAPE5, SHAPE6, SHAPE7, SHAPE8, SHAPE9, SHAPE10) COLORS = (Color(255, 102, 102), Color(255, 178, 102), Color(255, 255, 102), Color(178, 255, 102), Color(102, 255, 102), Color(102, 255, 178), Color(102, 255, 255), Color(102, 178, 255), Color(102, 102, 255), Color(178, 102, 255), Color(255, 102, 255), Color(255, 102, 178), Color(192, 192, 192))
def Reset(self): self.obj.mesh.faces[0].material = Color.Material(Color.white) self.obj.mesh.faces[1].material = Color.Material(Color.black) self.obj.mesh.faces[2].material = Color.Material(Color.red) self.obj.mesh.faces[3].material = Color.Material(Color.black)