Exemplo n.º 1
0
 def add_wave(self, amp, central_frequency, phase):
     wave = Wave(amp,
                 central_frequency,
                 phase,
                 stop=self.meas_time,
                 sampling_frequency=self.sampfreq)
     self.wavefreqs.append(central_frequency)
     param_array = np.array([amp, central_frequency, phase, -1, -1])
     self.wave_array = np.sum([self.wave_array, wave.get_wave()], axis=0)
     del wave
Exemplo n.º 2
0
    def __init__(self, file):
        with open(file, "r") as f:
            self.cash, self.height, self.width = [int(x) for x in f.readline().split(" ")]
            self.waves = SinglyList()
            self.waves_num = 0
            for line in iter(f.readline, ""):
                self.waves.add_head(Wave(*[int(x) for x in line.split(" ")]))
                self.waves_num += 1
        self.game_over = False
        self.turn_number = 0
        self.non_plants = 0

        self.deck = Stack()

        for i in range(100):
            self.deck.push(random.randint(1, 5))

        self.board = [] #SinglyList Next points to the next array.
                        #Data points to the list that stores the queues

        for i in range(self.height):
            self.board.append([]) #;
            for z in range(self.width):
                self.board[i].append(Queue())
                print(self.board[i][z])
Exemplo n.º 3
0
    def add_spread_wave(self, amp, central_frequency, phase, freqspread,
                        bunchsize):
        param_array = np.array(
            [amp, central_frequency, phase, freqspread, bunchsize])
        freqs = np.random.normal(
            central_frequency, freqspread,
            size=bunchsize)  #frequency Gaussian distribution

        for freq in freqs:
            wave = Wave(amplitude=amp,
                        frequency=freq,
                        phase=phase,
                        stop=self.meas_time,
                        sampling_frequency=self.sampfreq)
            self.wavefreqs.append(freq)
            self.wave_array = np.sum(
                [self.wave_array, wave.get_wave()], axis=0)
        del wave
Exemplo n.º 4
0
    def __init__(self, root):

        self._root = root
        self._gameRunning = False
        # TODO: probably move these into a Wave object?
        self._currWaveNumber = 0
        self._currWave = None
        self._path = None

        self._createGUIElements(root)

        self.grid = self._createGridOfCells()

        # Read path info from a file and highlight the path on the screen.
        self.readPathInfo()

        # TODO: should support multiple paths eventually.
        # TODO: _wave should be related to _currWave
        self._wave = Wave("wave1.txt", self._path, self._canv)
Exemplo n.º 5
0
 def __init__(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [
             int(x) for x in f.readline().split(' ')
         ]
         self.waves = LinkedList()
         self.waves_num = 0
         for line in iter(f.readline, ''):
             self.waves.add(Wave(*[int(x) for x in line.split(' ')]))
             self.waves_num += 1
Exemplo n.º 6
0
 def scanWaveforms(self):
     from wave import Wave
     thread = QtCore.QThread(self)
     thread.worker = Wave(Foo.readConfig('options')['music_folder'])
     thread.worker.moveToThread(thread)
     thread.started.connect(thread.worker.processScan)
     thread.worker.finished.connect(thread.quit)
     thread.worker.finished.connect(thread.worker.deleteLater)
     thread.finished.connect(thread.deleteLater)
     thread.finished.connect(self.tree.initUI)
     thread.start()
Exemplo n.º 7
0
def main():
    #    prob = Advection()
    prob = Wave()
    #    prob = Hopf()

    print('\nLO\n')
    dg = Dg(50, 4, prob, C=0.05, method='lo')
    dg.run()
    print('\nHO\n')
    dg = Dg(50, 4, prob, C=0.05, method='ho')
    dg.run()
    print('\nTVD\n')
    dg = Dg(50, 4, prob, C=0.05, method='tvd')
    dg.run()
Exemplo n.º 8
0
 def __init__(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [
             int(x) for x in f.readline().split('')
         ]
         self.waves = LinkedList()
         self.waves_num = 0
         for line in iter(f.readline, ''):
             self.waves.add(Wave(*[int(x) for x in line.split('')]))
             self.waves_num += 1
     self.board = 0
     self.game_over = False
     self.turn_number = 0
     self.powerup_cards = 0
Exemplo n.º 9
0
 def init(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [int(x) for x in f.readline().split(' ')]
         self.waves = LinkedList()
         self.waves_num = 0
         for line in iter(f.readline, ' '):
             self.waves.add(Wave(*[int(x) for x in line.split(' ')]))
             self.waves_num += 1
     self.board = [[Queue() for x in range(self.width)] for y in range(self.height)]
     self.game_over = False
     self.turn_number = 0
     self.nonplants = 0
     self.deck_powerup_cards = Stack()
     for i in range(100):
         self.deck_powerup_cards.push(Card(random.randint(0, 6)))
Exemplo n.º 10
0
 def __init__(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [int(x) for x in f.readline().split(' ')]
         self.waves = LinkedList()
         self.waves_num = 0
         for line in iter(f.readline, ''):
             self.waves.add_head(Wave(*[int(x) for x in line.split(' ')]))
             self.waves_num += 1
     self.board = [[Queue() for x in range(self.width)] for x in range(self.height)]
     self.gameOver = False
     self.turnNumber = 0
     self.nonPlants = 0
     self.powerDeck = Stack()
     for i in range(100):
         self.powerDeck.push(Card(random.randint(0,5)))
Exemplo n.º 11
0
    def generate_wave_list(self):
        waves = []  # list of waves

        for e in self.midi_events:
            if e.status == 144:  # press event
                start_time = e.timestamp
                end_time = next(
                    x for x in self.midi_events
                    if x.status == 128 and x.data1 == e.data1).timestamp
                duration = (end_time - start_time) / 1000  # from ms to s
                frequency = midi.midi_to_frequency(e.data1)
                velocity = e.data2 / 127  # vel ranges from 1 to 127

                waves.append(Wave(frequency, dur=duration, vol=velocity))

        return waves
Exemplo n.º 12
0
    def __init__(self, file):
        with open(file, "r") as f:
            self.cash, self.height, self.width = [
                int(x) for x in f.readline().split(" ")
            ]
            self.waves = LinkedList()
            self.waves_num = 0
            for line in f:
                self.waves.add(Wave(*[int(x) for x in line.split(" ")]))
                self.waves_num += 1

        self._board = [[_Queue() for __ in range(self.width)]
                       for _ in range(self.height)]
        self.game_over = False
        self._turn = 0
        self.non_plants = 0
        self._power_ups = Game._init_powerups()
Exemplo n.º 13
0
 def __init__(self, file):
     with open(file, 'r') as f:
         #Cash, height, width split by a space
         self.cash, self.height, self.width = [int(x) for x in f.readline().split(' ')]
         self.waves = LinkedList()
         self.wave_num = 0
         
         for line in iter(f.readline, ''):
             self.waves.add(Wave(*[int(x) for x in line.split(' ')]))
             self.wave_num = 1
     
     #Board
     self.board = Queue()    #size? (self.width and self.height)
     self.board = [][]       #?---
     
     #
     self.game_over = False
     self.turn = 0
     self.num_nonplants = 0
     self.powerup_cards = Stack()
Exemplo n.º 14
0
 def __init__(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [int(x) for x in f.readline().split(' ')]
         self.waves = LinkedList()
         self.waves_num = 0 #This is the amount of waves left, not current wave number
         for line in iter(f.readline, ''):
             self.waves.add(Wave(*[int(x) for x in line.split(' ')]))
             self.waves_num += 1
     self.board=Queue() #Incomplete, supposed to create Queue of width and height of read-in file
     addme={}
     for row in range(self.height):
         for column in range(self.width):
             addme.update({(row,column):None})
     self.board.enqueue(addme)
     self.gameover=False
     self.turn=0
     self.nonplants_amt=0
     self.deck=Stack() #Completish, please bugtest, supposed to initialize powerup card deck
     for i in range(100):
         self.deck.push(random.randint(0,5))
Exemplo n.º 15
0
def test_wave():
    print(style(HEADER, "---Start: Wave Class checking---"))
    erron = 0
    o = Wave(1, 2, 3)
    if (hasattr(o, "wave_num") & hasattr(o, "row") & hasattr(o, "num")) == 0:
        print(
            style(WARNING, "You didn't initialize your ") +
            style(UNDERLINE, "Wave") + end_style() +
            style(WARNING, " class properly"))
        return
    if o.wave_num != 1:
        erron += 1
        print(
            style(FAIL, "You didn't initialize"
                  " the wave's ") + style(UNDERLINE, "wave_num") +
            end_style() + style(FAIL, " to ") + style(
                BOLD,
                "the value that's passed into the __init__ function for the 1st argument"
            ) + end_style())
    if o.row != 2:
        erron += 1
        print(
            style(FAIL, "You didn't initialize"
                  " the wave's ") + style(UNDERLINE, "row") + end_style() +
            style(FAIL, " to ") + style(
                BOLD,
                "the value that's passed into the __init__ function for the 2nd argument"
            ) + end_style())
    if o.num != 3:
        erron += 1
        print(
            style(FAIL, "You didn't initialize"
                  " the wave's ") + style(UNDERLINE, "num") + end_style() +
            style(FAIL, " to ") + style(
                BOLD,
                "the value that's passed into the __init__ function for the 3rd argument"
            ) + end_style())
    if erron == 0:
        print(style(OKGREEN, "Wave Class, perfect."))
Exemplo n.º 16
0
 def __init__(self, file):
     with open(file, 'r') as f:
         self.cash, self.height, self.width = [
             int(x) for x in f.readline().split(' ')
         ]
         self.waves = []
         self.waves_num = 0
         for line in iter(f.readline, ''):
             self.waves.append(Wave(*[int(x) for x in line.split(' ')]))
             self.waves_num += 1
         self.waves.sort(key=lambda x: x.wave_num)
     self.board = []
     for y in range(self.height):
         row = []
         for x in range(self.width):
             row.append(Queue())
         self.board.append(row)
     self.on = True
     self.turn = 0
     self.nonplants = 0
     self.deck = Stack()
     for x in range(100):
         card = Card(random.randint(1, 5))
         self.deck.push(card)
Exemplo n.º 17
0
    def delete_wave(self, amp, freqs, phase):
        if type(freqs) != type(self.wavefreqs):
            wave = Wave(amplitude=amp,
                        frequency=freqs,
                        phase=phase,
                        stop=self.meas_time,
                        sampling_frequency=self.sampfreq)
            self.wave_array = np.subtract(self.wave_array, wave.get_wave())
            self.wavefreqs.remove(freqs)

        if type(freqs) == type(self.wavefreqs):
            for freq in freqs:
                wave = Wave(amplitude=amp,
                            frequency=freq,
                            phase=phase,
                            stop=self.meas_time,
                            sampling_frequency=self.sampfreq)
                self.wave_array = np.subtract(self.wave_array, wave.get_wave())
                self.wavefreqs.remove(freq)
Exemplo n.º 18
0
def main():
    pygame.init()
    settings = Settings()
    screen = pygame.display.set_mode(
        (settings.screen_width, settings.screen_height))
    # icon = pygame.image.load('image/icon.png')
    # pygame.display.set_icon(icon)
    pygame.display.set_caption("水波")

    font1 = pygame.freetype.Font(r'C:\Windows\Fonts\msyh.ttc', 36)
    ant = Ant(screen, settings, (400, 300), 10)

    fps = 50
    fclock = pygame.time.Clock()

    # 开始游戏主循环
    while True:
        # 监听键盘和鼠标事件
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit(0)  # 此处必须带有参数0
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    sys.exit(0)
            elif event.type == pygame.MOUSEBUTTONDOWN:
                pos = event.pos
                w = Wave(screen, settings, pos)

        screen.fill(settings.bg_color)
        try:
            w.spread()
            w.blitme()
        except Exception as e:
            pass
        ant.move()
        ant.blitme()
        pygame.display.update()
        fclock.tick(fps)
Exemplo n.º 19
0
import pygame
from wave import Wave
import math

pygame.init()

SIZE = WIDTH, HEIGHT = 800, 600
FPS = 60
screen = pygame.display.set_mode(SIZE)
pygame.display.set_caption("Springy water")

clock = pygame.time.Clock()
is_running = True

wave = Wave()


def on_click(mx, my):
    closest_distance = -1
    closest_point = None
    for p in wave.wave_points:
        distance = math.fabs(mx - p.pos.x)
        if closest_distance == -1:
            closest_point = p
            closest_distance = distance
        elif distance <= closest_distance:
            closest_point = p
            closest_distance = distance

    closest_point.pos.y = my
Exemplo n.º 20
0
def test_game(file=None):
    print(style(HEADER, "---Start: Game Class checking---"))
    if file == None:
        print(
            style(
                WARNING,
                "You need to pass in a valid example file to check the Game Class"
            ))
        return
    erron = 0
    o = Game(file)
    w = Wave(0, 0, 0)
    for r in range(o.height):
        for c in range(o.width):
            if (type(o.board[r][c]).__name__ != "Queue"):
                print(style(FAIL, "Your Board is not initialized properly"))
                return
    o.board[0][0].enqueue(Non_Plant())
    if (hasattr(o, "is_nonplant")) == 1:
        UT_game.is_nonplant(o)
    else:
        print(style(WARNING, "No is_nonplant method in class"))
        erron += 1
    o.board[1][1].enqueue(Plant())

    if (hasattr(o, "is_plant")) == 1:
        erron += UT_game.is_plant(o)
    else:
        print(style(WARNING, "No is_plant method in class"))
        erron += 1
    old_cash = o.cash

    if (hasattr(o, "is_nonplant") & hasattr(o, "remove")) == 1:
        o.remove(0, 0)
        UT_game.remove(o, old_cash)
    else:
        print(style(WARNING, "No remove method in class"))
        erron += 1

    if (hasattr(o, "place_plant") & hasattr(o, "is_plant")) == 1:
        UT_game.place_plant(o)
    else:
        erron += 1
        print(style(WARNING, "No place_plant method in class"))

    if (hasattr(o, "place_nonplant")) == 1:
        o.place_nonplant(0)
        UT_game.place_nonplant(o, 0)
    else:
        erron += 1
        print(style(WARNING, "No place_nonplant method in class"))

    if (hasattr(o, "place_wave")) == 1:
        UT_game.place_wave()
    else:
        erron += 1
        print(style(WARNING, "No place_wave method in class"))

    if (hasattr(o, "plant_turn")) == 1:
        UT_game.plant_turn()
    else:
        erron += 1
        print(style(WARNING, "No plant_turn method in class"))

    if (hasattr(o, "nonplant_turn")) == 1:
        UT_game.nonplant_turn()
    else:
        erron += 1
        print(style(WARNING, "No nonplant_turn method in class"))

    if (hasattr(o, "run_turn")) == 1:
        UT_game.run_turn()
    else:
        erron += 1
        print(style(WARNING, "No run_turn method in class"))

    if (hasattr(o, "draw_card")) == 1:
        UT_game.draw_card(o)
    else:
        erron += 1
        print(style(WARNING, "No draw_card method in class"))

    if erron == 0:
        print(
            style(
                OKGREEN,
                "Game Class, within tests perfect! Otherwise...good luck with the last 4 functions!!"
            ))
    else:
        print(style(OKBLUE,
                    "\n--------(:P for the lack of error details ^_^)"))
        print(
            style(
                WARNING,
                "--------∆ IF YOU GET ALOT OF UNEXPECTED ERRORS, MAKE SURE YOU PROPERLY COPIED AND PASTED THE CODE GIVEN TO YOU #_#"
            ) + end_style())
Exemplo n.º 21
0
 def generate_wave(self):
     return Wave(midi.midi_to_frequency(self.data1), vol=self.data2 / 127)
Exemplo n.º 22
0
 def __init__(self, myDebug, direction, theta, thetaDelta, cX, cY, len, color, speed):
     Wave.__init__(self, myDebug, direction, theta, thetaDelta, cX, cY, len, color, speed)
Exemplo n.º 23
0
class Game():
    
    def __init__(self):
        self.squareSize = 40
        self.width = 600
        self.height = 600
        self.over = False
        
        self.enemies = []
        self.towers = []
        self.projectiles = []
        self.player = Player(200,10)
    
    def loadMap(self,level):
        self.map = Map(self.squareSize,level)
        self.createSpawnAndEnd()
        self.CreateButtons()
        self.createWave()
        self.bfs = BreadthSearch(self.map)
        self.bfs.bfs(self.bfs.map.map[self.map.end.y][self.map.end.x])
    
    def createWave(self):
        self.wave = Wave(self.spawnSquare.x,self.spawnSquare.y,self.map)
    
    def updateTowers(self):
        for tower in self.towers:
            for enemy in self.enemies:
                if tower.canFire(enemy) and tower.ttype != 3:
                    tower.fire()
                    newprojectile = Projectile(tower.x+20,tower.y+20,tower.projSpeed,tower.damage,enemy,tower.ttype)
                    self.projectiles.append(newprojectile)
            tower.readyToFire()
    
    def updateEnemies(self):
        if self.wave.active == True:
            if self.wave.delay == 0:
                e = self.wave.spawnEnemies()
                if e != None:
                    self.enemies.append(e)
            else:
                self.wave.delay -= 1
        for enemy in self.enemies:
            enemy.move()
            if enemy.hp <= 0:
                enemy.dead = True
    
    def updateProjectiles(self):
        for projectile in self.projectiles:
            projectile.moveTowards(projectile.enemy)
            projectile.setRotation()

    def updateAll(self):
        self.updateTowers()
        self.updateProjectiles()
        self.updateEnemies()
        self.player.updatePlayer()
    
    def addTower(self,x,y,ttype):
        gold = [50,100,500]
        if x < len(self.map.map) and y < len(self.map.map[0]) and self.map.map[y][x].isWall and self.isFree(x,y):
            g = gold[ttype-1]
            if self.player.gold >= g:
                self.player.getGold(-g)
                if ttype == 1:
                    # Arrow tower
                    #Tower(self,x,y,damage,trange,firerate,projSpeed,ttype):
                    newtower = Tower(x*self.squareSize,y*self.squareSize,10,200,10,20,1)
                    self.buttons[0].activated = False
                elif ttype == 2:
                    newtower = Tower(x*self.squareSize,y*self.squareSize,10,150,15,20,2)  
                    self.buttons[1].activated = False
                elif ttype == 3:
                    newtower = LaserTower(x*self.squareSize,y*self.squareSize,4,100,3)
                    self.buttons[2].activated = False
                self.towers.append(newtower)

    
    def CreateButtons(self):
        gt = QPixmap("guntower.png")
        at = QPixmap("arrowtower.png")
        lt = QPixmap("lasertower.png")
        arrowTowerButton = CustomButton(650,20,at,1)
        gunTowerButton = CustomButton(650,100,gt,2)
        laserTowerButton = CustomButton(650,180,lt,3)
        
        self.buttons = []
        self.buttons.append(arrowTowerButton)
        self.buttons.append(gunTowerButton)
        self.buttons.append(laserTowerButton)
        
    
    def isFree(self,x,y):
        if len(self.towers) > 0:
            for t in self.towers:
                if t.x/self.squareSize == x and t.y/self.squareSize == y:
                    return False
        return True
    
    def createSpawnAndEnd(self):
        if self.map.start.y == 0: # Up edge
            spawnSquare = Square(self.squareSize,False,self.map.start.x,(self.map.start.y-1))
        elif self.map.start.x == 0: # Left edge
            spawnSquare = Square(self.squareSize,False,(self.map.start.x-1),self.map.start.y)
        elif self.map.start.y == len(self.map.map)-1: # down edge
            spawnSquare = Square(self.squareSize,False,self.map.start.x,(self.map.start.y+1))
        elif self.map.start.x == len(self.map.map[0])-1: # right edge
            spawnSquare = Square(self.squareSize,False,(self.map.start.x+1),self.map.start.y)
        self.spawnSquare = spawnSquare
        self.spawnSquare.cameFrom = self.map.map[self.map.start.y][self.map.start.x]

        if self.map.end.y == 0: # Up edge
            endSquare = Square(self.squareSize,False,self.map.end.x,(self.map.end.y-1.5))
        elif self.map.end.x == 0: # Left edge
            endSquare = Square(self.squareSize,False,self.map.end.x-1.5,self.map.end.y)
        elif self.map.end.y == len(self.map.map)-1: # down edge
            endSquare = Square(self.squareSize,False,self.map.end.x,self.map.end.y+1.5)
        elif self.map.end.x == len(self.map.map[0])-1: # right edge
            endSquare = Square(self.squareSize,False,(self.map.end.x+1.5,self.map.end.y))
        self.endSquare = endSquare
        self.map.map[self.map.end.y][self.map.end.x].cameFrom = endSquare 
Exemplo n.º 24
0
class App(implements(CellObserver)):
    def __init__(self, root):

        self._root = root
        self._gameRunning = False
        # TODO: probably move these into a Wave object?
        self._currWaveNumber = 0
        self._currWave = None
        self._path = None

        self._createGUIElements(root)

        self.grid = self._createGridOfCells()

        # Read path info from a file and highlight the path on the screen.
        self.readPathInfo()

        # TODO: should support multiple paths eventually.
        # TODO: _wave should be related to _currWave
        self._wave = Wave("wave1.txt", self._path, self._canv)

    def _createGUIElements(self, root):

        self._bottom_panel = Frame(root)
        self._bottom_panel.pack()
        self._btStartGame = Button(self._bottom_panel,
                                   text="Start Game",
                                   command=self.startGame)
        self._btStartGame.pack(side=LEFT)
        Label(self._bottom_panel, text="Gold: ").pack(side=LEFT)
        self._goldAmtVar = IntVar()
        self._goldAmtVar.set(INIT_GOLD_AMOUNT)
        self._goldLbl = Label(self._bottom_panel,
                              textvariable=self._goldAmtVar)
        self._goldLbl.pack(side=LEFT)
        self._btNextWave = Button(self._bottom_panel,
                                  text="Start Wave",
                                  command=self.startNextWave,
                                  state=DISABLED)
        self._btNextWave.pack(side=LEFT)
        Label(self._bottom_panel,
              text="Time till next wave starts: ").pack(side=LEFT)
        self._timeLeftTilWave = IntVar()
        self._timeLeftTilWave.set(TIME_BETWEEN_WAVES)
        self._timeLeftLbl = Label(self._bottom_panel,
                                  textvariable=self._timeLeftTilWave)
        self._timeLeftLbl.pack(side=LEFT)
        self._btPlaceTower = Button(self._bottom_panel,
                                    text="Place tower",
                                    command=self.placeTowerMode,
                                    state=DISABLED)
        self._btPlaceTower.pack(side=LEFT)
        self._canv = Canvas(root, width=CANVAS_DIM, height=CANVAS_DIM)
        self._canv.pack()

    def startGame(self):
        self._gameRunning = True
        self._btNextWave.config(state=NORMAL)
        self._btStartGame.config(state=DISABLED)
        self._btPlaceTower.config(state=NORMAL)
        # Start the timer, which forces the next wave to start in a few seconds.
        self._canv.after(1000, self.decrementTimer)

    def startNextWave(self):
        '''Start the next wave now, instead of waiting for the timer to go down to 0.'''
        if not self._gameRunning:
            return
        self._timeLeftTilWave.set(TIME_BETWEEN_WAVES)
        self._wave.start()
        self._canv.after(1000, self.decrementTimer)

    def decrementTimer(self):
        timeLeft = self._timeLeftTilWave.get() - 1
        self._timeLeftTilWave.set(timeLeft)
        if timeLeft == 0:
            self.startNextWave()
        else:
            self._canv.after(1000, self.decrementTimer)

    def readPathInfo(self):
        '''Read path information from a file and create a path object for it.'''
        self._path = Path(NUM_CELLS_PER_DIM)
        with open('path.txt') as pf:
            for elem in pf:
                elem = elem.strip()
                x, y = map(int, elem.split(','))  # map(int) to make ints.
                self._path.add_cell(self.grid[y][x])
                self.grid[y][x].set_type('path')

    def update(self, cell):
        # print("cell at {}, {} clicked".format(cell.get_x(), cell.get_y()))
        cell.set_type("tower")
        self.disableAllCellsTowerPlacementMode()
        self._btPlaceTower.config(state=NORMAL)
        self._placingATower = False
        # self.towers.append(Tower(cell.get_x(), cell.get_y()...))

    def _createGridOfCells(self):
        grid = []
        for row in range(NUM_CELLS_PER_DIM):
            rowlist = []
            for col in range(NUM_CELLS_PER_DIM):
                cell = Cell(self._canv, col, row, SQUARE_SIZE)
                rowlist.append(cell)
                # register to receive notifications when a cell is clicked
                cell.registerObserver(self)
            grid.append(rowlist)
        return grid

    def placeTowerMode(self):
        self._placingATower = True
        self._btPlaceTower.config(state=DISABLED)
        self.enableAllCellsTowerPlacementMode()

    def enableAllCellsTowerPlacementMode(self):
        t = Tower(0, 0)
        for r in self.grid:
            for cell in r:
                cell.enable_tower_placement_mode(t)

    def disableAllCellsTowerPlacementMode(self):
        for r in self.grid:
            for cell in r:
                cell.disable_tower_placement_mode()
Exemplo n.º 25
0
 def __init__(self):
     self.wave = Wave().set_wave()
     self.season = Season().set_season()
     self.board = Board().set_board()
     self.wind = Wind().set_wind()
Exemplo n.º 26
0
 def createWave(self):
     self.wave = Wave(self.spawnSquare.x,self.spawnSquare.y,self.map)
Exemplo n.º 27
0
 def new_wave(self, target):
     self.wave_number += 1
     wave = Wave(self.get_types(), self.screen, self.amount, self.maxX,
                 self.maxY, self.groups)
     wave.startWave(target)
     self.amount += 1
Exemplo n.º 28
0
 def __load_waves(self) -> Dict:
     return {
         str(wave_id): Wave(wave_id, self.wave_total)
         for wave_id in range(1, self.wave_total + 1)
     }