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)
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()
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 def on_update(self, dt): if window.get_key_down(KeyCode.R): self.change_x(random.randrange(0, 100)) self.scale = self.scale + 0.1 elif window.get_key(KeyCode.SPACE): self.scale = self.scale - 0.01 if self.touching_window_edge(): print("rooster win!") window.exit() window.create_sprite(Owl) window.create_sprite(Rooster) window.run()
if self.window.get_key(KeyCode.Y): self.y += 11 if self.window.get_key(KeyCode.H): self.y -= 11 class Hi(Sprite): def on_create(self): self.image = "pig.png" self.x = 0 self.y = 500 def on_update(self, dt): if self.window.get_key(KeyCode.RIGHT): self.x += 12 if self.window.get_key(KeyCode.LEFT): self.x -= 12 if self.window.get_key(KeyCode.UP): self.y += 12 if self.window.get_key(KeyCode.DOWN): self.y -= 12 w.create_sprite(Hi) w.create_sprite(Me) w.create_sprite(MySprite) #if self.x>1000: #print("pig win!") w.run()
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) if w.get_key(KeyCode.RIGHT): self.rotation = 0 self.scale_x = 1 self.move_forward(10) player = w.create_sprite(Cat) class Gem(Sprite): def on_create(self): self.image = random.choice([ "gem_shiny01.png", "gem_shiny02.png", "gem_shiny03.png", "gem_shiny04.png", "gem_shiny05.png" ]) self.scale = float(0.34) self.goto_random_position() self.y = 600 def on_update(self, dt): self.y -= 5 if is_aabb_collision(self, player):
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) class Aliens(Sprite): def on_create(self): self.image = random.choice( ['1.png', '2.png', '3.png', '4.png', '5.png']) self.goto_random_position() self.y = 50 self.scale = 0.3 self.is_moving = False def on_update(self, dt): if self.is_moving: self.y += 20 if self.touching_any_sprite_with_tag("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"
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()
sprite1.is_rotating = True sprite2.is_rotating = True else: no_match_sprite_sound.play() sprite1.is_visible = False sprite2.is_visible = False clicked_sprite.clear() class Win(Sprite): def on_create(self): pass def on_update(self, dt): pass avatar = 4 * [ 'avatar_01.png', 'avatar_02.png', 'avatar_03.png', 'avatar_04.png', ] random.shuffle(avatar) for x in range(100, 500, 100): for y in range(100, 500, 100): window.create_sprite(Card, x=x, y=y, image=avatar.pop()) a = window.create_sprite(Button, x=800, y=200, image='button.png') window.run()
self.scale=0.5 self.x=500 self.y=200 def on_left_click(self): if len (check_sprite)==2: s1:Sprite=check_sprite[0] s2:Sprite=check_sprite[1] if s1.image==s2.image: s1.delete() s2.delete() else: s1.is_visible=False s2.is_visible=False check_sprite.clear() print (check_sprite) w.create_sprite(Card, x=100, y=100, image=card[r]) w.create_sprite(Card, x=100, y=200, image=card[r1]) w.create_sprite(Card, x=200, y=100, image=card[r2]) w.create_sprite(Card, x=200, y=200, image=card[r3]) w.create_sprite(Card, x=300, y=200, image=card[r4]) w.create_sprite(Card, x=300, y=100, image=card[r5]) w.create_sprite(Card, x=300, y=300, image=card[r6]) w.create_sprite(Card, x=200, y=300, image=card[r7]) w.create_sprite(Card, x=100, y=300, image=card[r8]) w.create_sprite(Card, x=400, y=100, image=card[r9]) w.create_sprite(Button) w.run()
score_label.text = 'BEST MATCH: ' + str(button.score) sprite1.is_rotated = True sprite2.is_rotated = True else: nomasound.play() sprite1.is_visible = False sprite2.is_visible = False button.health += 1 score_label01.text = "WORST MATCH: " + str(button.health) cL_sprite.clear() def on_update(self, dt): self.rotation += 1 button = w.create_sprite(Button) button.score = 0 button.health = 0 score_label = Label("BEST MATCH: 0", x=1000, y=400) w.add_label(score_label) score_label01 = Label("WORST MATCH: 0", x=1000, y=160) w.add_label(score_label01) # score_label0 = Label("YOU WIN!") # w.add_label(score_label0) # score_label00 = Label("YOU LOSE!") # w.add_label(score_label00) cL_sprite = 4 * [ "avatar_01.png", "avatar_02.png", "avatar_03.png", "avatar_04.png"
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 = 199 def on_update(self, dt): self.x += 4 if self.x <= 600: self.scale += 0.0025 if self.x >= 600: self.scale -= 0.0025 def on_left_click(self): print("wow")
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")
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) class Enemy(Sprite): def on_create(self): self.rotation_mode = RotationMode self.image = "ork1.png" self.scale = 0.5 self.x = w.width self.y = w.height def on_update(self, dt): self.point_toward_sprite(player) self.move_forward(2)
def on_update(self, dt): if self.is_rotating: self.rotation += 2 if self.rotation > 120: self.delete() def on_left_click(self): if self not in click_sprite: if len(click_sprite) < 2: select_sprite_sound.play() 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=300, image="avatar_01.png") # w.create_sprite(Card, x=200, y=300, image="avatar_02.png") # w.create_sprite(Card, x=300, y=200, image="avatar_02.png") # w.create_sprite(Card, x=200, y=200, image="avatar_03.png") # w.create_sprite(Card, x=300, y=100, image="avatar_03.png") # w.create_sprite(Card, x=100, y=200, image="avatar_04.png") # w.create_sprite(Card, x=200, y=100, image="avatar_04.png") class Checkbutton(Sprite): def on_create(self): self.image = "button.png" self.x = 600
class Cat(Sprite): def on_create(self): self.image = "cat.png" self.x = 30 self.y = 30 def on_update(self, dt): if w.get_key(KeyCode.LEFT): self.x = self.x - 10 if w.get_key(KeyCode.RIGHT): self.x = self.x + 10 cat = w.create_sprite(Cat) class Gem(Sprite): def on_create(self): self.image = "gem_shiny01.png" self.goto_random_position() self.y = w.height self.scale = 0.25 def on_update(self, dt): self.y = self.y - 7 if self.y < 0: self.delete() #if self.touching_any_sprite(): # self.delete()
def on_left_click(self): if len(cL_sprite) == 2: sprite1: Sprite = cL_sprite[0] sprite2: Sprite = cL_sprite[1] if sprite1.image == sprite2.image: sprite1.delete() sprite2.delete() button.score += 1 score_label.text = 'BEST MATCH: ' + str(button.score) else: sprite1.is_visible = False sprite2.is_visible = False cL_sprite.clear() button = w.create_sprite(Button) button.score = 0 score_label = Label("BEST MATCH: 0", x=1000, y=400) w.add_label(score_label) p1 = w.create_sprite(Card, x=200, y=100, image="avatar_01.png", scale=float(1.6)) p2 = w.create_sprite(Card, x=200, y=220, image="avatar_02.png", scale=float(1.6))
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()
class Button(Sprite): def on_create(self): self.image = "button.png" self.scale = 0.5 self.x = 600 self.y = 300 def on_left_click(self): if len(check_sprite) == 2: s1: Card = check_sprite[0] s2: Card = check_sprite[1] if s1.image == s2.image: s1.is_rotation = True s2.is_rotation = True point.play() else: laugh.play() s1.is_visible = False s2.is_visible = False check_sprite.clear() random.shuffle(card) for x in range(100, 500, 100): for y in range(100, 500, 100): w.create_sprite(Card, x=x, y=y, image=card.pop()) w.create_sprite(Button) audio_loop.play() w.run()
class Wowow(Sprite): def on_create(self): self.image = "rooster.png" self.x = 1160 self.y = 50 def on_update(self, dt): if o.get_key(KeyCode.I): self.rotation = 90 self.move_forward(10) if o.get_key(KeyCode.K): self.rotation = 270 self.move_forward(10) if o.get_key(KeyCode.J): self.rotation = 180 self.move_forward(10) if o.get_key(KeyCode.L): self.rotation = 0 self.move_forward(10) if self.touching_any_sprite(): print('Oh Yeah!') o.exit() oh = o.create_sprite(Wow) ohma = o.create_sprite(Wowow) o.run()
print("You lose!") window.exit() class Enemy(Sprite): def on_create(self): self.image = 'ork1.png' self.x = 1000 self.y = 300 self.scale = 0.5 def on_update(self, dt): self.point_toward_sprite(self) self = window.create_sprite(Enemy) s = window.create_sprite() s.image = 'fireball.gif' s.x = 300 s.y = 300 s1 = window.create_sprite() s1.image = 'fireball.gif' s1.x = 600 s1.y = 500 s2 = window.create_sprite() s2.image = 'fireball.gif' s2.x = 1000 s2.y = 100 s3 = window.create_sprite() s3.image = 'fireball.gif'
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 w.add_label(scores) class Alien(Sprite): def on_create(self): self.image = random.choice(["1.png", "2.png", "3.png", "5.png"]) self.scale = float(0.25) self.goto_random_position() self.y = 46 self.is_moving_up = False def on_update(self, dt):
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 def on_update(self, dt): self.y-=3 if is_aabb_collision(self, player): self.delete() elif self.y<0: self.delete()
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":
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" self.x = 450 self.y = 100 self.scale = 0.4 def on_left_click(self):