本文整理汇总了Python中terrain.Terrain类的典型用法代码示例。如果您正苦于以下问题:Python Terrain类的具体用法?Python Terrain怎么用?Python Terrain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Terrain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:bevingtona,项目名称:earthengine-api,代码行数:35,代码来源:__init__.py
示例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
开发者ID:daniel-wen,项目名称:bouncier,代码行数:10,代码来源:main.py
示例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)
开发者ID:theall,项目名称:Python-Tiled,代码行数:15,代码来源:editterraindialog.py
示例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)
开发者ID:Dejmas,项目名称:Terrain,代码行数:28,代码来源:main.py
示例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
开发者ID:eychung,项目名称:animats,代码行数:26,代码来源:game.py
示例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()
开发者ID:daniel-wen,项目名称:bouncier,代码行数:17,代码来源:main.py
示例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
开发者ID:NiccosSystem,项目名称:pymine2,代码行数:57,代码来源:world.py
示例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"
)
开发者ID:RodrigoVillatoro,项目名称:machine_learning_projects,代码行数:56,代码来源:robot.py
示例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
开发者ID:irpainel,项目名称:river472,代码行数:20,代码来源:terrainMain.py
示例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()
开发者ID:bevingtona,项目名称:earthengine-api,代码行数:21,代码来源:__init__.py
示例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()
开发者ID:hartfelt,项目名称:kampvogne,代码行数:20,代码来源:kampvogne.py
示例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()
开发者ID:Rdbaker,项目名称:AI-HW-1,代码行数:21,代码来源:agent.py
示例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
开发者ID:Dejmas,项目名称:Terrain,代码行数:39,代码来源:main.py
示例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)
开发者ID:daniel-wen,项目名称:bouncier,代码行数:24,代码来源:main.py
示例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'
开发者ID:IndexErrorCoders,项目名称:PygamesCompilation,代码行数:24,代码来源:battlefield.py
示例16: populate
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'])
开发者ID:NiccosSystem,项目名称:pymine2,代码行数:24,代码来源:world.py
示例17: setUp
def setUp(self):
"""
set up data used in the tests.
setUp is called before each test function execution.
"""
pygame.init()
pygame.display.set_mode([Settings.SCREEN_WIDTH, Settings.SCREEN_HEIGHT])
self.input = Input()
self.terrain = Terrain()
self.teamName = "EJteam"
self.team = Team(self.teamName)
self.team.setGravity(Direction.DOWN)
self.team.hasTurn = True
TurnManager().status = TurnStatus.CURRENTTURN
TurnManager().teams = []
TurnManager().teams.append(self.team)
self.snail = Snail(self.team)
self.snail.hasTurn = True
开发者ID:ryuken,项目名称:gravity-snails,代码行数:24,代码来源:unittest_snail.py
示例18: Game
#.........这里部分代码省略.........
self.car.blade_spining=True
self.grass.mower_blade.show()
def setup(self):
self.worldNP = render.attachNewNode('World')
# World
self.debugNP = self.worldNP.attachNewNode(BulletDebugNode('Debug'))
self.debugNP.hide()
self.world = BulletWorld()
self.world.setGravity(Vec3(0, 0, -9.81))
self.world.setDebugNode(self.debugNP.node())
# Plane
#shape = BulletPlaneShape(Vec3(0, 0, 1), 0)
#mesh = BulletTriangleMesh()
#geomNodes = loader.loadModel('levels/test1/collision').findAllMatches('**/+GeomNode')
#geomNode = geomNodes.getPath(0).node()
#geom = geomNode.getGeom(0)
#mesh.addGeom(geom)
#shape = BulletTriangleMeshShape(mesh, dynamic=False, bvh=True )
#np = self.worldNP.attachNewNode(BulletRigidBodyNode('Ground'))
#np.node().addShape(shape)
#np.setPos(0, 0, 20.0)
#np.setCollideMask(BitMask32.allOn())
#self.world.attachRigidBody(np.node())
#sky dome
self.sun_sky=Sky()
self.sun_sky.setTime(17.0)
#terrain
self.ground=Terrain(self.world, self.worldNP)
self.ground.loadMesh(path+'levels/gandg2/collision')
self.ground.setMaps(path+'levels/gandg2/')
self.ground.setTextures((39, 1, 2, 15, 4, 5))
#grass
self.grass=Grass()
self.grass.setMap(path+'levels/gandg2/grass.png')
self.grass_to_cut=self.grass.getStatus()
# Car
self.car=Car(self.world, self.worldNP)
self.car.setPos(161.0,160.0,26)
#camera
self.camera=FlyingCamera()
#car to character scale 0.0128
self.char=Character(self.world, self.worldNP)
self.char.enterCar()
#self.char.setPos(256, 250, 80)
#filter manager, post process
self.filters=Postprocess()
#self.filters.setupFxaa()
#no time to make it work, sorry...
self.filters.setupFilters()
#map objects .. hardcoded because of time
self.object_root=render.attachNewNode('object_root')
obj=[
(path+'models/pyweek_wall1',0.0,(303.0,405.0,25.0980415344238),path+'models/pyweek_wall1_collision'),
(path+'models/pyweek_wall1',0.0,(301.0,405.0,25.0980434417725),path+'models/pyweek_wall1_collision'),
(path+'models/pyweek_wall1',0.0,(299.0,405.0,25.0980415344238),path+'models/pyweek_wall1_collision'),
开发者ID:wezu,项目名称:pyweek21,代码行数:67,代码来源:game.py
示例19: 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 ()
开发者ID:irpainel,项目名称:river472,代码行数:5,代码来源:terrainMain.py
示例20: __init__
def __init__(self, name, locations=None, map=None, color="black"):
Terrain.__init__(self, name, locations, map)
self._color = color
开发者ID:markllama,项目名称:hexgame-research,代码行数:3,代码来源:vertexterrain.py
注:本文中的terrain.Terrain类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论