Exemple #1
0
    def __init__(self):
        super(GameModel,self).__init__()
        self.food_range = [ x for x in range(MAP_WIDTH*MAP_HEIGHT)]

        self.wall = []
        self.init()
        self.init_food()
        self.overlapcount = 0
        self.detatime = 0
        status.reset()
Exemple #2
0
 def __init__(self):
     super(Model, self).__init__()
     self.choice = None
     self.cpu_choice = None
     status.reset()
     
     self.player_choices = [Rock(), Paper(), Shotgun()]
     count = 0
     for c in self.player_choices:
         c.position = (100 + count, 100 )
         count += 50
Exemple #3
0
 def __init__(self):
     super(Model, self).__init__()
     self.cursor = Cursor()
     self.player = Player()
     self.mobs = []
     self.tardis = None
     self.mob_active_bullets = set([])
     self.mob_spawn_rate = 50
     self.mob_spawn_counter = 0
     self.scroller = None
     #self.level = Level()
     status.reset()
Exemple #4
0
    def __init__(self, background_layer):
        super(GameModel, self).__init__()

        self.background_layer = background_layer

        self.bird = None
        self.pipes = list()

        self.width, self.height = director.get_window_size()

        status.reset()

        status.level = levels.levels[0]
Exemple #5
0
    def __init__(self):
        super(GameModel, self).__init__()

        self.init()

        # current block
        self.block = None

        # grid
        self.map = {}

        status.reset()

        # phony level
        status.level = levels.levels[0]
Exemple #6
0
    def __init__(self):
        super(GameModel,self).__init__()

        self.init()

        # current block
        self.block = None

        # grid
        self.map = {}

        status.reset()


        # phony level
        status.level = levels.levels[0]
Exemple #7
0
    def __init__(self):
        super(GameModel, self).__init__()

        self.init_map()

        # current character
        self.character = Character()

        # grid
        self.map = {}

        # init
        status.reset()

        # phony level
        status.level = levels.levels[0]
Exemple #8
0
    def __init__(self):
        super(GameModel,self).__init__()

        self.init_map()

        # current character
        self.character = Character()

        # grid
        self.map = {}

        # init
        status.reset()


        # phony level
        status.level = levels.levels[0]
    def update(self, dt):  #Updates the scene
        self.collisions.clear()
        for z, node in self.children:
            self.collisions.add(node)
        buttons = self.buttons
        ###############PLAYER CONTROLS & COLLISIONS###############
        ma = buttons['right'] - buttons['left']
        if ma != 0:
            self.player.rotation += ma * dt * self.ang_velocity
            a = math.radians(self.player.rotation)
            self.impulse_dir = euc.Vector2(math.sin(a), math.cos(a))

        new_velocity = self.player.vel
        mv = buttons['up']
        mvdn = buttons['down']
        nv = new_velocity.magnitude()

        if mvdn != 0:  #reverse movement
            new_velocity += mvdn * self.acceleration * -(self.impulse_dir)
            new_velocity *= (status.stamina / 100.0)
            if status.stamina > 10:
                status.stamina -= 0.2
            if nv > self.top_speed:
                new_velocity *= self.top_speed / nv
        if mv != 0:  #forward movement
            new_velocity += mv * self.acceleration * self.impulse_dir
            new_velocity *= (status.stamina / 100.0)
            if status.stamina > 10:
                status.stamina -= 0.2
            if nv > self.top_speed:
                new_velocity *= self.top_speed / nv
        if mv == 0 and mvdn == 0:  #stop moving
            new_velocity = euc.Vector2(0.0, 0.0)
        player_position = self.player.cshape.center
        r = self.player.cshape.r

        while dt > 1.e-6:
            new_position = player_position + dt * new_velocity
            dt_minus = dt
            if new_position.x < r or new_position.x > (
                    self.width - r) or new_position.y < r or new_position.y > (
                        self.height - r):
                status.level += 1
                director.push(get_newgame())
            for colliding in self.collisions.iter_colliding(self.player):
                typecoll = colliding.btype
                if typecoll == 'wall':
                    new_velocity = -new_velocity
                    status.health -= 0.04
                elif typecoll == 'enemy':
                    status.health -= 0.1 * status.level  #Enemy damage multiplies each level
                elif typecoll == 'health':
                    status.health = 100

            dt -= dt_minus
            if status.stamina <= 100 and mvdn == 0 and mv == 0:
                status.stamina += 1
        self.player.vel = new_velocity
        self.player.update_center(new_position)
        #key bindings
        if buttons['escape'] != 0 or status.health <= 0.0:
            status.reset()  #player stats, level reset to defaults
            scene = cocos.scene.Scene()
            scene.add(
                game.MultiplexLayer(game.Main_Menu(), game.Options_Menu()))
            director.run(scene)

        for node in self.toRemove:
            self.remove(node)
        self.toRemove.clear()
Exemple #10
0
 def init(self):
     #set base conditions so we can load a new level
     #self.player = Player()
     #self.level = Level()
     status.reset()