Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
gnumch.Player Class Reference
Inheritance diagram for gnumch.Player:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def spawn
def die
def getEaten
def isAt
def isNear
def move_step
def move
def startMunching
def stopMunching
def stop

Public Attributes

 move_stepnum
 x
 y
 x_old
 y_old
 moving
 exists
 action_start
 anim
 velocity
 movestep_timer
 munch_timer
 foodchain

Detailed Description

Definition at line 302 of file gnumch.py.


Constructor & Destructor Documentation

def gnumch.Player.__init__ (   self)

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 304 of file gnumch.py.

00304 
00305     def __init__(self):
00306         self.move_stepnum = 0
00307         self.x = self.y = self.x_old = self.y_old = -1
00308         self.moving = self.exists = False
00309         self.action_start = 0
00310         self.anim = None
00311         self.velocity = []
00312 
00313         self.movestep_timer = 0
00314         self.munch_timer = 0
00315 
00316         # food chain status
00317         self.foodchain = 0


Member Function Documentation

def gnumch.Player.die (   self)

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 322 of file gnumch.py.

00322 
00323     def die(self):
00324         if self.movestep_timer != 0:
00325             gtk.timeout_remove(self.movestep_timer)
00326             self.movestep_timer = 0
00327         if self.munch_timer != 0:
00328             gtk.timeout_remove(self.munch_timer)
00329             self.munch_timer = 0

Here is the caller graph for this function:

def gnumch.Player.getEaten (   self)

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 330 of file gnumch.py.

00330 
00331     def getEaten(self):
00332         pass

Here is the caller graph for this function:

def gnumch.Player.isAt (   self,
  x,
  y 
)

Definition at line 333 of file gnumch.py.

00333 
00334     def isAt(self, x, y):
00335         return self.exists and not self.moving and (self.x == x and self.y == y)

def gnumch.Player.isNear (   self,
  x,
  y 
)

Definition at line 336 of file gnumch.py.

00336 
00337     def isNear(self, x, y):
00338         return self.exists and (    (self.x == x and self.y == y)
00339                                 or  (self.moving and self.x_old == x
00340                                                  and self.y_old == y)
00341                                )

def gnumch.Player.move (   self,
  x_old,
  y_old,
  x,
  y 
)

Reimplemented in gnumch.Troggle.

Definition at line 361 of file gnumch.py.

00361 
00362     def move(self, x_old, y_old, x, y):
00363         self.x_old = x_old
00364         self.y_old = y_old
00365         self.x = x
00366         self.y = y
00367         self.velocity = [x-x_old, y-y_old]
00368         self.anim.gnomecanvas.set(x=(self.x_old * game.sw + game.left),
00369                                    y=(self.y_old * game.sh + game.top))
00370         self.moving = True
00371 
00372         # it takes game.num_moveticks iterations of duration game.move_tick to move squares
00373         if x != x_old or y != y_old:
00374             self.anim.setState(1)
00375             self.movestep_timer = game.timeout_add(game.move_tick, self.move_step)
00376         else:
00377             self.stop()

Here is the call graph for this function:

Here is the caller graph for this function:

def gnumch.Player.move_step (   self)

Definition at line 342 of file gnumch.py.

00342 
00343     def move_step(self):
00344         if self.move_stepnum < game.num_moveticks-1:
00345             self.move_stepnum += 1
00346             x_old = self.anim.gnomecanvas.get_property("x")
00347             y_old = self.anim.gnomecanvas.get_property("y")
00348             x = self.anim.gnomecanvas.get_property("x") + self.velocity[0]*game.sw/game.num_moveticks
00349             y = self.anim.gnomecanvas.get_property("y") + self.velocity[1]*game.sh/game.num_moveticks
00350             ret = True
00351         else:
00352             self.move_stepnum = 0
00353             x = game.sw * self.x + game.left
00354             y = game.sh * self.y + game.top
00355             self.stop()
00356             self.movestep_timer = 0
00357             ret = False
00358 
00359         self.anim.gnomecanvas.set(x=x, y=y)
00360         return ret

Here is the call graph for this function:

Here is the caller graph for this function:

def gnumch.Player.spawn (   self)

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 319 of file gnumch.py.

00319 
00320     def spawn(self):
00321         pass

Here is the caller graph for this function:

Definition at line 378 of file gnumch.py.

00378 
00379     def startMunching(self):
00380         self.anim.setState(2)
00381         self.munch_timer = game.timeout_add(game.munch_time, self.stopMunching)
00382         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def gnumch.Player.stop (   self)

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 388 of file gnumch.py.

00388 
00389     def stop(self):
00390         self.anim.setState(0)
00391         self.moving = False
00392 
00393         # work out eating stuff
00394         for p in game.players:
00395             if p.isAt(self.x, self.y) and p != self:
00396                 if self.foodchain >= p.foodchain:
00397                     p.getEaten()
00398                     self.startMunching()
00399                 else:
00400                     self.getEaten()
00401                     p.startMunching()
00402 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 383 of file gnumch.py.

00383 
00384     def stopMunching(self):
00385         self.munch_timer = 0
00386         self.anim.setState(0)
00387         return False

Here is the caller graph for this function:


Member Data Documentation

Definition at line 308 of file gnumch.py.

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 309 of file gnumch.py.

Reimplemented in gnumch.Troggle, and gnumch.Muncher.

Definition at line 307 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 316 of file gnumch.py.

Definition at line 305 of file gnumch.py.

Definition at line 312 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 307 of file gnumch.py.

Definition at line 313 of file gnumch.py.

Definition at line 310 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 306 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 306 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 306 of file gnumch.py.

Reimplemented in gnumch.Troggle.

Definition at line 306 of file gnumch.py.


The documentation for this class was generated from the following file: