예제 #1
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
 def __init__(self):
     self.background = Sprite('img/titleBackground.png')
     self.logo = Sprite('img/steroidsLogo.png')
     self.logo.x = 20
     self.logo.y = 20
     self.pressStart = Sprite('img/pressStart.png')
     self.pressStart.x = 320-(self.pressStart.bitmap.width/2)
     self.pressStart.y = 320
     self.fadeTime = 30
     music_player.play(pyglet.media.load('bgm/title.mp3'))
예제 #2
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
 def __init__(self):
     self.background = Sprite('img/titleBackground.png')
     self.player = Sprite('img/player.png')
     self.player.x = 320
     self.player.y = 240
     self.player.ox = self.player.bitmap.width / 2
     self.player.oy = self.player.bitmap.height / 2
     self.player_speed = 5
     self.steroid = SpaceObject(0, 0, SpaceObjectType.asteroid, 2, 2)
     self.steroid.ox = self.steroid.width / 2
     self.steroid.oy = self.steroid.height / 2
     self.steroid.angle = 45
     self.player_life = 640
     music_player.play(pyglet.media.load('bgm/stage1.mp3'))
     print("Iniciou primeiro estágio")
예제 #3
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
 def __init__(self):
     self.background = Sprite('img/titleBackground.png')
     self.player = Sprite('img/player.png')
     self.player.x = 320
     self.player.y = 240
     self.player.ox = self.player.bitmap.width/2
     self.player.oy = self.player.bitmap.height/2
     self.player_speed = 5
     self.steroid = SpaceObject(0, 0, SpaceObjectType.asteroid, 2, 2)
     self.steroid.ox = self.steroid.width/2
     self.steroid.oy = self.steroid.height/2
     self.steroid.angle = 45
     self.player_life = 640
     music_player.play(pyglet.media.load('bgm/stage1.mp3'))
     print("Iniciou primeiro estágio")
예제 #4
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
class SceneTitle(game.SceneBase):
    # Tela de título
    def __init__(self):
        self.background = Sprite('img/titleBackground.png')
        self.logo = Sprite('img/steroidsLogo.png')
        self.logo.x = 20
        self.logo.y = 20
        self.pressStart = Sprite('img/pressStart.png')
        self.pressStart.x = 320 - (self.pressStart.bitmap.width / 2)
        self.pressStart.y = 320
        self.fadeTime = 30
        music_player.play(pyglet.media.load('bgm/title.mp3'))

    def update(self):
        self.background.update(window)
        self.logo.update(window)
        self.pressStart.update(window)
        if self.fadeTime == 0:
            game.scene = SceneStage1()
        if self.fadeTime < 30:
            self.fadeTime -= 1
            #print("Remaining fade delay: "+str(self.fadeTime))
            if self.fadeTime % 5 == 0:
                self.pressStart.visible = not self.pressStart.visible

    def on_key_press(self, symbol, modifiers):
        print("Pressou tecla!")
        if symbol == key.RETURN and self.fadeTime >= 30:
            self.fadeTime -= 1
            pyglet.media.load('snd/confirm2.wav', streaming=False).play()
예제 #5
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
class SceneTitle(game.SceneBase):
    # Tela de título
    def __init__(self):
        self.background = Sprite('img/titleBackground.png')
        self.logo = Sprite('img/steroidsLogo.png')
        self.logo.x = 20
        self.logo.y = 20
        self.pressStart = Sprite('img/pressStart.png')
        self.pressStart.x = 320-(self.pressStart.bitmap.width/2)
        self.pressStart.y = 320
        self.fadeTime = 30
        music_player.play(pyglet.media.load('bgm/title.mp3'))

    def update(self):
        self.background.update(window)
        self.logo.update(window)
        self.pressStart.update(window)
        if self.fadeTime == 0:
            game.scene = SceneStage1()
        if self.fadeTime < 30:
            self.fadeTime -= 1
            #print("Remaining fade delay: "+str(self.fadeTime))
            if self.fadeTime % 5 == 0:
                self.pressStart.visible = not self.pressStart.visible

    def on_key_press(self, symbol, modifiers):
        print("Pressou tecla!")
        if symbol == key.RETURN and self.fadeTime >= 30:
            self.fadeTime -= 1
            pyglet.media.load('snd/confirm2.wav', streaming=False).play()
예제 #6
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
 def __init__(self):
     self.background = Sprite('img/titleBackground.png')
     self.logo = Sprite('img/steroidsLogo.png')
     self.logo.x = 20
     self.logo.y = 20
     self.pressStart = Sprite('img/pressStart.png')
     self.pressStart.x = 320 - (self.pressStart.bitmap.width / 2)
     self.pressStart.y = 320
     self.fadeTime = 30
     music_player.play(pyglet.media.load('bgm/title.mp3'))
예제 #7
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
class SceneStage1(game.SceneBase):
    # Primeiro estágio
    def __init__(self):
        self.background = Sprite('img/titleBackground.png')
        self.player = Sprite('img/player.png')
        self.player.x = 320
        self.player.y = 240
        self.player.ox = self.player.bitmap.width / 2
        self.player.oy = self.player.bitmap.height / 2
        self.player_speed = 5
        self.steroid = SpaceObject(0, 0, SpaceObjectType.asteroid, 2, 2)
        self.steroid.ox = self.steroid.width / 2
        self.steroid.oy = self.steroid.height / 2
        self.steroid.angle = 45
        self.player_life = 640
        music_player.play(pyglet.media.load('bgm/stage1.mp3'))
        print("Iniciou primeiro estágio")

    def update(self):
        pass
        spd = self.player_speed
        if str(key.RIGHT) in keys:
            self.player.angle += spd
        if str(key.LEFT) in keys:
            self.player.angle -= spd
        if str(key.UP) in keys:
            self.player.x -= spd * math.sin(-radial(self.player.angle))
            self.player.y -= spd * math.cos(-radial(self.player.angle))
        if str(key.DOWN) in keys:
            self.player.x += spd * math.sin(-radial(self.player.angle))
            self.player.y += spd * math.cos(-radial(self.player.angle))
        if str(key.Y) in keys:
            self.player_life = 640
        self.background.update(window)
        self.player.update(window)
        # Checa interseção do jogador com o asteróide
        r1 = Rect(self.player.x, self.player.y,
                  self.player.x + self.player.width,
                  self.player.y + self.player.height, self.player.angle)
        r2 = Rect(self.steroid.x - self.steroid.width / 2,
                  self.steroid.y + self.steroid.height / 2,
                  self.steroid.x + self.steroid.width,
                  self.steroid.y + self.steroid.height, self.steroid.angle)
        # p1_1 = r1.upleft()      + Point(-self.player.ox, self.player.oy)
        # p1_2 = r1.bottomleft()  + Point(-self.player.ox, self.player.oy)
        # p1_3 = r1.bottomright() + Point(-self.player.ox, self.player.oy)
        # p1_4 = r1.upright()     + Point(-self.player.ox, self.player.oy)
        # p2_1 = r2.upleft()      + Point(-self.steroid.ox, self.steroid.oy)
        # p2_2 = r2.bottomleft()  + Point(-self.steroid.ox, self.steroid.oy)
        # p2_3 = r2.bottomright() + Point(-self.steroid.ox, self.steroid.oy)
        # p2_4 = r2.upright()     + Point(-self.steroid.ox, self.steroid.oy)
        # pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
        #     ('v2f',
        #         (
        #             p1_1.x*window.x_proportion, (480.0 - p1_1.y)*window.y_proportion,
        #             p1_2.x*window.x_proportion, (480.0 - p1_2.y)*window.y_proportion,
        #             p1_3.x*window.x_proportion, (480.0 - p1_3.y)*window.y_proportion,
        #             p1_4.x*window.x_proportion, (480.0 - p1_4.y)*window.y_proportion
        #         )
        #     ),
        #     ('c3B',
        #         (
        #             255, 0, 0,
        #             0, 250, 0,
        #             0, 0, 250,
        #             255, 0, 250
        #         )
        #     )
        # )
        # pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
        #     ('v2f',
        #         (
        #             p2_1.x*window.x_proportion, (480.0 - p2_1.y)*window.y_proportion,
        #             p2_2.x*window.x_proportion, (480.0 - p2_2.y)*window.y_proportion,
        #             p2_3.x*window.x_proportion, (480.0 - p2_3.y)*window.y_proportion,
        #             p2_4.x*window.x_proportion, (480.0 - p2_4.y)*window.y_proportion
        #         )
        #     ),
        #     ('c3B',
        #         (
        #             0, 0, 255,
        #             0, 0, 255,
        #             0, 0, 255,
        #             0, 0, 255
        #         )
        #     )
        # )
        pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
                             ('v2f',
                              (0, 480, self.player_life, 480, self.player_life,
                               480 - 32, 0, 480 - 32)),
                             ('c3B',
                              (0, 0, 255, 0, 0, 255, 0, 0, 128, 0, 0, 128)))
        if r1.intersects(r2):
            self.steroid.on_collide_with_player()
            self.player_life -= 10
        self.steroid.angle += 5
        self.steroid.update(window)

    def on_key_press(self, symbol, modifiers):
        pass
예제 #8
0
파일: gui.py 프로젝트: Nixonite/PyGame-RPG
	def blit(self, screen):
		x = self.owner.rect.x-globs.cameraX-self.image.get_width()/2+self.owner.image.get_width()/2
		y = self.owner.rect.y-globs.cameraY-self.image.get_height()-10
		self.rect.topleft = (x, y)
		Sprite.blit(self, screen)
예제 #9
0
파일: gui.py 프로젝트: Nixonite/PyGame-RPG
	def __init__(self, character):
		Sprite.__init__(self, (0,0), (100,30))
		self.owner = character
		globs.currentgame.guiElements.add(self)
		self.image.fill((0,0,0))
예제 #10
0
파일: steroids.py 프로젝트: JPTIZ/awesomepy
class SceneStage1(game.SceneBase):
    # Primeiro estágio
    def __init__(self):
        self.background = Sprite('img/titleBackground.png')
        self.player = Sprite('img/player.png')
        self.player.x = 320
        self.player.y = 240
        self.player.ox = self.player.bitmap.width/2
        self.player.oy = self.player.bitmap.height/2
        self.player_speed = 5
        self.steroid = SpaceObject(0, 0, SpaceObjectType.asteroid, 2, 2)
        self.steroid.ox = self.steroid.width/2
        self.steroid.oy = self.steroid.height/2
        self.steroid.angle = 45
        self.player_life = 640
        music_player.play(pyglet.media.load('bgm/stage1.mp3'))
        print("Iniciou primeiro estágio")

    def update(self):
        pass
        spd = self.player_speed
        if str(key.RIGHT) in keys:
            self.player.angle += spd
        if str(key.LEFT) in keys:
            self.player.angle -= spd
        if str(key.UP) in keys:
            self.player.x -= spd*math.sin(-radial(self.player.angle))
            self.player.y -= spd*math.cos(-radial(self.player.angle))
        if str(key.DOWN) in keys:
            self.player.x += spd*math.sin(-radial(self.player.angle))
            self.player.y += spd*math.cos(-radial(self.player.angle))
        if str(key.Y) in keys:
            self.player_life = 640
        self.background.update(window)
        self.player.update(window);
        # Checa interseção do jogador com o asteróide
        r1 = Rect(self.player.x,
             self.player.y,
             self.player.x + self.player.width,
             self.player.y + self.player.height,
             self.player.angle)
        r2 = Rect(self.steroid.x - self.steroid.width/2,
             self.steroid.y + self.steroid.height/2,
             self.steroid.x + self.steroid.width,
             self.steroid.y + self.steroid.height,
             self.steroid.angle)
        # p1_1 = r1.upleft()      + Point(-self.player.ox, self.player.oy)
        # p1_2 = r1.bottomleft()  + Point(-self.player.ox, self.player.oy)
        # p1_3 = r1.bottomright() + Point(-self.player.ox, self.player.oy)
        # p1_4 = r1.upright()     + Point(-self.player.ox, self.player.oy)
        # p2_1 = r2.upleft()      + Point(-self.steroid.ox, self.steroid.oy)
        # p2_2 = r2.bottomleft()  + Point(-self.steroid.ox, self.steroid.oy)
        # p2_3 = r2.bottomright() + Point(-self.steroid.ox, self.steroid.oy)
        # p2_4 = r2.upright()     + Point(-self.steroid.ox, self.steroid.oy)
        # pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
        #     ('v2f',
        #         (
        #             p1_1.x*window.x_proportion, (480.0 - p1_1.y)*window.y_proportion,
        #             p1_2.x*window.x_proportion, (480.0 - p1_2.y)*window.y_proportion,
        #             p1_3.x*window.x_proportion, (480.0 - p1_3.y)*window.y_proportion,
        #             p1_4.x*window.x_proportion, (480.0 - p1_4.y)*window.y_proportion
        #         )
        #     ),
        #     ('c3B',
        #         (
        #             255, 0, 0,
        #             0, 250, 0,
        #             0, 0, 250,
        #             255, 0, 250
        #         )
        #     )
        # )
        # pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
        #     ('v2f',
        #         (
        #             p2_1.x*window.x_proportion, (480.0 - p2_1.y)*window.y_proportion,
        #             p2_2.x*window.x_proportion, (480.0 - p2_2.y)*window.y_proportion,
        #             p2_3.x*window.x_proportion, (480.0 - p2_3.y)*window.y_proportion,
        #             p2_4.x*window.x_proportion, (480.0 - p2_4.y)*window.y_proportion
        #         )
        #     ),
        #     ('c3B',
        #         (
        #             0, 0, 255,
        #             0, 0, 255,
        #             0, 0, 255,
        #             0, 0, 255
        #         )
        #     )
        # )
        pyglet.graphics.draw(4, pyglet.gl.GL_QUADS,
            ('v2f',
                (
                    0, 480,
                    self.player_life, 480,
                    self.player_life, 480-32,
                    0, 480-32

                )
            ),
            ('c3B',
                (
                    0, 0, 255,
                    0, 0, 255,
                    0, 0, 128,
                    0, 0, 128
                )
            )
        )
        if r1.intersects(r2):
           self.steroid.on_collide_with_player()
           self.player_life -= 10
        self.steroid.angle += 5
        self.steroid.update(window)

    def on_key_press(self, symbol, modifiers):
        pass