Пример #1
0
    def run(self):

        pygame.display.set_caption(self.caption)

        if self.state == S_MENU:

            play_button = Button(
                'PLAY', Tile.screen_size[0] / 2 - self.button_size[0] / 2, 200,
                self.button_size[0], self.button_size[1], 'PLAY GAME')
            builder_button = Button(
                'DEVELOP', Tile.screen_size[0] / 2 - self.button_size[0] / 2,
                300, self.button_size[0], self.button_size[1], 'DEVELOP LEVEL')

            while self.state == S_MENU:
                self.state = functions.get_state()

                self.screen.blit(self.menubackground, (0, 0))
                Button.draw_buttons(self.screen)
                menu_interaction(self.screen)

                pygame.display.flip()
                self.clock.tick(self.FPS)

        if self.state == S_GAME:

            Tile.create_tiles()

            bill = Character('Bill')
            bull = Character('Bull')

            functions.load_level(1)
            sound = pygame.mixer.Sound("audio/music.wav")
            sound.set_volume(.25)
            sound.play(-1)

            print Tile.MAP

            while self.state == S_GAME:
                self.state = functions.get_state()

                self.screen.blit(self.gamebackground, (0, 0))
                Tile.draw_tiles(self.screen)
                Character.update_characters(bill, bull)
                Character.draw_characters(self.screen)

                interaction(self.screen, bill, bull)

                bill.movement()
                bull.movement()

                pygame.display.flip()
                self.clock.tick(self.FPS)

        if self.state == S_ESC:
            pass
Пример #2
0
def gameLoop():
    pygame.init()
    pygame.font.init()
    #pygame.mixer.init()

    #pygame.mixer.music.load("audio/halo_themes.wav")
    #pygame.mixer.music.play(-1)

    invalids = tuple(invalids_func())

    for y in range(0, screen.get_height(), 32):
        for x in range(0, screen.get_width(), 32):
            if Tile.total_tiles in invalids:
                Tile(x, y, 'solid')
            else:
                Tile(x, y, 'empty')

    #set time
    #clock = pygame.time.Clock()
    FPS = 24
    total_frames = 0

    background = pygame.image.load('images/Background.png')
    player = Player(64, 128)

    while player.health > 1:

        screen.blit(background, (0, 0))

        Enemy.spawn(total_frames, FPS)
        Enemy.update(screen, player)

        player.movement()

        Bullet.super_massive_jumbo_loop(screen)

        A_Star(screen, player, total_frames, FPS)
        interaction(screen, player)
        player.draw(screen)

        Func.text_to_screen(screen, "Health {0}".format(player.health), 0, 0)

        pygame.display.flip()
        clock.tick(FPS)
        total_frames += 1

        if player.health <= 0:
            sleep(2)
            screen.blit(pygame.image.load("images/End.png"), (0, 0))
            pygame.display.update()
            break

    sleep(4)
Пример #3
0
	def run(self):

		pygame.display.set_caption(self.caption)

		if self.state == S_MENU:
			
			play_button = Button('PLAY', Tile.screen_size[0] / 2 - self.button_size[0] / 2, 200, self.button_size[0], self.button_size[1], 'PLAY GAME')
			builder_button = Button('DEVELOP', Tile.screen_size[0] / 2 - self.button_size[0] / 2, 300, self.button_size[0], self.button_size[1], 'DEVELOP LEVEL')

			while self.state == S_MENU:
				self.state = functions.get_state()

				self.screen.blit(self.menubackground, (0,0))
				Button.draw_buttons(self.screen)
				menu_interaction(self.screen)

				pygame.display.flip()
				self.clock.tick(self.FPS)

		if self.state == S_GAME:

			Tile.create_tiles()

			bill = Character('Bill')
			bull = Character('Bull')

			functions.load_level(1)
			sound = pygame.mixer.Sound("audio/music.wav")
			sound.set_volume(.25)
			sound.play(-1)

			print Tile.MAP

			while self.state == S_GAME:
				self.state = functions.get_state()

				self.screen.blit(self.gamebackground, (0,0))
				Tile.draw_tiles(self.screen)
				Character.update_characters(bill, bull)
				Character.draw_characters(self.screen)

				interaction(self.screen, bill, bull)

				bill.movement()
				bull.movement()

				pygame.display.flip()
				self.clock.tick(self.FPS)


		if self.state == S_ESC:
			pass
Пример #4
0
def main_loop(survivor, clock):
    total_frames = 0
    while survivor.health > 0:
        Tile.draw_all(display)
        interaction(display, survivor)
        Zombie.spawn(display, total_frames, survivor)
        survivor.movement()
        text(display, survivor.health, Zombie.left_round + len(Zombie.instances),
             clock.get_fps(), Zombie.level, survivor.ammo, Drop.actives)
        Bullet.update(display)
        survivor.draw(display)
        Zombie.update(display, survivor)
        PickUp.update(display, survivor, total_frames)
        Drop.update(display, survivor)
        clock.tick(Options.fps)
        pygame.display.flip()
        total_frames += 1
Пример #5
0
def game_screen(*args, **kwargs):
	global total_frames, current_screen, total_frames_before, survivor
	
	screen.blit(bg, (0, 0))
	events = pygame.event.get()
	if not paused:
		pygame.mouse.set_visible(False)
		Zombie.movement(total_frames)
		Blood.update(total_frames)
		BaseClass.List.update(total_frames)
		Bullet.loop(screen, total_frames, survivor)
		if Zombie.current_wave.alive > 0:
			Zombie.current_wave.spawn_zombies(survivor, total_frames)
			total_frames_before = total_frames
		else:
			if total_frames - total_frames_before > FPS * 2:
				Zombie.wave_number += 1
				Zombie.current_wave = Wave(Zombie.wave_number)
			else:
				func.text_to_screen(screen, 'Wave {}'.format(Zombie.wave_number+1),
					WIDTH / 2, HEIGHT / 2, size=40)
		find_path(survivor)
		total_frames += 1
	else:
		pygame.mouse.set_visible(True)
		pause_menu(screen, survivor, events)
	interaction(screen, total_frames, events)
	BaseClass.set_dirty()
	Bullet.set_dirty()
	Blood.draw(screen)
	Bullet.List.draw(screen)
	BaseClass.List.draw(screen)
	display_explosions(screen, paused)
	func.text_to_screen(screen, str(int(survivor.health)), 20, 20,
		color=(30, 255, 20), size=40)
	func.text_to_screen(screen, 'Score: {}'.format(str(survivor.score)),
		20, 70, size=30)
	func.text_to_screen(screen, 'Highscore: {}'.format(str(survivor.max_score)),
		20, 110, size=30)
	if not paused:
		mx, my = pygame.mouse.get_pos()
		screen.blit(cursor, (mx-16, my-16))
	pygame.display.update()
	clock.tick(FPS)
Пример #6
0
    def test_interaction(self):
        x_action = np.random.randint(2)
        y_action = np.random.randint(2)
        env = IPD()
        init_state = env.get_state_id(x_action, y_action)
        Q_class = TableQAgent()

        # epislon 0.15 without decay works well with 200k steps!

        strategy = [0.9999, 0.1111, 0.9999, 0.1111] # is approx. 3 - 3
        # strategy = [1., 0., 1., 0.]
        # strategy = [0.9999, 0.9999, 0.9999, 0.9999]  # is approx 0 - 5-+
        # strategy = [0.1111, 0.1111, 0.1111, 0.1111] #is approx 1 - 1

        # strategy = [11/13, 1/2, 7/26, 0] #3.65139 -- The average reward for learning agent y:  1.8763999999999998
        for _ in range(5):
            reward_x, reward_y = interaction(init_state, Q_class, env, strategy)
            # print("The average reward for fixed agent x: ", reward_x, "-- The average reward for learning agent y: ",
            #       reward_y)
        self.assertTrue(len(strategy) == 4)
Пример #7
0
dungeon = pygame.image.load('images/dungeon.jpg')

# zombie1 = Zombie(80, 80)
survivor = Survivor(32 * 2, 32 * 4)

while True:

    screen.blit(dungeon, (0, 0))

    Zombie.spawn(total_frames, FPS)
    Zombie.update(screen, survivor)
    survivor.movement()

    Bullet.super_massive_jumbo_loop(screen)

    A_Star(screen, survivor, total_frames, FPS)
    interaction(screen, survivor)
    survivor.draw(screen)

    Funk.text_to_screen(screen, 'Health: {0}'.format(survivor.health), 0, 0)

    pygame.display.flip()
    clock.tick(FPS)
    total_frames += 1

    if survivor.health <= 0:
        sleep(2.5)
        screen.blit(pygame.image.load('images/dead.jpg'), (0, 0))
        pygame.display.update()
        break
sleep(4)
Пример #8
0
bill = Character('Bill')
bull = Character('Bull')

while True:
	screen.fill((200,200,200))
	develop.draw_tiles(screen)
	develop.show_inter_window()
	#develop.show_info(screen)

	if develop.testing == True:

		try:
			Character.update_characters(bill, bull)
			Character.draw_characters(screen)

			interaction(screen, bill, bull)

			bill.movement()
			bull.movement()

		except Exception, e:
			print 'Seems like the map is not valid. Are you sure you have point block and spawning points set?'
			develop.testing = False

	else:

		develop.build_controls(screen)

	pygame.display.flip()
	clock.tick(FPS)
Пример #9
0
RED = (200, 0, 0)
PURPLE = (255, 0, 255)
ORANGE = (255, 155, 0)
BRIGHT_GREEN = (0, 255, 0)
BRIGHT_BLUE = (0, 0, 255)
BRIGHT_RED = (255, 0, 0)

pygame.init()

screen = pygame.display.set_mode((960, 480))

clock = pygame.time.Clock()
FPS = 20
total_frames = 0

game = Game()

while True:

    screen = pygame.display.get_surface()

    screen.fill((120, 120, 120))

    Game.update(screen)
    interaction(screen)

    pygame.display.set_caption("Hax Free Pokemon")
    pygame.display.flip()
    clock.tick(FPS)
    total_frames += 1
Пример #10
0
            Tile(x, y, 'empty')

#set time
clock = pygame.time.Clock()
FPS = 24
total_frames = 0

background = pygame.image.load('images/Background.png')
player = Player(64, 128)

while True:

    screen.blit(background, (0, 0))

    Enemy.spawn(total_frames, FPS)
    Enemy.movement()

    player.movement()

    Bullet.super_massive_jumbo_loop(screen)

    A_Star(screen, player, total_frames, FPS)
    interaction(screen, player)
    Tile.draw_tiles(screen)
    player.draw(screen)
    Enemy.draw_enemies(screen)

    pygame.display.flip()
    clock.tick(FPS)
    total_frames += 1
Пример #11
0
def run(N, step, modifier):
    row_tot, col_tot = int(np.round(np.sqrt(N/10)/step)), \
                       int(np.round(np.sqrt(N/10)/step))
    #row_tot, col_tot = 8,8
    Dx, Dy = row_tot * step, col_tot * step
    box_tot = row_tot * col_tot

    k = 2 * np.pi / (step * row_tot)
    P = int(np.ceil(
        k * np.sqrt(2) * step)) * modifier  # proportional to box diameter * k
    Q = 2 * P + 1
    # source creation
    box_list = [[] for i in range(box_tot)]
    src_list = []
    #src_list = [source.source(0.3, 0.5, 1),source.source(3.4,3.5,1)]#source.source(3.5, 3.3, 1)]
    for i in range(N):
        src_list.append(source.source(Dx * np.random.random(), Dy * \
                                      np.random.random(), np.random.random()))
        # Map src to nearest lower left grid pnt
        src_list[i].grid = np.array([int(np.floor(src_list[i].x/step)), \
                                     int(np.floor(src_list[i].y/step))])
        src_list[i].idx = utils.coord2idx(src_list[i].grid[0], \
                                          src_list[i].grid[1], col_tot)
        # compute c2m vector in cyl
        src_list[i].rho, src_list[i].theta = utils.cart2cyl((src_list[i].grid[0] +\
          0.5)*step - src_list[i].x, (src_list[i].grid[1] + 0.5)*step - src_list[i].y)
        # contains source idxs in each box
        box_list[src_list[i].idx].append(i)

    interactions = interaction.interaction(box_tot, col_tot, row_tot, \
                                           src_list, box_list)
    interactions.fill_lists()

    fast = time.clock()  #fast time

    #Calculate Multipoles
    alpha_list = np.array([i for i in np.arange(0, 2 * np.pi, 2 * np.pi / Q)])
    C2M_list = [[] for i in range(box_tot)]
    for box_idx in range(box_tot):
        for i, alpha in enumerate(alpha_list):
            val = 0
            for src_idx in box_list[box_idx]:
                src = src_list[src_idx]
                val += np.exp(np.complex(0,1) * k * src.rho * \
                              np.cos(alpha - src.theta)) * src.weight
            C2M_list[box_idx].append(val)

    #M2L
    M2L_list = [[0 for i in range(box_tot)] for i in range(box_tot)]
    for obs_box_idx in range(box_tot):
        obs_x, obs_y = np.array(utils.idx2coord(obs_box_idx, col_tot)) * step
        for src_box_idx in interactions.list[obs_box_idx]:
            vals = []
            for alpha in alpha_list:
                src_x, src_y = np.array(utils.idx2coord(src_box_idx,
                                                        col_tot)) * step
                x, y = obs_x - src_x, obs_y - src_y
                sep_rho, sep_theta = utils.cart2cyl(x, y)
                val = 0
                for p in np.arange(-P, P + 1, 1):
                    val += funcs.hankel1(p, k*sep_rho) * np.exp(-np.complex(0,1) *\
                                         p * (sep_theta - alpha - np.pi/2))
                vals.append(val)
            M2L_list[obs_box_idx][src_box_idx] += np.array(vals)

    #L2O
    L2O_list = [[] for i in range(N)]
    for i, src in enumerate(src_list):
        for alpha in alpha_list:
            L2O_list[i].append(np.exp(np.complex(0,1) * k * src.rho * \
                            np.cos(alpha - (src.theta + np.pi))))

    # interactions
    pot = np.array([np.complex(0, 0) for i in range(N)])
    for obs_box_idx in range(box_tot):
        C2L_list = []
        for i, src_box_idx in enumerate(interactions.list[obs_box_idx]):
            # translates from sources to local multipole
            C2L_list.append(M2L_list[obs_box_idx][src_box_idx] * \
                            C2M_list[src_box_idx])
        for i, obs_idx in enumerate(box_list[obs_box_idx]):
            C2O_list = [L2O_list[obs_idx] * C2L for C2L in C2L_list]
            pot[obs_idx] = np.sum(C2O_list) / Q
        # near interactions
        near_pot = interactions.compute_near(obs_box_idx, k)
        for i, obs_idx in enumerate(box_list[obs_box_idx]):
            pot[obs_idx] += near_pot[i]

    fast = time.clock() - fast

    # TESTING
    slow = time.clock()
    src_idxs = [i for i in range(N)]
    G = interactions.build_G(src_idxs, src_idxs, k)
    weights = np.array([src.weight for src in src_list])
    #    slow = time.clock()
    test_pot = np.dot(G, weights)
    slow = time.clock() - slow

    error = (lg.norm(pot) - lg.norm(test_pot)) / lg.norm(test_pot)
    print('N: ', N, 'Modifier: ', modifier, 'Step: ', step)
    print('error: ', error)
    print('Slow Time: ', slow)
    print('Fast Time: ', fast)
    return (error, slow, fast)
Пример #12
0
clock = pygame.time.Clock()
fps = 1

first_apple = Tile.random_tile(958, 1588, Invalids)

head = Head(180, 400)
target = Apple(first_apple.x, first_apple.y)

#pygame.mixer.music.load("Music/BloodyTears.ogg")
#pygame.mixer.music.play(-1)

background = pygame.image.load("Images/Nokia_Phone.png")

while True:
    #Processes
    interaction(screen, head)
    #Processes
    #Logic
    head.motion()
    Tile.Occupied = []
    Tile.Occupied_Numbers = []
    for segment in Body.List:
        for tile in Tile.List:
            if tile.x == segment.x and tile.y == segment.y:
                Tile.Occupied.append(tile)
                Tile.Occupied_Numbers.append(tile.number)
            elif tile.number in Invalids:
                continue
            else:
                tile.Type = 'empty'
                tile.walkable = True
Пример #13
0
def run(level_cnt, grid_step, N, eps):
    grid_dim = 2**(level_cnt-1) # Should remain power of two for easy life
    src_list = []
    for i in range(N):
        src_list.append(source.source(grid_dim * np.random.random(),grid_dim *\
                                  np.random.random(), np.random.random()))
        # Map src to nearest lower left grid pnt
        src_list[i].grid = (int(np.floor(src_list[i].x/grid_step)), \
                            int(np.floor(src_list[i].y/grid_step)))
    
    print("Building Tree...")    
    my_tree = tree.tree(src_list, level_cnt)
    my_tree.build()
    
    print("Filling Interaction Lists...")
    interactions = interaction.interaction(level_cnt, my_tree)
    interactions.fill_list()
    
    leaf_start = 2**(2*(level_cnt-1))
    leaf_end = 2*leaf_start
    
    for obs_idx in range(leaf_start, leaf_end):
        for src_idx in range(leaf_start, leaf_end):
            G = interactions.build_G(my_tree.tree[obs_idx], \
                                     my_tree.tree[src_idx])
            if (my_tree.tree[src_idx] == []) or (my_tree.tree[obs_idx] == []):
                U, V = np.array([]), np.array([])
            else:
                U,V = utils.uv_decompose(G, eps)
            
            srcs = np.array([src_list[i] for i in my_tree.tree[src_idx]])
            obs_ids = my_tree.tree[obs_idx]
            src_vec = np.array([src.weight for src in srcs])
            
            interactions.src_vecs[obs_idx][src_idx] = src_vec
            interactions.obs_vecs[obs_idx] = obs_ids
            interactions.uv_list[obs_idx][src_idx] = (U,V)
    
    print('Computing UV Decompositions...')
    for lvl in range(level_cnt-2, 1, -1):
        lb = 2**(2*lvl)
        ub = 2*lb
        for obs_idx in range(lb,ub):
            for src_idx in interactions.list[obs_idx]:
    #        for src_idx in range(lb,ub):
                n = my_tree.get_children(obs_idx,lvl) #rows of merging
                m = my_tree.get_children(src_idx,lvl) #cols of merging
                uv = [[0,0],[0,0]] # index as [row][col]
                for i in range(2):
                    for j in range(2):
                        U1, V1 = interactions.uv_list[n[2*i]][m[2*j]]
                        U2, V2 = interactions.uv_list[n[2*i+1]][m[2*j]]
                        U3, V3 = interactions.uv_list[n[2*i]][m[2*j+1]]
                        U4, V4 = interactions.uv_list[n[2*i+1]][m[2*j+1]]
                        
                        U12,V12 = utils.merge(U1, V1, U2, V2, eps)
                        U34,V34 = utils.merge(U3, V3, U4, V4, eps)
                        # Horizontal merge
                        uv[i][j] = utils.merge(U12, V12, U34, V34, eps, 1)
                
                Um1,Vm1 = utils.merge(uv[0][0][0], uv[0][0][1],\
                                      uv[1][0][0], uv[1][0][1], eps)
                Um2,Vm2 = utils.merge(uv[0][1][0], uv[0][1][1], \
                                      uv[1][1][0], uv[1][1][1], eps)
                src_vec = np.array([])
                obs_ids = []
                for box_idx in m:
                    srcs = np.array([src_list[i] for i in my_tree.tree[box_idx]])
                    src_vec = np.hstack((src_vec, np.array([src.weight \
                                            for src in srcs])))
                for box_idx in n:
                    obss = np.array([src_list[i] for i in my_tree.tree[box_idx]])
                    obs_ids = obs_ids + my_tree.tree[box_idx]
                
                U,V = utils.merge(Um1, Vm1, Um2, Vm2, eps, 1)
                
                interactions.src_vecs[obs_idx][src_idx] = src_vec
                interactions.obs_vecs[obs_idx] = obs_ids
                interactions.uv_list[obs_idx][src_idx] = (U, V)  
    
    fast_time = 0    
    print("Computing Fast Interactions...")
    for obs_box_idx in range(len(interactions.list)):
        obs_srcs_near = my_tree.tree[obs_box_idx]
        obs_srcs_far = interactions.obs_vecs[obs_box_idx]
        obs_pot_near = np.zeros(len(obs_srcs_near))
        obs_pot_far = np.zeros(len(obs_srcs_far))
        for src_box_idx in interactions.list[obs_box_idx]:
    #        src_srcs = my_tree.tree[src_box_idx]
            src_vec = interactions.src_vecs[obs_box_idx][src_box_idx]
    #        src_vec = np.array([src_list[idx].weight for idx in src_srcs])
            U, V = interactions.uv_list[obs_box_idx][src_box_idx]
            if np.size(U) != 0:
                s = time.clock() 
                obs_pot_far += np.dot(U, np.dot(V, src_vec))
                fast_time += time.clock() - s
        #near field interacitons
        obs_pot_near += interactions.compute_near(obs_box_idx)
        for i, obs in enumerate(obs_srcs_near):
            s = time.clock()
            interactions.potentials[obs] += obs_pot_near[i]
            fast_time += time.clock() - s
        for i, obs in enumerate(obs_srcs_far):
            s = time.clock()
            interactions.potentials[obs] += obs_pot_far[i]
            fast_time += time.clock() - s
    
    #Direct Computation
    print("Computing Direct Interactions...")
    idxs = [i for i in range(N)]
    G = interactions.build_G(idxs, idxs)
    src_vec = np.array([src.weight for src in src_list])
    s = time.clock()
    direct_potentials = np.dot(G, src_vec)
    slow_time = time.clock() - s
    #
    error = (lg.norm(interactions.potentials) - lg.norm(direct_potentials))\
            / lg.norm(direct_potentials)
            
    print('Error: ', error)
    print('Fast Time: ', fast_time)
    print('Slow Time: ', slow_time)
        
    return(fast_time, slow_time, error)
    
## old testing code but saving it just incase ### 

#lvl = 2
#obs_idx = 16
#src_idx = 25
#n = my_tree.get_children(obs_idx,lvl) #rows of merging
#m = my_tree.get_children(src_idx,lvl) #cols of merging
#rank = 1
#uv = [[0,0],[0,0]] # index as [row][col]
#for i in range(2):
#    for j in range(2):
#        print(i,j)
#        U1, V1 = interactions.uv_list[n[2*i]][m[2*j]]
#        U2, V2 = interactions.uv_list[n[2*i+1]][m[2*j]]
#        U3, V3 = interactions.uv_list[n[2*i]][m[2*j+1]]
#        U4, V4 = interactions.uv_list[n[2*i+1]][m[2*j+1]]
#        
#        U12,V12 = utils.merge(U1, V1, U2, V2, eps)
#        U34,V34 = utils.merge(U3, V3, U4, V4, eps)
#        # Horizontal merge
#        uv[i][j] = utils.merge(U12, V12, U34, V34, eps, 1)
#
#Um1,Vm1 = utils.merge(uv[0][0][0], uv[0][0][1],\
#                      uv[1][0][0], uv[1][0][1], eps)
#Um2,Vm2 = utils.merge(uv[0][1][0], uv[0][1][1], \
#                      uv[1][1][0], uv[1][1][1], eps)
#
#U,V = utils.merge(Um1, Vm1, Um2, Vm2, eps, 1)
Пример #14
0
# Currently works for a grid 40 x 30 and 32 pixel tiles
# Needs to define global vars for grid size, tile size and
# Vertical differential for grid calculation
# Define image file to load .... background_image
# Define image size to set SCREEN size

import pygame, sys, text_to_screen
from tile_Class import Tile
from interaction import interaction

pygame.init()
pygame.font.init()
SCREEN = pygame.display.set_mode((1280, 960)) # 40 x 30
Tile.pre_init(SCREEN)
CLOCK = pygame.time.Clock()
FPS = 20
TOTAL_FRAMES = 0
background_image = pygame.image.load('images/map1.png')

while True:

	SCREEN.blit(background_image, (0,0))
	interaction(SCREEN)
	Tile.draw_tiles(SCREEN)
	pygame.display.flip()
	CLOCK.tick(FPS)
	TOTAL_FRAMES += 1
Пример #15
0
from cmd import Cmd
# import readline
import json

from interaction import interaction
from time import sleep

try:
    with open('openbackup_config.json') as config:
        config_file = json.load(config)
except FileNotFoundError or PermissionError:
    print("Error while reading/opening the configuration file, exiting")
    sleep(5)
    exit()

command = interaction(
    config_file)  # Create an interaction object to interact with the DB, passing the config file in parameters

change_options = ["name", "ip"]
list_options = ["switch", "router", "firewall",
                "all"]
add_options = ["csv", "device"]


# TODO USE A DB CALL TO RETRIEVE VALUE IN DEVICE TYPE TABLE TO BE DYNAMIC


class Prompt(Cmd):
    prompt = "OPENBACKUP>"

    def do_set_backup(self,arg):
        command.trigger_backup(arg)
Пример #16
0
pygame.mixer.music.load('audio/tristram.mp3')
pygame.mixer.music.play(-1)
pygame.mixer.music.set_volume(.25)

screen = pygame.display.set_mode((1280, 960)) # 40, 30

Tile.pre_init(screen)

clock = pygame.time.Clock()
FPS = 20
total_frames = 0
 
dungeon = pygame.image.load('images/map1.png')
survivor = Survivor(128, 512)

while True:

    screen.blit(dungeon, (0,0) )
    Zombie.spawn(total_frames, FPS)

    survivor.movement()
    Bullet.super_massive_jumbo_loop(screen)
    A_Star(screen, survivor, total_frames, FPS)
    interaction(screen, survivor)
    survivor.draw(screen)
    Zombie.update(screen)

    pygame.display.flip()
    clock.tick(FPS)
    total_frames += 1
Пример #17
0
# Currently works for a grid 40 x 30 and 32 pixel tiles
# Needs to define global vars for grid size, tile size and
# Vertical differential for grid calculation
# Define image file to load .... background_image
# Define image size to set SCREEN size

import pygame, sys, text_to_screen
from tile_Class import Tile
from interaction import interaction

pygame.init()
pygame.font.init()
SCREEN = pygame.display.set_mode((1280, 960))  # 40 x 30
Tile.pre_init(SCREEN)
CLOCK = pygame.time.Clock()
FPS = 20
TOTAL_FRAMES = 0
background_image = pygame.image.load('images/map1.png')

while True:

    SCREEN.blit(background_image, (0, 0))
    interaction(SCREEN)
    Tile.draw_tiles(SCREEN)
    pygame.display.flip()
    CLOCK.tick(FPS)
    TOTAL_FRAMES += 1