def update_object(self): """ Es werden falls nicht vorhanden passende PowerUps auf dem Spielfeld plaziert """ # Es ist immer ein PowerUp des Typen PLUS_LENGTH auf dem Spielfeld und befindet sich immer in obj_arr[0] if self.obj_arr[0] == None: # Falls kein solches PowerUp vorhanden, wird sofort eins erzeugt self.obj_arr[0] = objects.Object(self.car_list, self.obj_arr, t.PLUS_LENGTH) if self.counter == 0: # Jedes PowerUp, das in obj_arr[1] liegt, hat einen Timer, wenn dieser self.obj_arr[1] = None # abgelaufen ist wird das PowerUp entfernt else: self.counter = self.counter - 1 # In obj_arr[1] liegen die anderen PowerUps, jedoch muss nicht immer eins vorhanden sein if self.obj_arr[1] == None: if random() < 0.05: # mit einer Wahrscheinlichkeit von 5% wird ein neues PowerUp erzeugt, falls keines vorhanden ist r = random() if r < 0.35: # 35% type = t.MINUS_LENGTH self.counter = TYPE_TIMER[t.MINUS_LENGTH] elif r < 0.70: # 35% type = t.DESTROY_TAIL self.counter = TYPE_TIMER[t.DESTROY_TAIL] elif r < 0.82 and self.powerup_1 < 2: # 12%, wird maximal zwei mal im Spiel gespawnt type = t.SELFDMG_OF self.counter = TYPE_TIMER[t.SELFDMG_OF] self.powerup_1 = self.powerup_1 + 1 elif r < 0.94 and r > 0.82 and self.powerup_2 < 2: # 12%, wird maximal zwei mal im Spiel gespawnt type = t.BORDERDMG_OF self.counter = TYPE_TIMER[t.BORDERDMG_OF] self.powerup_2 = self.powerup_2 + 1 else: # 6% (- 30%), erhöhte Wahrscheinlichkeit, falls SELFDMG_OF und/oder # BORDER type = t.LOSE # BORDERDMG_OF schon zwei mal gespawnt sind self.counter = TYPE_TIMER[t.LOSE] self.obj_arr[1] = objects.Object(self.car_list, self.obj_arr, type)
def create_board(): i = 1 x = 10 while x < global_var.mp.width - 250: no = random.randint(0, 3) y = random.randint(10, global_var.mp.height - 15) #beams enemy = objects.Object(config.enemy[no], x, y) global_var.beams.append(enemy) enemy.render() #dragon power up if i % 10 == 0: dg_pow_up = objects.Object(config.dg_pow_up, x + 15, y) global_var.dg_power_up.append(dg_pow_up) dg_pow_up.render() #magnets elif i % 5 == 0: magnet = objects.Object(config.magnet, x + 10, y) global_var.magnets.append(magnet) magnet.render() i += 1 x += random.randint(20, 30) if x > global_var.mp.width - 250: break y = random.randint(10, global_var.mp.height - 15) #coins coin = objects.Object(config.coins, x, y) global_var.coins.append(coin) coin.render() x += random.randint(20, 30) y = random.randint(10, global_var.mp.height - 15) #boost boost = objects.Object(config.boost, x, y) global_var.boosts.append(boost) boost.render() x += random.randint(20, 50)
def getObject(self, objectNum): objectsStartAddress = self.header.objectTable + self.getPropertiesLength( ) objectAddress = objectsStartAddress + self.getObjectLength() * ( objectNum - 1) return objects.Object(self, objectAddress, objectNum)
def loadPlayer(self, name): # get dict of settings in player's file settings = files.loadFromFile('players\\%s.plr' % self.name) # iterate through dict for k in settings.keys(): if k == "Username": self.name = settings[k] elif k == "Password": self.password = settings[k] elif k == "Level": # store as int as required self.level = int(settings[k]) elif k == "IsAdmin": # turns out I couldn't just go bool(settings[k]), it always # returned True (presumably because it contained _something_. if settings[k] == "True": self.isAdmin = True if settings[k] == "False": self.isAdmin = False elif k == "Room": # there may be a faster way to do this, rather than looping # through every single room until we find it. for r in self.server.world.rList: if r.id == int(settings[k]): self.room = int(settings[k]) elif k == 'I': # this line creates an object and appends it to the player's # inventory. self.inventory.append(objects.Object(self, settings[k])) # set admin commands if self.isAdmin: self.cmds['dump'] = self.parse_dump
def load(self): log.info(f"Loading area: {self.area_path}") with open(self.area_path, 'r') as thefile: data = thefile.read() # Load Header Data into this Area log.info(f"Loading area Header: {self.area_path}") for eachkey, eachvalue in json.loads(data).items(): setattr(self, eachkey, eachvalue) # Load each Room into this Area log.info(f"{self.name} : Loading area Rooms") roomfilepath = os.path.join(self.folder_path, f"rooms/*.json") filenames = glob.glob(roomfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: room.Room(self, thefile.read()) # Load each Exit and attach it to a room log.info(f"{self.name} : Loading area Exits") exitfilepath = os.path.join(self.folder_path, f"exits/*.json") filenames = glob.glob(exitfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: fullpath, direction_fn = eachfile.split('.')[0].split('-') roomvnum = fullpath.split('/')[-1:][0] attached_room = self.room_by_vnum(int(roomvnum)) if attached_room is None: log.warning( f"room_by_vnum_global failed in exit load: {roomvnum}") else: exits.Exit(attached_room, direction_fn, thefile.read()) # Load each Mobile in to the Indexes. log.info(f"{self.name} : Loading area Mobiles") mobilefilepath = os.path.join(self.folder_path, f"mobiles/*.json") filenames = glob.glob(mobilefilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: mobile.Mobile(self, thefile.read()) # Load each Object in to the Indexes. log.info(f"{self.name} : Loading area Objects") objectfilepath = os.path.join(self.folder_path, f"objects/*.json") filenames = glob.glob(objectfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: objects.Object(self, thefile.read(), load_type="index") # Load the resets for this area. log.info(f"{self.name} : Loading area Resets") resetfilepath = os.path.join(self.folder_path, f"resets/resets.json") if os.path.exists(resetfilepath): with open(resetfilepath, 'r') as thefile: reset.Reset(self, thefile.read()) # Add this area to the area list. log.info(f"{self.name} : Appending to arealist.") arealist.append(self)
def create_stairs(self, x, y, upstairs=False): char = '<' name = 'stairs down' if upstairs: char = '>' name = 'stairs up' s = objects.Object(x, y, char, name, libtcod.white, always_visible=True) self.stairs.append(s) self.objects.append(s) s.send_to_back(self.objects)
def on_newobj_pressed(self): new_obj = objects.Object("New object", CaseInsensitiveDict({}), self.game) self.game.objects.add(new_obj) self.update_objects() for i, x in enumerate(self.last_objects): if x is new_obj: self.object_list_widget.focus(i) self.object_list_widget.selection_set(i)
def new_game(): global player, con # create object representing the player fighter_component = o.Fighter(hp=30, defense=2, power=5, death_function=o.player_death, xp=0) player = o.Object(0, 0, '@', 'player', libtcod.white, blocks=True, fighter=fighter_component) player.level = 1 # generate map (at this point it's not drawn to the screen) make_map() initialize_fov() g.game_state = 'playing' g.inventory = [] # create the list of game messages and their colors, starts empty g.game_msgs = [] # initial equipment: a dagger equipment_component = o.Equipment(slot='right hand', power_bonus=2) obj = o.Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component) g.inventory.append(obj) equipment_component.equip() obj.always_visible = True # a warm welcoming message! g.message('Welcome stranger! Prepare to die.', libtcod.red)
def _parse_objects(self, s): l = [] i = 0 while i < len(s): kind = s[i] if kind == MARTIAN: l.append(objects.Martian( *map(float, s[i + 1:i + 5]))) i += 5 elif kind in (BOULDER, CRATER, HOME): l.append(objects.Object(kind, float(s[i + 1]), float(s[i + 2]), float(s[i + 3]))) i += 4 return l
def handle_client(self, client): while self.tick > client.world.tick: client.tick() obj_a = objects.Object(client.world, self.data) obj_b = objects.Object(client.drawer.world, self.data) for obj in (obj_a, obj_b): obj.pos = self.pos obj.vel = self.vel obj.rot = self.rot obj.rot_vel = self.rot_vel client.world.objects[self.id] = obj_a client.world.append(obj_a) if 'add_object' in client.world.script: try: client.world.script['add_object'](obj_a) except: print_exc() client.object_map[obj_a] = obj_b
def GenerateObject(): if game.currentFrame_object == game.object_frameResult: game.object_spawnFrame = game.object_frameResult + \ int(np.random.uniform(0.0, game.object_spawnDif) * game.cFrames) if game.object_spawnFrame == game.currentFrame_object: game.currentFrame_object = 0 allObjects.append( o.Object(0, game.Vel * (1.8), game.screenX, game.screenY)) game.object_frameResult = int(game.cFrames * game.object_spawnRate) game.object_spawnFrame = 10000 game.currentFrame_object += 1
def update(self, world_obj:world.World\ , x_offset = 1, y_offset = 1): bg = self._background.copy() _x = x_offset _y = y_offset game_info = world_obj._phys_pixels # self._updated_rects =[] for y in range(len(game_info)): for x in range(len(game_info[y])): spec_obj = objects.Object(i_x=x,i_y=y,\ ) if game_info[y][x] is None else game_info[y][x] bg.blit(\ spec_obj.current_sprite,(_x,_y)) _x += self.VISUAL_PER_PHYSICAL_PIXELS + x_offset _y += self.VISUAL_PER_PHYSICAL_PIXELS + y_offset _x = x_offset self._updated_rects = self._screen_surface.blit(bg, (0, 0)) self.display()
async def load(self): if os.path.exists(self.filename): with open(self.filename, "r") as thefile: player_file_dict = json.loads(thefile.read()) for eachkey, eachvalue in player_file_dict.items(): setattr(self, eachkey, eachvalue) log.debug(f"Loading player: {self.name}") if self.contents: self.contents = {k: objects.Object(None, v, load_type="inventory") for k, v in self.contents.items()} self.race = races.racebyname(self.race) if not self.equipped: self.equipped = {k: None for k in self.race.wearlocations} self.location = area.room_by_vnum_global(self.location) await self.move(self.location)
def run(self): query = Query( "SELECT deviceID,IP,port,device FROM Devices WHERE last IS NULL") response = yield query self.devices = [] self.deviceid = {} self.objectid = {} for deviceID, IP, port, device in response: device = objects.Device(IP, port, device, deviceID) self.devices.append(device) self.deviceid[deviceID] = device if debug: print "postgres.GetDevices>", self.devices for d in self.devices: query = Query( "SELECT objectID,type,instance,name FROM Objects WHERE deviceID=%s" % (d.id)) response = yield query for objectID, otype, oinstance, name in response: o = objects.Object(d.id, objectID, otype, oinstance, name) d.objects.append(o) self.objectid[objectID] = o
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( "Assets/Levels/Jungle/Bg/Jungle.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -6000 # Array with type of platform, and x, y location of the platform. platform_array = [ [constants.JUNGLE_STONE_PLATFORM_FLAT, -450, 575], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 200, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 280, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 480, 310], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 560, 310], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 760, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 840, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_1, 1500, 540], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_1, 2270, 540], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_2, 1600, 440], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 2800, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 2870, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3020, 350], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3090, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3160, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3310, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3380, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3450, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3520, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3800, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3870, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4150, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 4220, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 4290, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 4360, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4640, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 4710, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4990, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5060, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5130, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5200, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 5350, 350], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5420, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5490, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 5640, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5710, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 6600, 430], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 6670, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 6740, 430], ] # Go through the array above and add platforms for platform in platform_array: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Array with type of enemy, and x, and distance of the enemy. enemy_array = [ [enemies.JUNGLE_ENEMY, 600, 310, 120], [enemies.JUNGLE_ENEMY, 1060, 435, 200], [enemies.JUNGLE_ENEMY, 3020, 450, 500], [enemies.JUNGLE_ENEMY, 4220, 400, 400], [enemies.JUNGLE_ENEMY, 5060, 400, 400], ] # Go through the array above and add enemies for enemy in enemy_array: enem = enemies.Enemy(enemy[0], enemy[3]) enem.rect.x = enemy[1] enem.rect.y = enemy[2] enem.player = self.player self.enemy_list.add(enem) # Array with type x and y of good object. good_object_array = [ [constants.BLACKBERRY, 520, 80], [constants.BLACKBERRY, 530, 80], [constants.BLACKBERRY, 1150, 280], [constants.BLACKBERRY, 1170, 280], [constants.BLACKBERRY, 1800, 280], [constants.BLACKBERRY, 1810, 290], [constants.BLACKBERRY, 1820, 280], [constants.BLACKBERRY, 1900, 280], [constants.BLACKBERRY, 1910, 290], [constants.BLACKBERRY, 1920, 280], [constants.BLACKBERRY, 2000, 280], [constants.BLACKBERRY, 2010, 290], [constants.BLACKBERRY, 2020, 280], [constants.JUNGLE_MUSHROOM_1, 3100, 320], [constants.JUNGLE_MUSHROOM_1, 3130, 320], [constants.JUNGLE_MUSHROOM_1, 3160, 320], [constants.BLACKBERRY, 3655, 30], [constants.BLACKBERRY, 3665, 40], [constants.BLACKBERRY, 4005, 30], [constants.BLACKBERRY, 4015, 40], [constants.BLACKBERRY, 4495, 30], [constants.BLACKBERRY, 4505, 40], [constants.BLACKBERRY, 4845, 30], [constants.BLACKBERRY, 4855, 40], [constants.JUNGLE_MUSHROOM_1, 3830, 220], [constants.JUNGLE_MUSHROOM_1, 5060, 220], [constants.JUNGLE_MUSHROOM_1, 5090, 220], [constants.JUNGLE_MUSHROOM_1, 5110, 220], [constants.BLACKBERRY, 6915, 210], [constants.BLACKBERRY, 6925, 200], [constants.BLACKBERRY, 6935, 210], [constants.BLACKBERRY, 6945, 200], [constants.BLACKBERRY, 6955, 210], [constants.JUNGLE_MUSHROOM_1, 6670, 540], [constants.JUNGLE_MUSHROOM_1, 6720, 540], [constants.JUNGLE_MUSHROOM_1, 6770, 540], ] # Go through the array above and add good object for good_object in good_object_array: obj = objects.Object(good_object[0]) obj.rect.x = good_object[1] obj.rect.y = good_object[2] obj.player = self.player self.good_object_list.add(obj) # Array with type x and y of bad object. bad_object_array = [ [constants.JUNGLE_STONE_PLATFORM_WAVES, 1570, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1570, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1640, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1640, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1710, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1710, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1780, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1780, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1850, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1850, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1920, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1920, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1990, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1990, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2060, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2060, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2130, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2130, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2200, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2200, 570], ] # Go through the array above and add bad object for bad_object in bad_object_array: obj = objects.Object(bad_object[0]) obj.rect.x = bad_object[1] obj.rect.y = bad_object[2] obj.player = self.player self.bad_object_list.add(obj) # Array with type x and y of standard object. standard_object_array = [ [constants.JUNGLE_MUSHROOM_2, 770, 400], [constants.JUNGLE_SIGN_2, 20, 500], [constants.JUNGLE_BUSH_1, 220, 390], [constants.JUNGLE_CRATE, 420, 490], [constants.JUNGLE_STONE, 480, 530], [constants.JUNGLE_BUSH_3, 540, 540], [constants.JUNGLE_BUSH_3, 570, 540], [constants.JUNGLE_BUSH_3, 600, 540], [constants.JUNGLE_TREE_1, 1000, 540], [constants.JUNGLE_TREE_1, 1200, 540], [constants.JUNGLE_TREE_1, 1400, 540], [constants.JUNGLE_SIGN_1, 1510, 490], [constants.JUNGLE_STONE, 2400, 530], [constants.JUNGLE_TREE_3, 2410, 270], [constants.JUNGLE_BUSH_2, 2820, 410], [constants.JUNGLE_STONE, 3300, 530], [constants.JUNGLE_BUSH_2, 3340, 530], [constants.JUNGLE_STONE, 3380, 530], [constants.JUNGLE_TREE_2, 3400, 270], [constants.JUNGLE_TREE_1, 5460, 320], [constants.JUNGLE_STONE, 5660, 410], [constants.JUNGLE_BUSH_3, 5680, 420], [constants.JUNGLE_TREE_3, 6050, 270], [constants.JUNGLE_TREE_3, 6100, 270], [constants.JUNGLE_TREE_3, 6150, 270], [constants.JUNGLE_BUSH_2, 6050, 530], [constants.JUNGLE_STONE, 6100, 530], [constants.JUNGLE_BUSH_2, 6150, 530], [constants.JUNGLE_BUSH_1, 6670, 390], [constants.JUNGLE_STONE, 6690, 390], [constants.JUNGLE_BUSH_2, 6870, 530], [constants.JUNGLE_STONE, 6880, 530], [constants.JUNGLE_STONE, 6920, 530], [constants.JUNGLE_SIGN_2, 6960, 490], [constants.JUNGLE_MUSHROOM_2, 3400, 220], [constants.JUNGLE_MUSHROOM_2, 3430, 220], [constants.JUNGLE_MUSHROOM_2, 3430, 220], [constants.JUNGLE_MUSHROOM_2, 4220, 220], [constants.JUNGLE_MUSHROOM_2, 4250, 220], [constants.JUNGLE_MUSHROOM_2, 5410, 320], ] # Go through the array above and add standard object for standard_object in standard_object_array: obj = objects.Object(standard_object[0]) obj.rect.x = standard_object[1] obj.rect.y = standard_object[2] obj.player = self.player self.standard_object_list.add(obj) # Add a custom moving platform block_1 = platforms.MovingPlatform( constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_2_1) block_1.rect.x = 1950 block_1.rect.y = 440 block_1.boundary_left = 1900 block_1.boundary_right = 2100 block_1.change_x = -1 block_1.player = self.player block_1.level = self self.platform_list.add(block_1) block_2 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_2.rect.x = 3655 block_2.rect.y = 200 block_2.boundary_top = 30 block_2.boundary_bottom = 560 block_2.change_y = 2 block_2.player = self.player block_2.level = self self.platform_list.add(block_2) block_3 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_3.rect.x = 4005 block_3.rect.y = 400 block_3.boundary_top = 30 block_3.boundary_bottom = 560 block_3.change_y = 2 block_3.player = self.player block_3.level = self self.platform_list.add(block_3) block_4 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_4.rect.x = 4495 block_4.rect.y = 200 block_4.boundary_top = 30 block_4.boundary_bottom = 560 block_4.change_y = 2 block_4.player = self.player block_4.level = self self.platform_list.add(block_4) block_5 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_5.rect.x = 4845 block_5.rect.y = 400 block_5.boundary_top = 30 block_5.boundary_bottom = 560 block_5.change_y = 2 block_5.player = self.player block_5.level = self self.platform_list.add(block_5)
eta = 0.25/1e5*5 piter = 4 titer = 4 NITER = 512 maxint = 3 voxelsize = 1e-6 energy = 5 # Load a 3D object beta = dxchange.read_tiff( 'data/test-beta-128.tiff').astype('float32')[::2, ::2, ::2] delta = dxchange.read_tiff( 'data/test-delta-128.tiff').astype('float32')[::2, ::2, ::2] # Create object. obj = objects.Object(beta, delta, voxelsize) # Create probe prb = objects.Probe(objects.gaussian(15, rin=0.8, rout=1.0), maxint=maxint) # Detector parameters det = objects.Detector(63, 63) # Define rotation angles theta = np.linspace(0, 2*np.pi, 400).astype('float32') # Scanner positions scanax, scanay = objects.scanner3(theta, beta.shape, 10, 10, margin=[ prb.size, prb.size], offset=[0, 0], spiral=1) # tomography data shape tomoshape = [len(theta), obj.shape[0], obj.shape[2]] # Class solver slv = solver_gpu.Solver(prb, scanax, scanay, theta, det, voxelsize, energy, tomoshape)
def create_object(self, data): obj = objects.Object(self, actions.add_default_properties(data)) self.add_object(obj) return obj
def run(): rendering.init_rendering() line = rendering.render_context.CreateLine(position=(0., 0.), size=(40, 40)) # TODO: create objects that exist at start here object_list = [ objects.Object( rendering.render_context.CreateSquare(position=(100., 100.), size=(60, 60))), objects.Object( rendering.render_context.CreatePoint(position=(200., 200.))), objects.Object( rendering.render_context.CreateCircle(position=(300., 300.), size=(60, 60))), ] global running running = True clicked = False click_point = None x_init = 200. x_post = 200. y_init = 200. y_post = 200. sel_index = 0 friction = 1.0 while running: result = input.handle_input() # execute on input if result == 'QUIT': running = False elif result == 'SQUARE': object_list.append( objects.Object( rendering.render_context.CreateSquare(position=(input.x, input.y), size=(60, 60)))) elif result == 'CIRCLE': object_list.append( objects.Object( rendering.render_context.CreateCircle(position=(input.x, input.y), size=(60, 60)))) elif result == 'POINT': object_list.append( objects.Object( rendering.render_context.CreatePoint(position=(input.x, input.y), size=(60, 60)))) elif result == 'RESTART': sys.exit(run()) rendering.clear() # render all objects [o.graphic.render(rendering.render_context) for o in object_list] # update all objects' positions and velocities for o in object_list: o.move_additive(o.vx, o.vy) if o.graphic.x < 0: o.vx = -abs(o.vx) if o.graphic.y < 0: o.vy = -abs(o.vy) avx, avy = abs(o.vx), abs(o.vy) if avx + avy == 0: continue friction_x = friction * avx / (avx + avy) friction_y = friction * avy / (avx + avy) if o.vx > 0: o.vx = max(o.vx - friction_x, 0.0) else: o.vx = min(o.vx + friction_x, 0.0) if o.vy > 0: o.vy = max(o.vy - friction_y, 0.0) else: o.vy = min(o.vy + friction_y, 0.0) if input.is_mouse_down: if not clicked: x_init = input.x y_init = input.y sel_index = update_selection(object_list, (x_init, y_init), sel_index) line.move(input.x, input.y) if sel_index is not -1: object_list[sel_index].move(input.x, input.y) clicked = True click_point = (input.x, input.y) if object_list[sel_index].graphic.contains((input.x, input.y)): line.sx, line.sy = input.x - line.x, input.y - line.y line.render(rendering.render_context) else: if clicked: if sel_index is not -1: object_list[sel_index].vx, object_list[ sel_index].vy = input.x - x_init, input.y - y_init clicked = False x_post = input.x y_post = input.y rendering.swap() return 0
def make_map(): global tile_map, objects, stairs # fill map with "blocked" tiles tile_map = [[Tile(True) for y in range(g.MAP_HEIGHT)] for x in range(g.MAP_WIDTH)] objects = [player] rooms = [] num_rooms = 0 new_x = 0 new_y = 0 for r in range(g.MAX_ROOMS): # random width and height w = libtcod.random_get_int(0, g.ROOM_MIN_SIZE, g.ROOM_MAX_SIZE) h = libtcod.random_get_int(0, g.ROOM_MIN_SIZE, g.ROOM_MAX_SIZE) # random position without going out of the boundaries of the map x = libtcod.random_get_int(0, 0, g.MAP_WIDTH - w - 1) y = libtcod.random_get_int(0, 0, g.MAP_HEIGHT - h - 1) # "Rect" class makes rectangles easier to work with new_room = Rect(x, y, w, h) # run through the other rooms and see if they intersect with this one failed = False for other_room in rooms: if new_room.intersect(other_room): failed = True break if not failed: # this means there are no intersections, so this room is valid # "paint" it to the map's tiles create_room(new_room) # center coordinates of new room, will be useful later (new_x, new_y) = new_room.center() if num_rooms == 0: # this is the first room, where the player starts at player.x = new_x player.y = new_y else: # all rooms after the first: # connect it to the previous room with a tunnel # center coordinates of previous room (prev_x, prev_y) = rooms[num_rooms - 1].center() # draw a coin (random number that is either 0 or 1) if libtcod.random_get_int(0, 0, 1) == 1: # first move horizontally, then vertically create_h_tunnel(prev_x, new_x, prev_y) create_v_tunnel(prev_y, new_y, new_x) else: # first move vertically, then horizontally create_v_tunnel(prev_y, new_y, prev_x) create_h_tunnel(prev_x, new_x, new_y) # finally, append the new room to the list place_objects(new_room) rooms.append(new_room) num_rooms += 1 # create stairs at the center of the last room stairs = o.Object(new_x, new_y, '<', 'stairs', libtcod.white, always_visible=True) objects.append(stairs) stairs.send_to_back(objects) # so it's drawn below the monsters
def __init__(self, player): """ Create level 2. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( "Assets/Levels/Desert/Bg/Desert.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -6000 # Array with type of platform, and x, y location of the platform. platform_array = [ [constants.DESERT_STONE_PLATFORM_FLAT, -450, 575], [constants.DESERT_GRASS_LEFT, 500, 425], [constants.DESERT_GRASS_MIDDLE, 570, 425], [constants.DESERT_GRASS_MIDDLE, 640, 425], [constants.DESERT_GRASS_RIGHT, 710, 425], [constants.DESERT_GRASS_LEFT, 1580, 425], [constants.DESERT_GRASS_MIDDLE, 1650, 425], [constants.DESERT_GRASS_MIDDLE, 1720, 425], [constants.DESERT_GRASS_RIGHT, 1790, 425], [constants.DESERT_GRASS_LEFT, 2150, 250], [constants.DESERT_GRASS_MIDDLE, 2220, 250], [constants.DESERT_GRASS_MIDDLE, 2290, 250], [constants.DESERT_GRASS_MIDDLE, 2360, 250], [constants.DESERT_GRASS_RIGHT, 2430, 250], [constants.DESERT_GRASS_LEFT, 2550, 350], [constants.DESERT_GRASS_MIDDLE, 2620, 350], [constants.DESERT_GRASS_MIDDLE, 2690, 350], [constants.DESERT_GRASS_MIDDLE, 2760, 350], [constants.DESERT_GRASS_RIGHT, 2830, 350], [constants.DESERT_GRASS_LEFT, 2950, 425], [constants.DESERT_GRASS_MIDDLE, 3020, 425], [constants.DESERT_GRASS_RIGHT, 3090, 425], [constants.DESERT_CRATE, 3450, 520], [constants.DESERT_GRASS_LEFT, 3930, 425], [constants.DESERT_GRASS_MIDDLE, 4000, 425], [constants.DESERT_GRASS_MIDDLE, 4070, 425], [constants.DESERT_GRASS_MIDDLE, 4140, 425], [constants.DESERT_GRASS_MIDDLE, 4210, 425], [constants.DESERT_GRASS_MIDDLE, 4280, 425], [constants.DESERT_GRASS_RIGHT, 4350, 425], [constants.DESERT_GRASS_LEFT, 4660, 200], [constants.DESERT_GRASS_MIDDLE, 4730, 200], [constants.DESERT_GRASS_MIDDLE, 4800, 200], [constants.DESERT_GRASS_MIDDLE, 4870, 200], [constants.DESERT_GRASS_RIGHT, 4940, 200], [constants.DESERT_GRASS_LEFT, 5200, 320], [constants.DESERT_GRASS_MIDDLE, 5270, 320], [constants.DESERT_GRASS_MIDDLE, 5340, 320], [constants.DESERT_GRASS_RIGHT, 5410, 320], [constants.DESERT_GRASS_LEFT, 5500, 200], [constants.DESERT_GRASS_MIDDLE, 5570, 200], [constants.DESERT_GRASS_RIGHT, 5640, 200], [constants.DESERT_GRASS_LEFT, 6200, 425], [constants.DESERT_GRASS_MIDDLE, 6270, 425], [constants.DESERT_GRASS_MIDDLE, 6340, 425], [constants.DESERT_GRASS_MIDDLE, 6410, 425], [constants.DESERT_GRASS_MIDDLE, 6480, 425], [constants.DESERT_GRASS_RIGHT, 6550, 425], ] # Go through the array above and add platforms for platform in platform_array: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Array with type of enemy, and x, and patrol distance of the enemy. enemy_array = [[enemies.DESERT_ENEMY, 2300, 435, 245], [enemies.DESERT_ENEMY, 4000, 435, 200]] # Go through the array above and add enemies for enemy in enemy_array: enem = enemies.Enemy(enemy[0], enemy[3]) enem.rect.x = enemy[1] enem.rect.y = enemy[2] enem.player = self.player self.enemy_list.add(enem) # Array with type x and y of good object. good_object_array = [ [constants.BLACKBERRY, 640, 285], [constants.BLACKBERRY, 1150, 385], [constants.BLACKBERRY, 1800, 280], [constants.BLACKBERRY, 2290, 120], [constants.BLACKBERRY, 2620, 290], [constants.BLACKBERRY, 3400, 380], [constants.BLACKBERRY, 3700, 380], [constants.BLACKBERRY, 5550, 380], [constants.BLACKBERRY, 4860, 130], [constants.BLACKBERRY, 4840, 130], [constants.BLACKBERRY, 5020, 405], [constants.BLACKBERRY, 5040, 405], [constants.BLACKBERRY, 5260, 265], [constants.BLACKBERRY, 5550, 130], [constants.BLACKBERRY, 5580, 130], [constants.BLACKBERRY, 6280, 350], ] # Array with type x and y of bad object. bad_object_array = [ [constants.DESERT_BUSH_2, 1150, 550], [constants.DESERT_BUSH_2, 1170, 550], [constants.DESERT_BUSH_2, 5600, 550], [constants.DESERT_BUSH_2, 5620, 550], ] # Array with type x and y of standard object. standard_object_array = [ [constants.DESERT_TREE, 10, 370], [constants.DESERT_GRASS_1, 150, 530], [constants.DESERT_GRASS_2, 180, 530], [constants.DESERT_GRASS_1, 210, 530], [constants.DESERT_GRASS_2, 240, 530], [constants.DESERT_GRASS_1, 270, 530], [constants.DESERT_CACTUS, 850, 490], [constants.DESERT_CACTUS_4, 900, 370], [constants.DESERT_CACTUS, 970, 490], [constants.DESERT_CACTUS, 1350, 490], [constants.DESERT_CACTUS_4, 1400, 370], [constants.DESERT_CACTUS, 1470, 490], [constants.DESERT_CACTUS_3, 1720, 400], [constants.DESERT_GRASS_1, 2140, 210], [constants.DESERT_GRASS_2, 2160, 210], [constants.DESERT_GRASS_1, 2180, 210], [constants.DESERT_TREE, 2220, 370], [constants.DESERT_GRASS_1, 2220, 530], [constants.DESERT_GRASS_2, 2250, 530], [constants.DESERT_GRASS_1, 2270, 530], [constants.DESERT_GRASS_2, 2290, 530], [constants.DESERT_GRASS_1, 2300, 530], [constants.DESERT_BUSH, 2650, 470], [constants.DESERT_CACTUS_2, 3000, 350], [constants.DESERT_STONE, 3250, 540], [constants.DESERT_STONE, 3630, 540], [constants.DESERT_BUSH, 3730, 470], [constants.DESERT_BUSH, 4030, 330], [constants.DESERT_TREE, 4650, 370], [constants.DESERT_GRASS_1, 4800, 530], [constants.DESERT_GRASS_2, 4830, 530], [constants.DESERT_GRASS_1, 4850, 530], [constants.DESERT_GRASS_2, 4870, 530], [constants.DESERT_GRASS_1, 4890, 530], [constants.DESERT_SIGN, 4950, 140], [constants.DESERT_CACTUS, 5200, 490], [constants.DESERT_CACTUS_4, 5250, 370], [constants.DESERT_CACTUS, 5300, 490], [constants.DESERT_GRASS_1, 5900, 530], [constants.DESERT_GRASS_2, 5950, 530], [constants.DESERT_GRASS_2, 6050, 530], [constants.DESERT_GRASS_1, 6100, 530], [constants.DESERT_GRASS_2, 6150, 530], [constants.DESERT_SKELETON, 6370, 400], [constants.DESERT_SIGNARROW, 6700, 470], [constants.DESERT_TREE, 6800, 370], [constants.DESERT_TREE, 7000, 370], [constants.DESERT_TREE, 7100, 370], [constants.DESERT_TREE, 7200, 370], [constants.DESERT_TREE, 7300, 370], [constants.DESERT_TREE, 7400, 370], ] # Go through the array above and add good object for good_object in good_object_array: obj = objects.Object(good_object[0]) obj.rect.x = good_object[1] obj.rect.y = good_object[2] obj.player = self.player self.good_object_list.add(obj) # Go through the array above and add bad object for bad_object in bad_object_array: obj = objects.Object(bad_object[0]) obj.rect.x = bad_object[1] obj.rect.y = bad_object[2] obj.player = self.player self.bad_object_list.add(obj) # Go through the array above and add standard object for standard_object in standard_object_array: obj = objects.Object(standard_object[0]) obj.rect.x = standard_object[1] obj.rect.y = standard_object[2] obj.player = self.player self.standard_object_list.add(obj) # Add a custom moving platform block = platforms.MovingPlatform( constants.DESERT_STONE_PLATFORM_TOP_MIDDLE) block.rect.x = 2000 block.rect.y = 200 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform( constants.DESERT_STONE_PLATFORM_TOP_MIDDLE) block.rect.x = 4530 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(constants.DESERT_CRATE) block.rect.x = 6000 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self): """ Load world from files. """ self.rList = [] # open all files in directory world/rooms/ fileList = os.listdir('world\\rooms\\') # find highest room number and create self.rList with that many slots highNum = 1 for f in fileList: num = f.split('.') if int(num[0]) > highNum: highNum = int(num[0]) self.rList = [0] * (highNum + 1) for f in fileList: settings = files.loadFromFile('world\\rooms\\%s' % f) id = None title = None desc = None exits = [None] * 10 inventory = [] mList = [] for k in settings.keys(): if k == 'ID': id = int(settings[k]) elif k == 'Title': title = settings[k] elif k == 'Desc': desc = settings[k] elif k == 'N': exits[0] = int(settings[k]) elif k == 'NE': exits[1] = int(settings[k]) elif k == 'E': exits[2] = int(settings[k]) elif k == 'SE': exits[3] = int(settings[k]) elif k == 'S': exits[4] = int(settings[k]) elif k == 'SW': exits[5] = int(settings[k]) elif k == 'W': exits[6] = int(settings[k]) elif k == 'NW': exits[7] = int(settings[k]) elif k == 'U': exits[8] = int(settings[k]) elif k == 'D': exits[9] = int(settings[k]) elif k == 'I': inventory.append(objects.Object(None, settings[k])) elif k == 'M': mList.append(mob.Mob(int(settings[k]))) r = room.Room(id, title, desc, exits) r.inventory = inventory r.mList = mList # update mobs knowledge of their room for m in r.mList: m.room = r self.rList[id] = r # loop through rooms and turn exit ints into room links for r in self.rList: # loop through exits in room for e in range(len(r.exits)): # if room has an exit if r.exits[e] != None: # loop through room list again for t in self.rList: # if current room id == exit int if t.id == r.exits[e]: # set exit to room object r.exits[e] = t
def timerEvent(self, e): if self.obj_arr[ 0] == None: # immer wenn kein Ojekt auf dem Feld ist wird ein neues hinzugefügt self.obj_arr[0] = objects.Object(self.car_list, self.obj_arr, 0) self.cars_move(self.car_list) self.update()
def __init__(self, player): """ Create level 3. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( "Assets/Levels/Snow/BG/Snow.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -6000 # Array with type of platform, and x, y location of the platform. platform_array = [ [constants.SNOW_STONE_PLATFORM_FLAT, -450, 575], [constants.SNOW_GRASS_LEFT, 630, 425], [constants.SNOW_GRASS_MIDDLE, 700, 425], [constants.SNOW_GRASS_MIDDLE, 770, 425], [constants.SNOW_GRASS_RIGHT, 840, 425], [constants.SNOW_GRASS_LEFT, 1200, 200], [constants.SNOW_GRASS_MIDDLE, 1270, 200], [constants.SNOW_GRASS_MIDDLE, 1340, 200], [constants.SNOW_GRASS_RIGHT, 1410, 200], [constants.SNOW_GRASS_LEFT, 2200, 425], [constants.SNOW_GRASS_MIDDLE, 2270, 425], [constants.SNOW_GRASS_MIDDLE, 2340, 425], [constants.SNOW_GRASS_MIDDLE, 2410, 425], [constants.SNOW_GRASS_RIGHT, 2480, 425], [constants.SNOW_GRASS_LEFT, 2610, 350], [constants.SNOW_GRASS_MIDDLE, 2680, 350], [constants.SNOW_GRASS_MIDDLE, 2750, 350], [constants.SNOW_GRASS_MIDDLE, 2820, 350], [constants.SNOW_GRASS_RIGHT, 2890, 350], [constants.SNOW_GRASS_LEFT, 3010, 250], [constants.SNOW_GRASS_MIDDLE, 3080, 250], [constants.SNOW_GRASS_MIDDLE, 3150, 250], [constants.SNOW_GRASS_MIDDLE, 3220, 250], [constants.SNOW_GRASS_RIGHT, 3290, 250], [constants.SNOW_GRASS_LEFT, 5000, 425], [constants.SNOW_GRASS_MIDDLE, 5070, 425], [constants.SNOW_GRASS_MIDDLE, 5140, 425], [constants.SNOW_GRASS_RIGHT, 5210, 425], [constants.SNOW_GRASS_LEFT, 5400, 350], [constants.SNOW_GRASS_MIDDLE, 5470, 350], [constants.SNOW_GRASS_MIDDLE, 5540, 350], [constants.SNOW_GRASS_RIGHT, 5610, 350], # 5700 [constants.SNOW_GRASS_LEFT, 5770, 350], [constants.SNOW_GRASS_MIDDLE, 5840, 350], [constants.SNOW_GRASS_MIDDLE, 5910, 350], [constants.SNOW_GRASS_MIDDLE, 5980, 350], [constants.SNOW_GRASS_RIGHT, 6050, 350], ### [constants.SNOW_GRASS_LEFT, 6220, 220], [constants.SNOW_GRASS_MIDDLE, 6290, 220], [constants.SNOW_GRASS_MIDDLE, 6360, 220], [constants.SNOW_GRASS_MIDDLE, 6430, 220], [constants.SNOW_GRASS_RIGHT, 6500, 220], ] # Go through the array above and add platforms for platform in platform_array: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Array with type of enemy, and x, and patrol distance of the enemy. enemy_array = [ [enemies.SNOW_ENEMY, 2610, 435, 245], [enemies.SNOW_ENEMY, 3110, 435, 245], [enemies.SNOW_ENEMY, 5000, 435, 245], ] # Go through the array above and add enemies for enemy in enemy_array: enem = enemies.Enemy(enemy[0], enemy[3]) enem.rect.x = enemy[1] enem.rect.y = enemy[2] enem.player = self.player self.enemy_list.add(enem) # Array with type x and y of good object. good_object_array = [ [constants.NUT, 480, 345], [constants.NUT, 750, 250], [constants.NUT, 950, 80], [constants.NUT, 1500, 80], [constants.NUT, 1800, 320], [constants.NUT, 1910, 320], [constants.NUT, 1980, 320], [constants.NUT, 2670, 230], [constants.NUT, 3080, 170], [constants.NUT, 4180, 320], [constants.NUT, 4450, 400], [constants.NUT, 4690, 320], [constants.NUT, 6200, 80], [constants.NUT, 6250, 80], [constants.NUT, 6300, 80], ] # Array with type x and y of bad object. bad_object_array = [ [constants.SNOW_CRYSTAL, 1550, 540], [constants.SNOW_CRYSTAL, 1580, 540], [constants.SNOW_CRYSTAL, 1620, 540], [constants.SNOW_CRYSTAL, 3400, 540], [constants.SNOW_CRYSTAL, 3430, 540], [constants.SNOW_CRYSTAL, 4050, 540], [constants.SNOW_CRYSTAL, 4080, 540], [constants.SNOW_CRYSTAL, 4550, 540], [constants.SNOW_CRYSTAL, 4590, 540], ] # Array with type x and y of standard object. standard_object_array = [ [constants.SNOW_TREE_2, 400, 400], [constants.SNOW_SNOWMAN, 100, 470], [constants.SNOW_TREE_1, 1240, 280], [constants.SNOW_TREE_2, 1700, 400], [constants.SNOW_SIGN, 2340, 365], [constants.SNOW_IGLOO, 2670, 300], [constants.SNOW_TREE_2, 2800, 400], [constants.SNOW_TREE_2, 2900, 400], [constants.SNOW_SNOWMAN, 3590, 470], [constants.SNOW_TREE_2, 3850, 400], [constants.SNOW_TREE_1, 3750, 280], [constants.SNOW_TREE_2, 4300, 400], [constants.SNOW_TREE_1, 4340, 280], [constants.SNOW_TREE_2, 4480, 400], [constants.SNOW_TREE_2, 4700, 400], [constants.SNOW_TREE_2, 4800, 400], [constants.SNOW_TREE_2, 5800, 400], [constants.SNOW_SNOWMAN, 6000, 470], [constants.SNOW_TREE_1, 6200, 280], [constants.SNOW_ICEBOX, 6550, 500], [constants.SNOW_SIGNARROW, 6700, 470], [constants.SNOW_TREE_1, 6900, 280], [constants.SNOW_TREE_1, 7100, 280], [constants.SNOW_TREE_1, 7300, 280], [constants.SNOW_TREE_1, 7500, 280], [constants.SNOW_TREE_1, 7800, 280], ] # Go through the array above and add good object for good_object in good_object_array: obj = objects.Object(good_object[0]) obj.rect.x = good_object[1] obj.rect.y = good_object[2] obj.player = self.player self.good_object_list.add(obj) # Go through the array above and add bad object for bad_object in bad_object_array: obj = objects.Object(bad_object[0]) obj.rect.x = bad_object[1] obj.rect.y = bad_object[2] obj.player = self.player self.bad_object_list.add(obj) # Go through the array above and add standard object for standard_object in standard_object_array: obj = objects.Object(standard_object[0]) obj.rect.x = standard_object[1] obj.rect.y = standard_object[2] obj.player = self.player self.standard_object_list.add(obj) # Add a custom moving platform block = platforms.MovingPlatform( constants.SNOW_STONE_PLATFORM_TOP_MIDDLE) block.rect.x = 1000 block.rect.y = 400 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
titer = 1 NITER = 257 maxint = 10 voxelsize = 1e-6 energy = 5 # Load a 3D object. beta = dxchange.read_tiff( 'data/test-beta-128.tiff').astype('float32')[::2, ::2, ::2] delta = dxchange.read_tiff( 'data/test-delta-128.tiff').astype('float32')[::2, ::2, ::2] #beta=beta/beta.max() #delta=delta/delta.max() # Create object. obj = objects.Object(beta, delta, voxelsize) # Create probe. prb = objects.Probe(gaussian(15, rin=0.8, rout=1.0), maxint=maxint) # Detector parameters. det = objects.Detector(63, 63) # Define rotation angles. theta = np.linspace(0, 2*np.pi, 720).astype('float32') # Raster scan parameters for each rotation angle. scan, scanax, scanay = scanner3(theta, beta.shape, 6, 6, margin=[ prb.size, prb.size], offset=[0, 0], spiral=1) tomoshape = [len(theta), obj.shape[1], obj.shape[2]] # class solver slv = solver_gpu.Solver(prb, scanax, scanay, theta, det, voxelsize, energy, tomoshape)