コード例 #1
0
import pyglet
import utils
import math
import bullet
import item
from pyglet.window import key

pyglet.resource.path.append('./images')
pyglet.resource.reindex()
ship_image = pyglet.resource.image('ship1_pur.png')
utils.center_anchor(ship_image)
ship_image_on = pyglet.resource.image('ship_on_pur.png')
utils.center_anchor(ship_image_on)
lyla_image = pyglet.resource.image('lyla.jpg')
utils.center_anchor(lyla_image)


class Ship(pyglet.sprite.Sprite, key.KeyStateHandler):
    def __init__(self,
                 image,
                 window_height,
                 window_width,
                 x=0,
                 y=0,
                 dx=0,
                 dy=0,
                 rotv=0,
                 planet=None,
                 batch=None):
        super(Ship, self).__init__(image, x, y, batch=batch)
        self.x = x
コード例 #2
0
ファイル: bullet.py プロジェクト: Trajan99/SPaceSHip
import pyglet
import utils
from pyglet.window import key

pyglet.resource.path.append('./images')
pyglet.resource.reindex()
#bullet_image = pyglet.resource.image('bullet2.png')
bullet_image = pyglet.resource.image('bullet2.png')
utils.center_anchor(bullet_image)
eliot_image = pyglet.resource.image('bullet_eliot.jpg')
utils.center_anchor(eliot_image)


class Bullet(pyglet.sprite.Sprite, key.KeyStateHandler):
    def __init__(self,
                 window_width,
                 window_height,
                 x=0,
                 y=0,
                 dx=0,
                 dy=0,
                 ship=None,
                 batch=None,
                 image=bullet_image,
                 timer=5):
        super(Bullet, self).__init__(image, x, y, batch=batch)
        self.x = x
        self.y = y
        self.dx = dx
        self.dy = dy
        self.radius = self.image.width / 2
コード例 #3
0
import pyglet
import utils
import math
from pyglet.window import key

pyglet.resource.path.append('./images')
pyglet.resource.reindex()
monster_image = pyglet.resource.image('monster1.png')
utils.center_anchor(monster_image)

class Monster(pyglet.sprite.Sprite):
	def __init__(self, x=0, y=0, dx=0, dy=0, batch=None):
		super(Monster, self).__init__(monster_image, x, y, batch=batch)
		self.x = x
		self.y = y
		self.radius = self.image.width / 2
コード例 #4
0
ファイル: myship.py プロジェクト: Trajan99/SPaceSHip
#Things that change at levels
max_aliens = [3 + i for i in range(100)]
alien_brains = [1 - 0.85 ** n for n in range(100)]
bullet_freq = [2 + 2 * (0.5 ** n) for n in range(100)]
kill_advance = [3 + 1 * i for i in range(100)]
#kill_advance = [2000 + 1 * i for i in range(100)]

window = pyglet.window.Window(fullscreen=True)
pyglet.resource.path.append('./images')
pyglet.resource.path.append('./audio')
pyglet.resource.reindex()


planet_image = pyglet.resource.image('earth.jpg')
utils.center_anchor(planet_image)
ship_image = pyglet.resource.image('ship1_pur.png')
utils.center_anchor(ship_image)
ship_image_on = pyglet.resource.image('ship_on_pur.png')
utils.center_anchor(ship_image_on)
alien_image = pyglet.resource.image('monster1.png')
utils.center_anchor(alien_image)
eliot_image = pyglet.resource.image('bullet_eliot.jpg')
utils.center_anchor(eliot_image)
#bullet_sound = pyglet.resource.media('bullet_long.wav', streaming=False)
high_score_file = 'high_score.csv'


class Planet(pyglet.sprite.Sprite, key.KeyStateHandler):
	def __init__(self, image, x=0, y=0, batch=None):
		super(Planet, self).__init__(
コード例 #5
0
ファイル: item.py プロジェクト: Trajan99/SPaceSHip
pyglet.resource.path.append('./images')
pyglet.resource.reindex()

item_list = ['life']
item_image_files = {'life' : 'ship1_mini.png'}
item_freq = {'life' : 4000}
item_max = {'life' : 1}
lose_on_reset = []
item_images = {}

give_life = ['life']

for an_item in item_list:
	item_images[an_item] = pyglet.resource.image(item_image_files[an_item])
	utils.center_anchor(item_images[an_item])

class Item(pyglet.sprite.Sprite, key.KeyStateHandler):
	def __init__(self, item_type, x=0, y=0, ship=None, batch=None, timer=20):
		super(Item, self).__init__(item_images[item_type], x, y, batch=batch)

		self.dx = 0
		self.dy = 0
		self.timer = timer #how long it lasts after spawn
		self.ship = ship
		self.image = item_images[item_type]
		self.radius = max(self.image.height, self.image.width) / 2
		self.location = self.ship.planet
		self.location.items.append(self)
		self.type = item_type
		self.on_ship = False
コード例 #6
0
ファイル: alien.py プロジェクト: Trajan99/SPaceSHip
import pyglet
import utils
import random
import math
import bullet

pyglet.resource.path.append('./images')
pyglet.resource.reindex()

alien_image = pyglet.resource.image('monster1.png')
utils.center_anchor(alien_image)
bullet_image = pyglet.resource.image('bullet3.png')
utils.center_anchor(bullet_image)


class Alien(pyglet.sprite.Sprite):
    def __init__(self,
                 image,
                 window_width,
                 window_height,
                 ship,
                 planet,
                 x=0,
                 y=0,
                 dx=0,
                 dy=0,
                 batch=None,
                 brains=0.5,
                 bullet_freq=2):
        super(Alien, self).__init__(alien_image, x, y, batch=batch)