Esempio n. 1
0
 def add_monster(self, monster):
     monster_image = Image(monster)
     screen_width = self.screen_size[GameConfig.WIDTH_INDEX]
     init_x = random.randint(screen_width, screen_width + 50)
     init_y = random.randint(0, self.screen_size[GameConfig.HEIGHT_INDEX] - 50)
     monster_image.position = Point(init_x, init_y)
     
     sprite = Zombie(5, monster_image, 10)
     
     self.monster_sprite_group.add(sprite)
Esempio n. 2
0
 def setup(self):
     super(PVZMainScreen, self).setup()
     # Preload monster sprites
     meteormon_img = os.path.join("sample_sprites", "notmine", "meteormon_clueless.png")
     bakemon_img = os.path.join("sample_sprites", "notmine", "bakemon_attack.png")
     lalamon_img = os.path.join("sample_sprites", "notmine", "lalamon_clueless.png")
     tentacly_img = os.path.join("sample_sprites", "notmine", "tentacly_angry.png")
     self.__monster_list = [meteormon_img, bakemon_img, lalamon_img, tentacly_img]
     
     # Load the character sprite
     shooter_image = Image(os.path.join("sample_sprites", "notmine", "seahomon_hero.png"))
     shooter_image.flip(True, False)
     
     shooter_image.position = Point(0, super(PVZMainScreen, self).screen_size[GameConfig.HEIGHT_INDEX] / 2)
     
     self.__shooter_sprite = Shooter(7, shooter_image, 10, self.screen_size[GameConfig.WIDTH_INDEX])
     self.player_sprite_group.add(self.shooter_sprite)
Esempio n. 3
0
  def process_image(self, form, model):
    if request.form.has_key('image-0'):
      newfilename  = request.form['image-0']
      uploadFolder = flask.current_app.config['UPLOAD_FOLDER']
      mirrorPath   = os.path.join(uploadFolder, 'mirror', request.form['image-0'])
      newPath      = os.path.join(uploadFolder, 'pictures', newfilename)
      thumbPath    = os.path.join(uploadFolder, 'pictures', 'thumbs', newfilename)
      box = (
        int(float(request.form['image-0x'])),
        int(float(request.form['image-0y'])),
        int(float(request.form['image-0x2'])),
        int(float(request.form['image-0y2']))
      )

      img = ImageKit(mirrorPath)
      img.crop(box)
      img.resize((1024, 600))
      img.save(newPath)

      thumb = ImageKit(newPath)
      thumb.thumbnail((260, 150))
      thumb.save(thumbPath)

      model.image = newfilename
      models.db.session.add(model)
      models.db.session.commit()

      if isfile(mirrorPath):
        os.remove(mirrorPath)

      if model and hasattr(model, 'id') and model.id > 0:
        if request.form.has_key('image-old') and request.form['image-old'] != newfilename:
          oldphoto = request.form['image-old']
          oldpath = os.path.join(uploadFolder, 'pictures', oldphoto)

          if isfile(oldpath):
            os.remove(oldpath)
from components.image import Image

import os

import pygame

"""
Image exception test results.

Scenario: File specified does not exist.
In this case, the call to pygame.image.load ... already throws
an Exception and it is pointless to throw our own custom Exception.

Scenario: File specified is deleted after load.
Does not seem to affect program flow in any way.

Also, this resource does not seem to need closing.

@author Chad Estioco
"""

pygame.display.set_mode([500, 500])
nonexistent = Image(os.path.join("sample_sprites", "lalamon_clueless.png"));

# Set-up blocking code...
foo = raw_input("Press enter when you have moved lalamon_clueless.png");

nonexistent.flip(True, False)

print "If you got here, deleting the resource does nothing."