本文整理汇总了Python中terrain.Terrain类的典型用法代码示例。如果您正苦于以下问题:Python Terrain类的具体用法?Python Terrain怎么用?Python Terrain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Terrain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Initialize
def Initialize(credentials="persistent", opt_url=None):
"""Initialize the EE library.
If this hasn't been called by the time any object constructor is used,
it will be called then. If this is called a second time with a different
URL, this doesn't do an un-initialization of e.g.: the previously loaded
Algorithms, but will overwrite them and let point at alternate servers.
Args:
credentials: OAuth2 credentials. 'persistent' (default) means use
credentials already stored in the filesystem, or raise an explanatory
exception guiding the user to create those credentials.
opt_url: The base url for the EarthEngine REST API to connect to.
"""
if credentials == "persistent":
credentials = _GetPersistentCredentials()
data.initialize(credentials, (opt_url + "/api" if opt_url else None), opt_url)
# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
Terrain.initialize()
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
示例2: init
def init(self):
self.initStyles()
self.initMaps()
Terrain.initImages()
Terrain.initSounds()
self.initMenus()
self.stopwatch = Stopwatch()
self.initHelp()
self.mode = "menu"
self.menu = self.mainMenu
示例3: addTerrainType
def addTerrainType(self, tile = None):
if tile:
x = tile.id()
else:
x = -1
terrain = Terrain(self.mTileset.terrainCount(), self.mTileset, QString(), x)
terrain.setName(self.tr("New Terrain"))
self.mMapDocument.undoStack().push(AddTerrain(self.mMapDocument, terrain))
# Select the newly added terrain and edit its name
index = self.mTerrainModel.index(terrain)
selectionModel = self.mUi.terrainList.selectionModel()
selectionModel.setCurrentIndex(index,
QItemSelectionModel.ClearAndSelect |
QItemSelectionModel.Rows)
self.mUi.terrainList.edit(index)
示例4: __init__
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
pyglet.clock.schedule_interval(self.update, 1./60)
self.strafe = [0, 0]
def fps(dt): print 'FPS is %f' % pyglet.clock.get_fps()
pyglet.clock.schedule_interval(fps, 2)
# Current (x, y, z) position in the world, specified with floats. Note
# that, perhaps unlike in class, the y-axis is the vertical axis.
self.position = (12, 8, 12)
self.press = {}
self.press["light"] = 0
# First element is rotation of the player in the x-z plane (ground
# plane) measured from the z-axis down. The second is the rotation
# angle from the ground plane up. Rotation is in degrees.
#
# The vertical plane rotation ranges from -90 (looking straight down) to
# 90 (looking straight up). The horizontal rotation range is unbounded.
self.rotation = (0, 0)
self.reticle = None
self.t = Terrain(a=33,water_line=1.5,generate=False)
self.spin = 180
self.fps = pyglet.clock.ClockDisplay()
#self.skybox = SkyBox.fromDir("../example/texture/bluesky", "bluesky")
#self.skybox = SkyBox.fromDir("../example/texture/lake2", "jajlake2")
self.kostka = Kostka(self.t)
示例5: on_init
def on_init(self):
pygame.init()
self.screen = pygame.display.set_mode(
self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
# Fill background and blits everything to the screen
self.background = pygame.Surface(self.size)
self.background = self.background.convert()
self.background.fill(BG_COLOR)
self.screen.blit(self.background, (0, 0))
pygame.display.flip()
self.terrain = Terrain()
self.beaver = Beaver()
self.beaversprite = pygame.sprite.RenderPlain(self.beaver)
self.generationtime = pygame.time.get_ticks()
self.brain = Brain()
self.brain.environment.setbeaver(self.beaver)
self.wolf = Wolf()
self.wolfsprite = pygame.sprite.RenderPlain(self.wolf)
self._clock = pygame.time.Clock()
self._running = True
示例6: nextLevel
def nextLevel(self):
# Update and save progress
saved = self.progress[self.level]
if saved["score"] == None or self.score > saved["score"]:
saved["score"] = self.score
duration = self.stopwatch.getSeconds()
if saved["time"] == None or duration < saved["time"]:
saved["time"] = duration
self.progress.save()
# Load next level
Terrain.playSound("happy")
index = self.maps.levels.index(self.level) + 1
if index >= len(self.maps.levels):
self.mode = "win"
else:
self.level = self.maps.levels[index]
self.loadLevel()
示例7: __init__
class World:
def __init__(self, server, path):
self.server = server
self.chunks = {}
self.entities = []
self.spawnPoint = (8, 150, 8) #todo: use data from level.dat
self.path = path
def populate(self):
if not os.path.exists(self.path):
os.mkdir(self.path)
if os.path.exists('%s/level.dat' % self.path):
cantLoad = False
f = open('%s/level.dat' % self.path, 'r')
try:
json.loads(f.read())
except:
cantLoad = True
self.server.log.error('level.dat unreadable or unparsable - resetting')
f.close()
defaults = {'seed': random.randrange(-9999999, 9999999),
'time': 0,
'name': ''
}
if not os.path.exists('%s/level.dat' % self.path) or cantLoad:
f = open('%s/level.dat' % self.path, 'w')
f.write(json.dumps(defaults))
f.close()
f = open('%s/level.dat' % self.path, 'r')
self.level = json.loads(f.read())
f.close()
self.terrain = Terrain(self.level['seed'])
#for x in range(16):
# row = []
# for z in range(16):
# row.append(self.terrain.generate(x, z))
# self.chunks.append(row)
#print self.chunks[0][0].blocks[0][0][0]
def touch(self, x, z): # same as unix touch command, basically creates a chunk file if it doesn't exist, otherwise keeps it
try:
self.chunks[x][z]
except:
if os.path.exists('%s/chunks/%s,%s' % (self.path, str(x), str(z))):
self.parseChunk(x, z)
else:
if x in self.chunks:
self.chunks[x] = {}
self.chunks[x][z] = self.terrain.generate(x, z)
return self.chunks[x][z]
def flush(self):
f = open('%s/level.dat' % self.path, 'w')
f.write(json.dumps(self.level))
f.close()
def loop(self):
self.server.log.info('World tick loop begin')
while not self.server.abort:
self.level['time'] += 1
time.sleep(.05) # 20 ticks/second is 1/20 (.05) seconds per tick
示例8: __init__
def __init__(self, maze_dim):
"""
Used to set up attributes that the robot will use to learn and
navigate the maze.
"""
# Position-related attributes
self.robot_pos = {'location': [0, 0], 'heading': 'up'} # Current pos
self.steps_first_round = 0
self.steps_final_round = 0
self.maze_dim = maze_dim
self.maze_representation = None
# Goal-related attributes
center = maze_dim/2
self.center_locations = [
[center, center], [center - 1, center],
[center, center - 1], [center - 1, center - 1]]
self.reached_destination = False
# For exploring state
self.exploring = False
self.steps_exploring = 0
self.consecutive_explored_cells = 0
# Initialize terrain
self.terrain = Terrain(maze_dim)
# Algorithm to use:
self.algorithm = None
if str(sys.argv[2]).lower() == 'ff':
self.algorithm = FloodFill()
elif str(sys.argv[2]).lower() == 'ar':
self.algorithm = AlwaysRight()
elif str(sys.argv[2]).lower() == 'mr':
self.algorithm = ModifiedRight()
else:
raise ValueError(
"Incorrect algorithm name. Options are: "
"\n- 'ff': flood-fill"
"\n- 'ar': always-right"
"\n- 'mr': modified-right (prefers unvisited cells)"
)
# Explore after reaching center of the maze:
if str(sys.argv[3]).lower() == 'true':
self.explore_after_center = True
elif str(sys.argv[3]).lower() == 'false':
self.explore_after_center = False
else:
raise ValueError(
"Incorrect explore value: Options are: "
"\n- 'true': to keep exploring after reaching the center"
"\n- 'false': to end run immediately after reaching the center"
)
示例9: __init__
class TerrainMain:
def __init__ ( self ):
#dict with the curve name as index
self.terrain = []
#the curve name will always be rCurve + index ( ie rCurve0 )
self.rCurveName = 'rCurve'
self.currentTerrain = None
self.newTerrain()
def newTerrain( self ):
self.currentTerrain = Terrain( self.rCurveName + str(len(self.terrain)) )
print self.currentTerrain.rCurveName
self.terrain.append( self.currentTerrain )
self.currentTerrain.createRiver ()
def reloadModule( self ):
import terrain
reload( terrain )
from terrain import Terrain
示例10: Reset
def Reset():
"""Reset the library. Useful for re-initializing to a different server."""
data.reset()
ApiFunction.reset()
Element.reset()
Image.reset()
Feature.reset()
Collection.reset()
ImageCollection.reset()
FeatureCollection.reset()
Filter.reset()
Geometry.reset()
List.reset()
Number.reset()
String.reset()
Date.reset()
Dictionary.reset()
Terrain.reset()
_ResetGeneratedClasses()
global Algorithms
Algorithms = _AlgorithmsContainer()
示例11: __init__
def __init__(self):
self.window = pyglet.window.Window(fullscreen=True)
self.terrain = Terrain(self.window.width, self.window.height-100)
self.players = [
Player(name, self, i)
for i, name in enumerate(sys.argv[1:])]
self.moving = []
# Setup events
self.window.event(self.on_draw)
Game.register_event_type('next_player')
Game.register_event_type('start_moving')
Game.register_event_type('stop_moving')
Game.register_event_type('explosion')
# Start the game.
self.reset()
# Run the fucker
pyglet.app.run()
示例12: __init__
def __init__(self, terrain, heuristic):
self.terrain = Terrain(terrain)
self.directions = {'N': (0, -1),
'E': (1, 0),
'S': (0, 1),
'W': (-1, 0)}
self.start_node = Node(self.terrain.get_start_position(), 'N', 0)
# Push our start position onto the heap
self.search_heap = SearchHeap(initial=[self.start_node],
g_func=lambda node: node.g,
h_func=heuristic,
goal=self.terrain.get_goal_position())
self.visited = []
self.position = list(self.terrain.get_start_position())
self.facing = 'N'
self.action_costs = {'forward': lambda cost: -cost,
'bash': lambda cost: -3,
'turn': lambda cost: -ceil(float(cost)/float(3)),
'demolish': lambda cost: -4}
print "goal position:"
print self.terrain.get_goal_position()
示例13: on_key_press
def on_key_press( self, symbol, modifier ):
global piece, bottom
if symbol == key.A:
self.strafe[1] -= 1
elif symbol == key.W:
self.strafe[0] -= 1
elif symbol == key.S:
self.strafe[0] += 1
elif symbol == key.D:
self.strafe[1] += 1
elif symbol == key.UP :
self.kostka.speed += .1
elif symbol == key.DOWN :
self.kostka.speed -= .1
elif symbol == key.LEFT :
self.kostka.input[0] = True
elif symbol == key.RIGHT :
self.kostka.input[1] = True
elif symbol == key.F :
global WIREFRAME
WIREFRAME = not WIREFRAME
if WIREFRAME :
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
else :
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
elif symbol == key.N :
self.t = Terrain(water_line=1.5,generate=True)
elif symbol == key.Q :
exit(0)
elif symbol == key.ESCAPE:
self.set_exclusive_mouse(False)
elif symbol == key.O :
self.press["light"] = 1
elif symbol == key.P :
self.press["light"] = -1
示例14: timerFiredPlay
def timerFiredPlay(self):
if (self.ball.x < self.maps.left
or self.ball.x > self.maps.left + self.maps.width or
self.ball.y < self.maps.top
or self.ball.y > self.maps.top + self.maps.height):
# Ball off map
self.killBall()
collided = pygame.sprite.spritecollide(self.ball, self.terrain, False,
Terrain.collidedFn)
if len(collided) > 0:
elements = Terrain.manageCollision(self.ball, collided)
for element, direction in elements:
result = element.interactFromDir(self.ball, direction)
if result == "score":
self.score += element.points
elif result == "win":
self.nextLevel()
elif result == "fly":
self.ballFly(self.ball, element)
elif result == "kill":
self.killBall()
self.ball.update(self.isKeyPressed)
示例15: __init__
def __init__(self, screen, sfx, rand):
self.level = 1
self.ship_type = 1 # 0, 1, 2
self.screen = screen
self.sfx = sfx
self.terrain = Terrain()
self.myship = MyShip(self.ship_type)
self.enemy_list = []
self.my_bullet_list = []
self.enemy_bullet_list = []
self.powerup_list = []
self.explosion_list = []
self.milage = RESOLUTION[1]
self.rand = rand
self.level_dat_path = LEVEL_PATH + '%02d.dat' % self.level
self.level_dat = open(self.level_dat_path).readlines()
self.next_pos = int(self.level_dat[0].split()[0])
self.status = 'game'
sfx.play_bgm()
if DEBUG: print 'init : battlefield'