Ejemplo n.º 1
0
    def update(self):
        """ Update the particle """
        if self.my_alpha <= constants.PARTICLE_FADE_RATE:
            # Faded out, remove
            self.remove_from_sprite_lists()
        else:
            # Update
            self.my_alpha -= constants.PARTICLE_FADE_RATE
            self.alpha = self.my_alpha
            self.center_x += self.change_x
            self.center_y += self.change_y
            self.change_y -= constants.PARTICLE_GRAVITY

            # Should we sparkle this?
            if random.random() == constants.PARTICLE_SPARKLE_CHANCE:
                self.alpha = 255
                self.texture = arcade.make_circle_texture(self.width, arcade.color.WHITE)
            else:
                self.texture = self.normal_texture

            # Leave a smoke particle?
            if random.random() <= constants.SMOKE_CHANCE:
                smoke = Smoke(5)
                smoke.position = self.position
                self.my_list.append(smoke)
Ejemplo n.º 2
0
def check_bullet_alien_collisions(ai_settings, screen, sounds, stats, sb, ship,
                                  aliens, ufo, bullets, barriers,
                                  alien_bullets, smokes, alien_timer,
                                  ufo_timer, smoke_timer):
    collisions = pygame.sprite.groupcollide(bullets, aliens, True, False)

    if collisions:
        for aliens in collisions.values():
            for alien in aliens:
                new_smoke = Smoke(ai_settings, screen, alien.type, alien.rect)
                smokes.add(new_smoke)
                alien.hit()
                # increases speed of aliens the fewer of them there are
                stats.score += alien.get_score()
                sb.prep_score()
        check_high_score(stats, sb)

    if len(aliens) == 0:
        alien_timer.reset()
        ufo_timer.reset()
        smoke_timer.reset()
        aliens.empty()
        ship.center_ship()
        bullets.empty()
        alien_bullets.empty()
        barriers.empty()
        smokes.empty()
        ufo.reset()

        ai_settings.increase_speed()
        stats.level += 1
        sb.prep_level()

        create_fleet(ai_settings, screen, sounds, aliens)
        create_barriers(ai_settings, screen, barriers)
Ejemplo n.º 3
0
def initSmoke():
    global smokes
    smokes = []
    for i in range(1000):
        vec = PVector(0, 0)
        velo = PVector(0, 0)
        siz = random(20, 30)
        #smoke has a velocity, size and direction
        smokes.append(Smoke(vec, velo, siz))
Ejemplo n.º 4
0
def check_bullet_ufo_collision(ai_settings, screen, stats, sb, ufo, bullets,
                               smokes):
    if pygame.sprite.spritecollide(ufo, bullets, True):
        new_smoke = Smoke(ai_settings, screen, 3, ufo.rect.copy())
        smokes.add(new_smoke)
        stats.score += ufo.get_score()
        sb.prep_score()
        check_high_score(stats, sb)
        ufo.destroy()
Ejemplo n.º 5
0
# load config from json file
print('Reading config.json file')
with open('../config.json') as json_config_file:
    config = json.load(json_config_file)
print(config)

ns = os.environ['namespace'] if 'namespace' in os.environ else 'btstalk'
mongo = MongoClient(config['mongo_url'], connect=False)
db = mongo[ns]

#nodes = [
#    os.environ['steem_node'] if 'steem_node' in os.environ else 'http://51.15.55.185:8090',
#]
nodes = config['steemd_nodes']
s = Smoke(nodes)

app = Flask(__name__)
app.json_encoder = MongoJsonEncoder
CORS(app)


def response(json, forum=False, children=False, meta=False, status='ok'):
    # Load height
    # NYI - should be cached at for 3 seconds
    statuses = db.status.find()
    network = {}
    for doc in statuses:
        network.update({str(doc['_id']): doc['value']})
    response = {'status': status, 'network': network, 'data': json}
    if forum:
Ejemplo n.º 6
0
from smoke.steemd import Smoked
from smoke.utils import block_num_from_hash

# load config from json file
print('Reading config.json file')
with open('../config.json') as json_config_file:
    config = json.load(json_config_file)
print(config)

#########################################
# Connections
#########################################

nodes = config['steemd_nodes']

s = Smoke(nodes)
d = Smoked(nodes)
b = Blockchain(steemd_instance=s, mode='head')
c = Converter(steemd_instance=s)

fn = Smoke(nodes)

# MongoDB
ns = os.environ['namespace'] if 'namespace' in os.environ else 'btstalk'
# mongo = MongoClient('mongodb://mongo')
mongo = MongoClient(config['mongo_url'])
db = mongo[ns]

# MongoDB Schema Enforcement
if not 'forum_requests' in db.collection_names():
    db.create_collection('forum_requests')
Ejemplo n.º 7
0
    def on_update(self, delta_time):
        """ Movement and game logic """

        # Call update on all sprites 
        self.physics_engine.update() 
        self.bullet_list.update()
        self.explosions_list.update()
        self.enemies.update()
        self.mask_list.update()
        self.player_list.update_animation(delta_time)

        
        for bullet in self.bullet_list:

            # Check for all the collisions that the bullet will have
            has_hit_bricks = arcade.check_for_collision_with_list(bullet, self.brick_list)
            has_hit_obstacles = arcade.check_for_collision_with_list(bullet, self.walls_and_bricks)
            has_hit_solid_blocks = arcade.check_for_collision_with_list(bullet, self.wall_list)
            has_hit_enemies = arcade.check_for_collision_with_list(bullet, self.enemies)

            for brick_hit in has_hit_bricks:
                brick_hit.explosion_sound = arcade.Sound("assets/sounds/explosion2.wav")
                brick_hit.explosion_sound.play(volume = self.volume)
                brick_hit.health -= 1

                if brick_hit.health == 3:
                    brick_hit.texture = (arcade.load_texture("assets/images/brickTextureWhite Hit1.png"))
    
                if brick_hit.health == 2:
                    brick_hit.texture = (arcade.load_texture("assets/images/brickTextureWhite Hit2.png"))

                if brick_hit.health == 1: 
                    brick_hit.texture = (arcade.load_texture("assets/images/brickTextureWhite Hit3.png"))
                    
                if brick_hit.health == 0:
                    for i in range(constants.PARTICLE_COUNT):
                        particle = Particle(self.explosions_list)
                        particle.position = brick_hit.position
                        self.explosions_list.append(particle)
                    smoke = Smoke(50)
                    smoke.position = brick_hit.position
                    self.explosions_list.append(smoke)
                    
                    brick_hit.remove_from_sprite_lists()

            for hit in has_hit_solid_blocks:
                hit.sound = arcade.Sound("assets/sounds/hurt2.wav")
        
                hit.sound.play()

            for enemie in has_hit_enemies:
                enemie.health -= 1

                if enemie.health == 3:
                    enemie.color = (255,255,0)   #Yellow    
                    enemie.change_x = enemie.change_x * 1.5 
                    enemie.change_y = enemie.change_y * 1.5 

                if enemie.health == 2:
                    enemie.color = (255,153,51)  #Orange
                    enemie.change_x = enemie.change_x * 1.5 
                    enemie.change_y = enemie.change_y * 1.5 

                if enemie.health == 1:
                    enemie.color = (255,0,0)   #Red
                    enemie.change_x = enemie.change_x * 1.5 
                    enemie.change_y = enemie.change_y * 1.5 

                if enemie.health == 0:
                    self.score += random.randint(2,5)
                    enemie.remove_from_sprite_lists()
            
            if (len(has_hit_bricks) > 0) or (len(has_hit_obstacles) > 0) or (len(has_hit_enemies) > 0):
                bullet.remove_from_sprite_lists()
                
            # if bullet is off screen, remove it.
            if bullet.bottom > self.width or bullet.top < 0 or bullet.right < 0 or bullet.left > self.width:
                bullet.remove_from_sprite_lists()

        for player in self.player_list:
            virus_player_collision = arcade.check_for_collision_with_list(player, self.enemies)
            mask_player_collision = arcade.check_for_collision_with_list(player, self.mask_list)
            # wall_collision = arcade.check_for_collision_with_list(player, self.walls_and_bricks) #Come back to this later if time
            if (len(mask_player_collision) > 0):
                for mask in mask_player_collision:
                    mask.remove_from_sprite_lists()
                    self.power = self.mask.generate_powers()

                    if self.power == "extra_health":
                        self.player_health += 1
                        self.player_sprite.color = (0,191,255)

                    elif self.power == "machine_gun":
                        self.shotgun = True

                    self.mask_count -= 1
                    self.score += random.randint(3,5)


            if (len(virus_player_collision) > 0):
                for virus in virus_player_collision:
                    virus.remove_from_sprite_lists()
                self.player_health -= 1
                if self.player_health == 1:
                    self.player_sprite.color = (255,255,255)
                if self.player_health == 0:
                    player.game_over_sound.play(volume= self.volume)
                    # self.background_music.stop(self.background_music)
                    player.remove_from_sprite_lists()
                    self.write_score_file(self.score)
                    game_over_view = GameOver()
                    self.background_music.stop(self.play_music)
                    self.window.show_view(game_over_view)
 
        #Check to see if a enemie hits an obstacle (walls, other enemie, destroyable_block)
        for enemy in self.enemies:
            # if len(arcade.check_for_collision_with_list(enemy, self.walls_and_bricks)) > 0:
            #     enemy.change_x *= -1
            #     enemy.change_y *= -1
            enemies_physics_engine = arcade.PhysicsEngineSimple(enemy, self.walls_and_bricks)  #Create basic physics engine with enemy and all walls and bricks    
            enemies_physics_engine.update()   
            self.follow_sprite(enemy, self.player_sprite)