Exemple #1
0
    def __init__(self, w: Window):
        self.w = w
        self.player = w.create_sprite(Player)
        self.ground = w.create_sprite(Platform, x=w.center.x, y=25)
        self.ground.width = w.width
        self.ground.height = 50

        w.create_sprite(Platform, x=w.center.x, y=225)
        w.create_sprite(Platform, x=w.center.x + 500, y=300)
        w.create_sprite(Platform, x=w.center.x - 300, y=150)
        w.create_sprite(Platform, x=w.center.x + 300, y=200)
        w.create_sprite(Button1, x=w.width - 25, y=70)
Exemple #2
0
from pycat.window import Window

window = Window()

s = window.create_sprite()
s.image = "bat-b.png"

s.x = 500
s.y = 220

print("The sprite is at the position(", s.x, s.y, ")", s.image)

window.run()
Exemple #3
0
from pycat.window import Window
from pycat.sprite import Sprite
import random
from pycat.keyboard import KeyCode
window = Window()


class Owl(Sprite):
    def on_create(self):
        self.image = "owl.gif"
        self.x = 10
        self.y = 450

    def on_update(self, dt):
        if window.get_key_down(KeyCode.O):
            self.change_x(random.randrange(0, 100))
            self.scale = self.scale + 0.1
        elif window.get_key(KeyCode.ENTER):
            self.scale = self.scale - 0.01
        if self.scale == 2 ():
            self.change_x(0)
        if self.touching_window_edge():
            print("owl win!")
            window.exit()


class Rooster(Sprite):
    def on_create(self):
        self.image = "rooster.png"
        self.x = 10
        self.y = 150
Exemple #4
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode

w = Window()


class MySprite(Sprite):
    def on_create(self):
        self.image = "tiger.png"
        self.x = 0
        self.y = 100

    def on_update(self, dt):
        if self.window.get_key(KeyCode.D):
            self.x += 10
        if self.window.get_key(KeyCode.A):
            self.x -= 10
        if self.window.get_key(KeyCode.W):
            self.y += 10
        if self.window.get_key(KeyCode.S):
            self.y -= 10


class Me(Sprite):
    def on_create(self):
        self.image = "owl.gif"
        self.x = 0
        self.y = 300

    def on_update(self, dt):
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
import random

w = Window(background_image="beach_03.png")


class Cat(Sprite):
    def on_create(self):
        self.image = "cat.png"
        self.y = 60
        self.x = 60
        self.point = 0

    def on_update(self, dt):

        if w.get_key(KeyCode.UP):
            self.scale_x = 1
            self.rotation = 90
            self.move_forward(10)
        if w.get_key(KeyCode.DOWN):
            self.scale_x = 1
            self.rotation = 270
            self.move_forward(10)
        if w.get_key(KeyCode.LEFT):
            self.rotation = 0
            self.scale_x = -1
            self.move_forward(-10)
Exemple #6
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
from pycat.label import Label
import random
window = Window(background_image="underwater_04.png")

score_label = Label("aliens in spaceship=0")
window.add_label(score_label)
score_label.x = 550
score_label.y = 600


class Spaceship(Sprite):
    def on_create(self):
        self.image = "saucer.png"
        self.y = 500
        self.scale = 0.3
        self.score = 0
        self.add_tag("spaceship")

    def on_update(self, dt):
        self.move_forward(8)
        if self.touching_window_edge():
            self.rotation += 180


spaceship = window.create_sprite(Spaceship)
from pycat.window import Window

window = Window()

oh = input("what do you want to eat?:")

ohw = input(
    "Then where do you want to see it, left or right? Enter a number.:")

ohwo = input("Then where do you want to see it, up or down? Enter a number.:")

ohwow = input("Which size do you want? enter it.:")

w = window.create_sprite()
w.image = "forest_background.jpg"
w.scale = 1.125
w.x = 600
w.y = 325

wow = window.create_sprite()
wow.x = 600
wow.y = 300

ww = window.create_sprite()
ww.image = "fireball.gif"
ww.x = 800
ww.y = 180
ww.is_visible = False

www = window.create_sprite()
www.image = "rat.png"
Exemple #8
0
from pycat.window import Window
from pycat.keyboard import KeyCode
from pycat.sprite import Sprite
w = Window(background_image="sea.png")


class Turn(Sprite):
    def on_create(self):
        self.image = "owl.png"

    def on_update(self, dt):
        if w.get_key_down(KeyCode.W):
            self.rotation = 90
        if w.get_key_down(KeyCode.A):
            self.rotation = 180
        if w.get_key_down(KeyCode.S):
            self.rotation = 270
        if w.get_key_down(KeyCode.D):
            self.rotation = 0
        self.move_forward(5)


w.create_sprite(Turn)

w.run()
Exemple #9
0
from pycat.window import Window
from pycat.sprite import Sprite, RotationMode
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
from pycat.label import Label
import random

w = Window(background_image="forest_04.png", draw_sprite_rects=True)

cL_sprite = []


class Card(Sprite):
    def on_create(self):
        self.is_visible = False

    def on_left_click(self):
        if self in cL_sprite:
            pass
        else:
            if len(cL_sprite) < 2:
                self.is_visible = True
                cL_sprite.append(self)


score = 0


class Button(Sprite):
    def on_create(self):
Exemple #10
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.core import Player, AudioLoop
import random
audio_loop = AudioLoop('LoopLivi.wav', volume=0.2)
audio_loop.play()
select_sprite_sound = Player('hit.wav')
match_sprite_sound = Player('point.wav')
no_match_sprite_sound = Player('laugh.wav')

window = Window(background_image="forest_04.png", draw_sprite_rects=True)

clicked_sprite = []
left = 2 * [1, 2, 3, 4]


class Card(Sprite):
    def on_create(self):
        self.is_visible = False
        self.is_rotating = False

    def on_left_click(self):
        if self not in clicked_sprite:
            if len(clicked_sprite) < 2:
                select_sprite_sound.play()
                clicked_sprite.append(self)
                self.is_visible = True

    def on_update(self, dt):
        if self.is_rotating:
            self.rotation += 2
Exemple #11
0
from inspect import classify_class_attrs
from pycat.window import Window
from pycat.sprite import Sprite
from random import randrange

w=Window(background_image="forest_04.png",draw_sprite_rects=True)

check_sprite=[]
card=["avatar_01.png","avatar_02.png","avatar_03.png","avatar_04.png"]

class Card (Sprite):

    def on_create(self):
        self.is_visible=False
    
    def on_left_click(self):
        if self not in check_sprite:
            if len(check_sprite)<2:
                self.is_visible=True
                check_sprite.append(self)

r=randrange(0,3)
r1=randrange(0,3)
r2=randrange(0,3)
r3=randrange(0,3)
r4=randrange(0,3)
r5=randrange(0,3)
r6=randrange(0,3)
r7=randrange(0,3)
r8=randrange(0,3)
r9=randrange(0,3)
Exemple #12
0
from pycat.window import Window, Sprite, Color
from platform_lib import Player, Platform, MovingPlatform, Door, Key, GRAVITY, Button

w = Window()


class Button1(Button):
    def on_update(self, dt):
        if self.is_touching_any_sprite_with_tag("player"):
            level1.keyplatform.state = 1


class Key1(Key):
    def on_create(self):
        super().on_create()
        self.add_tag("key1")
        self.x = level1.keyplatform.x
        self.y = level1.keyplatform.y + self.height / 2 + level1.keyplatform.height / 2 - 1

    def on_update(self, dt):
        if not self.is_touching_sprite(level1.keyplatform):
            prev_y = self.y
            self.y += self.vy
            self.vy -= GRAVITY / 2
            platforms = w.get_sprites_with_tag("platform")
            for platform in platforms:
                top_y = platform.y + 0.5 * (platform.height + self.height)
                bot_y = platform.y - 0.5 * (platform.height + self.height)
                if self.is_touching_sprite(platform):
                    if prev_y >= top_y:
                        self.vy = 0
Exemple #13
0
from pycat.sound import Sound
from pycat.window import Window
from pycat.sprite import Sprite, RotationMode
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
from pycat.label import Label
from pycat.core import Player, AudioLoop
import random

w = Window(background_image="forest_04.png", draw_sprite_rects=True)

sound01 = Player('hit.wav')
masound = Player('point.wav')
nomasound = Player('laugh.wav')

audio_loop = AudioLoop('LoopLivi.wav', volume=0.2)
audio_loop.play()


class Card(Sprite):
    def on_create(self):
        self.is_visible = False
        self.is_rotated = False

    def on_left_click(self):
        sound01.play()
        if self in cL_sprite:
            pass
        else:
            if len(cL_sprite) < 2:
Exemple #14
0
from os import waitpid
from types import BuiltinFunctionType
from pycat.window import Window
from pycat.sprite import Sprite
from pyglet import sprite


o = Window()

w = o.create_sprite()
w.image = "forest_background.jpg"
w.scale=1.125
w.x=600
w.y=325



class Wow(Sprite):
    def on_create (self):
        self.image="owl.png"
        self.y=300
    def on_update(self, dt):
        self.x +=1
        if self.x<=600:
            self.scale+=0.0025
        if self.x>=600:
            self.scale-=0.0025
    
    def on_left_click(self):
        print("wow") 
        
Exemple #15
0
from pycat.base.base_sprite import RotationMode
from pycat.window import Window
from pycat.keyboard import KeyCode
from pycat.sprite import Sprite
w = Window(background_image="sea.png")


class Turn(Sprite):
    def on_create(self):
        self.image = "owl.png"

    def on_update(self, dt):
        if w.get_key_down(KeyCode.W):
            self.rotation = 90
        if w.get_key_down(KeyCode.A):
            self.rotation = 180
        if w.get_key_down(KeyCode.S):
            self.rotation = 270
        if w.get_key_down(KeyCode.D):
            self.rotation = 0
        if self.touching_any_sprite():
            print("You Lose!")
            w.close()
        if self.x > 1200:
            print("You Win!")
            w.close()
        self.move_forward(10)


player = w.create_sprite(Turn)
Exemple #16
0
from inspect import classify_class_attrs
from pycat.window import Window
from pycat.sprite import Sprite
import random
from pycat.core import Player, AudioLoop

hit = Player("hit.wav")
laugh = Player("laugh.wav")
point = Player("point.wav")
audio_loop = AudioLoop('LoopLivi.wav', volume=0.2)
w = Window(background_image="forest_04.png", draw_sprite_rects=True)

check_sprite = []
card = 4 * ["avatar_01.png", "avatar_02.png", "avatar_03.png", "avatar_04.png"]


class Card(Sprite):
    def on_create(self):
        self.is_visible = False
        self.is_rotation = False

    def on_update(self, dt):
        if self.is_rotation:
            self.rotation += 1
            self.scale -= 0.01
        if self.rotation == 40:
            self.color = 200, 0, 0
        if self.rotation == 100:
            self.delete()

    def on_left_click(self):
Exemple #17
0
from pycat.window import Window
from pycat.sprite import Sprite
from random import randrange
window=Window()
class ClassSprite(Sprite):
    def on_create(self):
        self.image=("rooster.png")
        self.x=600
        self.y=300
        self.rotate(110)
        self.change_x(1)

for i in range(100):
    x=window.create_sprite(ClassSprite)

window.run()
Exemple #18
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.scheduler import Scheduler
from pyglet.image import create
from pyglet.window.key import DELETE

window = Window(background_image="underwater_04.png")


class Spaceship(Sprite):
    def on_create(self):
        self.image = "saucer.png"
        self.scale = 0.35
        self.y = 500
        self.score = 0
        self.add_tag('spaceship')

    def on_update(self, dt):
        self.move_forward(10)
        if self.touching_window_edge():
            self.rotation += 180


s = window.create_sprite(Spaceship)


class Alien(Sprite):
    def on_create(self):
        self.image = "1.png"
        self.scale = 0.25
        self.goto_random_position()
Exemple #19
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode
from pycat.collision import is_aabb_collision
from pycat.scheduler import Scheduler
from pyglet import window

o = Window()
s = Scheduler()

w = o.create_sprite()
w.image = "forest_background.jpg"
w.scale = 1.125
w.x = 600
w.y = 325


class Wow(Sprite):
    def on_create(self):
        self.image = "owl.png"
        self.x = 50
        self.y = 600

    def on_update(self, dt):

        if o.get_key(KeyCode.W):
            self.rotation = 90
            self.move_forward(10)
        if o.get_key(KeyCode.S):
            self.rotation = 270
            self.move_forward(10)
Exemple #20
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode

window = Window(background_image='forest_background.jpg')


#w=window.create_sprite()
#w.image='forest_background.jpg'
class MySprite(Sprite):
    def on_create(self):
        self.image = 'owl.png'
        self.x = 100
        self.y = 400
        self.health = 50

    def on_update(self, dt):
        self.move_forward(8)
        if window.get_key_down(KeyCode.UP):
            self.rotation = 90
        elif window.get_key_down(KeyCode.DOWN):
            self.rotation = 270
        elif window.get_key_down(KeyCode.LEFT):
            self.rotation = 180
        elif window.get_key_down(KeyCode.RIGHT):
            self.rotation = 0
        if self.touching_any_sprite() or self.x > window.width:
            self.health -= 1
            print(self.health)
        if self.health < 0:
            print("You lose!")
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode

o = Window(background_image="forest_background.jpg")


class Wow(Sprite):
    def on_create(self):
        self.image = "owl.png"
        self.x = 50
        self.y = 600

    def on_update(self, dt):

        if o.get_key(KeyCode.W):
            self.rotation = 90
            self.move_forward(10)
        if o.get_key(KeyCode.S):
            self.rotation = 270
            self.move_forward(10)
        if o.get_key(KeyCode.A):
            self.rotation = 0
            self.move_forward(-10)
        if o.get_key(KeyCode.D):
            self.rotation = 0
            self.move_forward(10)
        if self.touching_any_sprite():
            print('Oh no!')
            o.exit()
Exemple #22
0
from pycat.window import Window
from pycat.sprite import Sprite
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
from pyglet.image import create

window=Window(background_image="img/beach_03.png")

class Player(Sprite):

    def on_create(self):
        self.image="img/cat.png"
        self.y=0
    def on_update(self, dt):
        if window.get_key(KeyCode.LEFT):
            self.scale_x=-1
            self.x-=10
        if window.get_key(KeyCode.RIGHT):
            self.scale_x=1
            self.x+=10

player = window.create_sprite(Player)

class Gem(Sprite):

    def on_create(self):
        self.image="img/gem_shiny01.png"
        self.goto_random_position()
        self.y=window.height
        self.scale=0.25
Exemple #23
0
from pycat.window import Window
from pycat.sprite import Sprite, RotationMode
from pycat.keyboard import KeyCode
from pycat.scheduler import Scheduler
from pycat.collision import is_aabb_collision
from pycat.label import Label
import random

from pyglet.text.layout import ScrollableTextLayout

w = Window(background_image="underwater_04.png")


class Ship(Sprite):
    def on_create(self):
        self.image = 'saucer.png'
        self.y = 490
        self.scale = float(0.25)
        self.rotation_mode = RotationMode.RIGHT_LEFT
        self.add_tag("spaceship")

    def on_update(self, dt):
        self.move_forward(4)
        if self.touching_window_edge():
            self.rotation += 180


ship = w.create_sprite(Ship)

scores = Label("How many Alien have been saved?:", x=400, y=600)
ship.score = 0
Exemple #24
0
from pycat.window import Window

window = Window()

window.run()
Exemple #25
0
from pycat.window import Window
from test.support import bigaddrspacetest
window = Window()

animal = input("Please enter the animal you want to see:")
size = input("Do you want your animal to be big or small or not?")
#x=input("How about the x?")
#y=input("How about the y?")
left = input("Do you want your animal at left or right or not?")
point = input("Do you want your animal point left or right?")
#placex=float(x)
#placey=float(y)
animal_png = window.create_sprite()
animal_png.opacity = 250
animal_png.x = animal_png.x + 650
animal_png.y = animal_png.y + 350
#animal_png.x=animal_png.x+placex
#animal_png.y=animal_png.y+placey
if animal == "elephant":
    animal_png.image = "elephant.png"
if animal == "owl":
    animal_png.image = "owl.gif"
if size == "big":
    animal_png.scale = 2
if size == "small":
    animal_png.scale = 0.5
if left == "left":
    animal_png.x = 550
if left == "right":
    animal_png.x = 750
if point == "left":
Exemple #26
0
from pycat.window import Window
from pycat.sprite import Sprite
from pyglet.window.key import W

w = Window(background_image="forest_04.png", draw_sprite_rects=True)

click_sprite = []


class Card(Sprite):
    def on_create(self):
        self.is_visible = False

    def on_left_click(self):
        if self not in click_sprite:
            if len(click_sprite) < 2:
                click_sprite.append(self)
                self.is_visible = True


w.create_sprite(Card)

w.create_sprite(Card, x=100, y=100, image="avatar_01.png")
w.create_sprite(Card, x=100, y=200, image="avatar_01.png")
w.create_sprite(Card, x=200, y=100, image="avatar_02.png")
w.create_sprite(Card, x=200, y=200, image="avatar_02.png")


class Checkbutton(Sprite):
    def on_create(self):
        self.image = "button.png"