예제 #1
0
class Game:
    def __init__(self):
        self.name="Test"
        self.map_size=[60,40]
        self.map=Map(self.map_size)
        self.window_size=[1400,800]
        self.fullscreen=False
        self.window=Window(self.name,self.window_size,self.fullscreen,text_color=RED)
        self.player=Player(borders=[0,0]+self.map.size)
        #print(self.map.grid)

    def __call__(self):
        self.show()
        while self.window.open:
            self.window.check()
            #self.getInput()
            self.update()
            self.show()

    def update(self):
        self.map.update()
        self.player.update(self.map,self.window)
        keys=self.window.press()
        if keys[K_RSHIFT]:
            self.map.camera.size[0]+=1
            self.map.camera.size[1]+=1
        if keys[K_LSHIFT]:
            self.map.camera.size[0]-=1
            self.map.camera.size[1]-=1

    def show(self):
        self.window.clear()
        #print("self.player.position:",self.player.position)
        self.map.show(self.player.position,self.player.size,self.window)
        self.window.print(text="Player's position: "+str(self.player.position),position=[10,10])
        self.window.flip()
예제 #2
0
window = Window(size=[800, 800], set=False)
window.open = True
window.text_color = BLACK
window.background_color = BLACK
window.text_size = 30
#window.size=[900,20]

results = []
i = 0
number = 10000
display = False

while i < number and window.open:
    i += 1
    game = Othello(window, display)
    game()
    winner_side = (game.state + 1) % 2
    results.append(winner_side)
    message = "Results for " + str(
        i) + " tests:\n" + "White victories: " + str(
            results.count(0)) + "\n" + "Black victories: " + str(
                results.count(1)) + "\n"
    window.print(str(message), size=[50, 20])
    window.flip()
    print(message)

message = "Results for " + str(i) + " tests:\n" + "White victories: " + str(
    results.count(0)) + "\n" + "Black victories: " + str(
        results.count(1)) + "\n"
print(message)