Skip to content

Commit

Permalink
First steps for a movement and pathfinding engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian R. A. Angermeier committed Jun 19, 2011
1 parent 3c8b8f3 commit 93dbc32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
29 changes: 27 additions & 2 deletions gameEngine/lv_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__( self, id, world, gender ):
self.id = id
self.world = world
self.pos = [ 0, 0, 0 ]
self.destination = [ 0, 0, 0 ]

if( gender.lower() == 'random' ):
self.gender = choice( ( 'male', 'female' ) )
Expand All @@ -37,10 +38,34 @@ def __init__( self, id, world, gender ):
'hygiene': 1000,
'fun': 1000,
'social': 1000 }

def move( self, x, y, z ):

def teleportTo( self, x, y, z ):
print 'DEBUG: Character %i teleports to X: %i Y: %i Z: %i.' % ( self.id, x, y, z )
self.pos = [ x, y, z ]

def goTo( self, x, y, z ):
print 'DEBUG: Character %i goes to X: Y: %i %i Z: %i.' % ( self.id, x, y, z )
self.destination = [ x, y, z ]

def move( self, x, y, z ):
if( self.pos[ 0 ] != self.destination[ 0 ] and self.pos[ 1 ] != self.destination[ 1 ] and self.pos[ 2 ] != self.destination[ 2 ] )
print 'DEBUG: Character %i is on his/her way.'
# X axis
if( self.pos[ 0 ] < self.destination[ 0 ] ):
self.pos[ 0 ] += 1
elif( self.pos[ 0 ] > self.destination[ 0 ] ):
self.pos[ 0 ] -= 1
# Y axis
if( self.pos[ 1 ] < self.destination [ 1 ] ):
self.pos[ 1 ] += 1
elif( self.pos[ 1 ] > self.destination[ 1 ] ):
self.pos[ 1 ] -= 1
# Z axis
if( self.pos[ 2 ] < self.destination [ 2 ] ):
self.pos[ 2 ] += 1
elif( self.pos[ 2 ] > self.destination[ 2 ] ):
self.pos[ 2 ] -= 1

def isInRange( self, characterOrObject ):
if( characterOrObject.pos[ 0 ] >= self.pos[ 0 ] - 5 and characterOrObject.pos[0] <= self.pos[ 0 ] + 5 ):
if( characterOrObject.pos[ 1 ] >= self.pos[ 1 ] - 5 and characterOrObject.pos[ 1 ] <= self.pos[ 1 ] + 5 ):
Expand Down
2 changes: 1 addition & 1 deletion gameEngine/lv_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def run( self ):
while( self.gameDay <= 7 ):
os.system('clear')
self.processTime()
self.processGravity()
# self.processGravity()
print '\033[32mInfo\033[0m World Game date: %i-%i-%i\tGame time: %i:%i:%i' % ( self.gameYear, self.gameMonth, self.gameDay, self.gameHour, self.gameMinute, self.gameSecond )
for character in self.characters:
print '\033[32mInfo\033[0m Character %i, %s' % ( character.id, character.gender )
Expand Down

0 comments on commit 93dbc32

Please sign in to comment.