Example #1
0
      pass
    def draw(self, screen):
      if not self.unit.checkAlive():
        return
      ration = self.unit.getHp() / self.maxHp
#      print(ration, self.position)
      if ration < 0:
        ration = 0
      if ration > 1:
        ration = 1
      screen.draw(self.image.getSubImage((0, 0), (self.imageSize.getX() * ration, self.imageSize.getY())), self.position - self.imageSize / 2)
  def __init__(self, unit, maxHp, position):
    RunnableList.__init__(self)
    self.append(GameObject(image = 'graphics/lifeBox.bmp', position = position))
    self.append(self.Bar(unit, maxHp, position))

class UnitStatusViewer(RunnableList):
  def __init__(self, unit, maxHp, position = Coordinate(0, 0)):
    RunnableList.__init__(self)
    self.unit = unit
    self.position = Coordinate(position)
    unitImage = unit.getImage()
    self.append(GameObject(image = unitImage,
                           position = self.position - Coordinate(60, 0)))
    self.append(LifeBar(unit, maxHp, self.position + Coordinate(20, 0)))

if __name__ == '__main__':
  unit = GameObject(image = Image('lifeBar.bmp', permeate = False))
  unit.hp = 80
  run(UnitStatusViewer(unit, 100, (400, 300)))
Example #2
0
import os
import sys

sys.path.append(os.path.abspath("ai"))
sys.path.append(os.path.abspath("aiLibrary"))
sys.path.append(os.path.abspath("setting"))
sys.path.append(os.path.abspath("graphics"))
sys.path.append(os.path.abspath("AiContest2012"))
sys.path.append(os.path.abspath("config"))
sys.path.append(os.path.abspath("mapData"))

import gameManager
from ymzkgame import runner

if __name__ == "__main__":
    runner.run(gameManager.GameManager())
Example #3
0
from ymzkgame.runnable import Runnable
from ymzkgame.gameObject import GameObject
from ymzkgame.runner import run
from ymzkgame.manager import Manager
from ymzkgame.image import Image
from playMode import PlayMode

class Menu(GameObject):
  def __init__(self):
    GameObject.__init__(self, image = Image('graphics/title.bmp', permeate = False), position = (400, 300))
  def step(self):
    GameObject.step(self)
    if any(Manager.getKeyStatus(key) for key in (Manager.K_SPACE,
                                                 Manager.K_z)):
      return PlayMode()

if __name__ == '__main__':
  run(Menu())
Example #4
0
        print("team 0 win")
      elif self._defeatTeam == 3:
        print("draw")
      self.end()
    for i in self.units:
      i.sendData()
  
  def draw(self, screan):
    self.field.draw(screan,self._viewPoint)
    self.bases.draw(screan, self._viewPoint)
    self.units.draw(screan, self._viewPoint)
    self.bullets.draw(screan, self._viewPoint)
    self.items.draw(screan, self._viewPoint)
  def readKeyEvent(self):
    self._viewPoint = GetKeyEvent(self._viewPoint, self.units, self.debugObjects)
  def end(self):
    for i in self.units:
      i.sendEndMessage()
    self.field.end()
    self.bases.end()
    self.units.end()
    self.bullets.end()
    self.items.end()
    time.sleep(3)
    Runnable.end(self)
    


if __name__ == "__main__":
  run( GameManager())
Example #5
0
from ymzkgame.runner import run
from ymzkgame.runnable import Runnable
from ymzkgame.gameObject import GameObject
from ymzkgame.moveClasses import *
from ymzkgame.manager import Manager
from ymzkgame.coordinate import Coordinate
from ymzkgame.image import Image

run(GameObject(image = Image().getSubImage((16, 16), (16, 16)), move = MoveByKey(velocity = 2)))