Example #1
0
	def __init__(self) -> None:
		self.sprites: List[sprite.Sprite] = []
		self.sprites.append(sprite.Button((200, 100), 'Load'))
		self.sprites.append(sprite.Button((800, 300), '1 Player'))
		self.sprites.append(sprite.Button((800, 400), '2 Players Hot Seat'))
		self.sprites.append(sprite.Button((800, 500), '3 Players Hot Seat'))
		self.sprites.append(sprite.Button((800, 600), '4 Players Hot Seat'))
Example #2
0
File: scene.py Project: 1m188/snake
    def prepare(self):
        width = self.screen.get_width()
        height = self.screen.get_height()

        # 标题信息
        self.infoLab = sprite.Label("Snake", pygame.font.Font(None, 60), (0, 0, 0))
        self.infoLab.center = (width / 2, height / 4)

        # 经典模式
        self.classicBtn = sprite.Button("Classic Mode", pygame.font.Font(None, 40), (0, 0, 0))
        self.classicBtn.centerx = width / 2
        self.classicBtn.top = height / 2

        preCtrl = self.classicBtn
        intervl = (height - self.classicBtn.top) / 4

        # 无尽模式
        self.endlessBtn = sprite.Button("Endless Mode", pygame.font.Font(None, 40), (0, 0, 0))
        self.endlessBtn.centerx = width / 2
        self.endlessBtn.top = preCtrl.top + intervl
        preCtrl = self.endlessBtn

        # 最高分
        self.highestScoreBtn = sprite.Button("Highest Score", pygame.font.Font(None, 40), (0, 0, 0))
        self.highestScoreBtn.centerx = width / 2
        self.highestScoreBtn.top = preCtrl.top + intervl
        preCtrl = self.highestScoreBtn

        # 退出
        self.exitBtn = sprite.Button("Exit", pygame.font.Font(None, 40), (0, 0, 0))
        self.exitBtn.centerx = width / 2
        self.exitBtn.top = preCtrl.top + intervl
        preCtrl = self.exitBtn
Example #3
0
File: scene.py Project: 1m188/snake
    def prepare(self):
        width = self.screen.get_width()
        height = self.screen.get_height()

        # 最高分标题
        self.highestScoreLab = sprite.Label("Highest Score", pygame.font.Font(None, 60), (0, 0, 0))
        self.highestScoreLab.center = (width / 2, height / 4)

        interval = height / 2 / (len(Mode) + 1)
        preCtrl = pygame.rect.Rect(0, height / 2 - interval, 1, 1)

        # 按照模式的种类一行一行往下展示
        self.scoreLabList = []
        for mode in Mode:
            scoreLab = sprite.Label(f"{mode.value} Mode: {HighestScore.score[mode.value]}", pygame.font.Font(None, 40), (0, 0, 0))
            scoreLab.centerx = width / 2
            scoreLab.top = preCtrl.top + interval
            preCtrl = scoreLab
            self.scoreLabList.append(scoreLab)

        # 返回按钮
        self.backBtn = sprite.Button("Back To Start", pygame.font.Font(None, 40), (0, 0, 0))
        self.backBtn.centerx = width / 2
        self.backBtn.top = preCtrl.top + interval
        preCtrl = self.backBtn
Example #4
0
File: scene.py Project: 1m188/snake
    def prepare(self):
        width = self.screen.get_width()
        height = self.screen.get_height()

        # 游戏结束标题
        self.gameoverLab = sprite.Label("Game Over", pygame.font.Font(None, 60), (0, 0, 0))
        self.gameoverLab.center = (width / 2, height / 4)

        # 分数
        self.scoreLab = sprite.Label(f"Your score is: {self.score}", pygame.font.Font(None, 40), (0, 0, 0))
        self.scoreLab.centerx = width / 2
        self.scoreLab.top = height / 2

        preCtrl = self.scoreLab
        interval = (height - self.scoreLab.top) / (4 if self.isNewHighestScore else 3)

        # 当前模式
        self.modeLab = sprite.Label(f"Your mode is: {self.mode.value}", pygame.font.Font(None, 40), (0, 0, 0))
        self.modeLab.centerx = width / 2
        self.modeLab.top = preCtrl.top + interval
        preCtrl = self.modeLab

        # 最高分提醒
        if self.isNewHighestScore:
            self.newHighestScoreLab = sprite.Label("New Highest Score!", pygame.font.Font(None, 40), (0, 0, 0))
            self.newHighestScoreLab.centerx = width / 2
            self.newHighestScoreLab.top = preCtrl.top + interval
            preCtrl = self.newHighestScoreLab

        # 返回按钮
        self.backBtn = sprite.Button("Back To Start", pygame.font.Font(None, 40), (0, 0, 0))
        self.backBtn.centerx = width / 2
        self.backBtn.top = preCtrl.top + interval
        preCtrl = self.modeLab
Example #5
0
	def __init__(self) -> None:
		self.terr = terrain.Terrain()
		self.civs: List[civ.Civ] = []
		self.active_civ = 0
		self.perspective_civ = 0
		self.pointer = sprite.Pointer()
		self.selected_sprite: Optional[sprite.Sprite] = None
		self.selected_index: int
		self.targets: List[sprite.Sprite] = []
		self.menu: List[sprite.Sprite] = []
		self.control: List[sprite.Sprite] = [ sprite.Button((400, 75), 'End turn') ]
		self.pushed_button: Optional[sprite.Button] = None
		self.animating_sprite: Optional[sprite.Sprite] = None
		self.message = ''
		self.history: List[Action] = []
		self.history_pos = 0
		self.display_mode = True
		self.replay = False
Example #6
0
	def select_sprite(self, s: sprite.Sprite, index: int) -> None:
		self.move_pointer(s.pos)
		self.selected_sprite = s
		self.selected_index = index
		if index >= 0 and not s.exhausted:
			# Make target sprites
			self.targets.clear()
			tt = targeter.Targeter(self.terr, self.civs)
			move_targets = tt.get_move_targets(
				s.tile,
				self.terr,
				s.move_range(),
				s.can_fly() or self.civs[self.active_civ].wood >= 1,
				s.can_fly(),
				)
			for targ in move_targets:
				t: sprite.Sprite = sprite.TargetMove()
				t.set_tile_and_pos(targ.tile, self.terr)
				self.targets.append(t)
			attack_targets = tt.get_attack_targets(
				s.tile,
				self.terr,
				s.attack_range(),
				self.active_civ,
				s.can_shoot(),
				)
			for targ in attack_targets:
				t = sprite.TargetAttack()
				t.set_tile_and_pos(targ.tile, self.terr)
				self.targets.append(t)

			# Make menu buttons
			self.menu.clear()
			y = 75
			for opt in s.menu_options(self.terr.tile(s.tile)):
				self.menu.append(sprite.Button((125, y), opt))
				y += 75