def rozpocznijGre(): games.init(screen_width=szerokosc_ekranu, screen_height=wysokosc_ekranu, fps=50) wall_image = games.load_image("wyswietlenie_grafik/Grafiki/chess.jpg", False) games.screen.background = wall_image obiekty_bierek = pokazFigury() games.screen.mainloop()
def main(): games.init(screen_width = 640, screen_height = 480, fps = 50) wall_image = games.load_image("wall.jpg", transparent = False) games.screen.background = wall_image pizza_image = games.load_image("pizza.bmp") pizza = Pizza(image = pizza_image, x = 320, y = 240, dx = 1, dy = 1) games.screen.add(pizza) pan_image = games.load_image("pan.bmp") the_pan = Pan(image = pan_image, x = games.mouse.x, y = games.mouse.y) games.screen.add(the_pan) games.mouse.is_visible = False games.screen.event_grab = True games.screen.mainloop()
def main(self, user): games.init(screen_width = 640, screen_height = 480, fps = 50) music = games.music.load("audio/background.mp3") games.music.play() wall_image = games.load_image("images/background.jpg",transparent = False) games.screen.background = wall_image choice = randint(0,2) if choice == 0: enemy = Red_Dragon("screechy") elif choice == 1: enemy = White_Dragon("Frosty") else: enemy = Goblin("shorty") user_health = games.Text(value = "health: " + str(user.health), size = 40, color = color.red, x = 75, y = 20) enemy_health = games.Text(value = "health: " + str(enemy.health), size = 40, color = color.red, x = 550, y = 20) games.screen.add(user_health) games.screen.add(enemy_health) character = player(user, enemy, user_health, enemy_health) games.screen.add(character) attacker = opponent(user, enemy) games.screen.add(attacker) games.screen.mainloop()
""" Whack a Mole!!! The fun game where we abuse these poor moles who pop up everywhere!!! <Author == JARED DEMBRUN> <Date == 11.6.2013> Using python3.3.1, graphical interface """ from livewires import games, color games.init(screen_width=1280, screen_height=556, fps=50) field = games.load_image("green-grass.jpg", transparent=False) games.screen.background = field score = games.Text(value=0, size=20, color=color.black, x=10, y=10) #tracks the number of moles hit games.screen.add(score) games.screen.mainloop() #end
The task is to score the enemy and not miss it yourself. After the goal immediately follows the flow from the random point near the left side to the right. The game goes to 11 eyes. Accompanied by the sounds of playing table tennis.""" from livewires import games, color import pygame import random # color definition YELLOW = (255, 255, 0) pygame.init() games.init(screen_width=720, screen_height=480, fps=70) class Recapture(games.Sprite): """ Movable object. Changes the trajectory of the ball """ """ Перемещаемый объект. Меняет траекторию движения мяча """ def update(self): """ Moves the object to the position of the mouse pointer along a single line. """ """ Перемещает объект в позицию указателя мыши по одной линии. """ self.y = games.mouse.y self.touch() # Checks the touch to the ball | проверка касания к мячу def touch(self): """ Checks the touch to the ball """ """ Проверяет касание к мячу """ # if applicable, changes the direction and speed of the ball
import pygame from livewires import games, color SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 games.init(screen_width=SCREEN_WIDTH, screen_height=SCREEN_HEIGHT, fps=50) class Player(games.Sprite): """ This class represents the player sprite, Pixel. """ # Attributes right_walk = games.load_image("pixel_right1.png") left_walk = games.load_image("pixel_left1.png") gravity = 0.3 moving = False jumping = False # speed attributes change_x = 0 change_y = 0 # list of platforms to move platform_list = [] level = 1 def __init__(self, platform_list): # call parent constructor super(Player, self).__init__(image=Player.right_walk, left=155, bottom=games.screen.height - 43)
import random import math from livewires import games, color games.init(screen_width=1200, screen_height=600, fps=60) class Wrapper(games.Sprite): def update(self): if self.top > games.screen.height: self.bottom = 0 if self.bottom < 0: self.top = games.screen.height if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def die(self): self.destroy() class Collider(Wrapper): def update(self): super(Collider, self).update()
# Background Image # Demonstrates setting the background image of a graphics screen from livewires import games games.init(screen_width=640, screen_height=480, fps=50) wall_image = games.load_image("wall.jpg", transparent=False) games.screen.background = wall_image games.screen.mainloop()
from time import sleep from livewires import games, color games.init(screen_width=852, screen_height=480, fps=60) class Rocket(games.Sprite): VELOCITY_FACTOR = 4 image = games.load_image('rocket.jpg', transparent=False) def __init__(self, x, y): super(Rocket, self).__init__(image=Rocket.image, x=x, y=y) class Rocket1(Rocket): def update(self): self.dx = 0 self.dy = 0 if games.keyboard.is_pressed(games.K_s): self.dy = self.VELOCITY_FACTOR if games.keyboard.is_pressed(games.K_w): self.dy = -self.VELOCITY_FACTOR if (games.keyboard.is_pressed(games.K_w) and games.keyboard.is_pressed(games.K_s)): self.dx = 0 self.dy = 0 if self.top < 0: self.top = 0 if self.bottom > games.screen.height: self.bottom = games.screen.height
from livewires import games, color from generate4 import * import pygame, math screen_width = 620 screen_height = 620 tilesize = 20 games.init(screen_width=screen_width, screen_height=screen_height, fps=50) shaft123 = games.load_image("hidden\\shaft.png", transparent=False) tiles = [ games.load_image("hidden\\plank1.png", transparent=False), games.load_image("hidden\\plank2.png", transparent=False), games.load_image("hidden\\plank3.png", transparent=False), games.load_image("hidden\\plank4.png", transparent=False), games.load_image("hidden\\plank5.png", transparent=False) ] tiles = [ pygame.transform.rotate(tiles[2], 180), #l end 1 tiles[2], #r end 2 tiles[0], #horizontal 3 pygame.transform.rotate(tiles[2], 90), #t end 4 tiles[1], #tl corner 5 pygame.transform.rotate(tiles[1], 270), #tr corner 6 pygame.transform.rotate(tiles[3], 270), #3t 7 pygame.transform.rotate(tiles[2], 270), #b end 8 pygame.transform.rotate(tiles[1], 90), #bl corner 9 pygame.transform.rotate(tiles[1], 180), #br corner 10 pygame.transform.rotate(tiles[3], 90), #3b 11 pygame.transform.rotate(tiles[0], 90), #vertical 12
Program......: challenge12_3.py Author.......: Michael Rouse Date.........: 3/24/13 Description..: My Own version of "Duck Hunt" """ from livewires import games, color import pygame.display, pygame.mouse from random import randint, randrange import subprocess from subprocess import Popen, PIPE command = "python tracking.py" process2 = Popen(command, stdout=PIPE, stderr=PIPE, shell=True) #print (process2.communicate()) # Setup game window games.init(screen_width=1372, screen_height=750, fps=50) pygame.display.set_caption("Duck Hunt") # Tree and grass to bring to the front foreground = games.Sprite(image=games.load_image("Sprites/foreground.png"), left=0, bottom=600) games.screen.add(foreground) # CLASS ==================================== # Name.........: Cursor # Description..: Sets mouse to the crosshair # Syntax.......: Cursor() # ========================================== class Cursor(games.Sprite): """ Cursor Object """ clicked = False
from livewires import games import random games.init(screen_width = 1080, screen_height = 540, fps = 50) space_image = games.load_image("space1.jpg", transparent = True) games.screen.background = space_image spaceship_image = games.load_image("spaceship.bmp", transparent = True) spaceship = games.Sprite(image = spaceship_image, x = games.screen.width/2,y = games.screen.height - 30) laser_image = games.load_image("redLaserRay.bmp", transparent = True) laser = games.Sprite(image = laser_image, x = games.screen.width/2,y = games.screen.height - 50) ufo_image = games.load_image("ufo.bmp", transparent = True) ufo = games.Sprite(image = ufo_image, x = random.randint(50,games.screen.width/2 -50),y = 50) games.screen.add(spaceship) games.screen.add(laser) games.screen.add(ufo) games.screen.event_grab = True games.mouse.is_visible = True games.screen.mainloop()
from livewires import games import random games.init(screen_width=384, screen_height=448, fps=50) class Bird(games.Animation): bird_images = ("1.png", "2.png", "3.png") JUMP_SPEED = -4.6 FALL_SPEED = 0.2 start = False last_press = False die = False def __init__(self): super(Bird, self).__init__(images=Bird.bird_images, x=192, y=190, repeat_interval=10, n_repeats=-1) def update(self): if self.start: self.jump() self.speed_update() self.check_die() def jump(self): if games.mouse.is_pressed(0): if self.last_press == False:
from livewires import games import random games.init(screen_width = 384,screen_height = 448,fps = 50) class Bird(games.Animation): bird_images = ("1.png","2.png","3.png") JUMP_SPEED = -4.6 FALL_SPEED = 0.2 start = False last_press = False die = False def __init__(self): super(Bird, self).__init__(images = Bird.bird_images, x = 192, y = 190, repeat_interval = 10, n_repeats = -1) def update(self): if self.start: self.jump() self.speed_update() self.check_die() def jump(self): if games.mouse.is_pressed(0): if self.last_press == False: self.dy = self.JUMP_SPEED self.last_press = True
# the refresh rate and FPS cause the ball (Stu's head) to go through the flipper # and glitch up. There is nothing I can do about this. # I tried to change the sprites, and do other things, but ultimately this bug is because # of Python and Pygame, and lack of refresh rate and low FPS. # The ball can also get caught in a corner. This is another bug I cannot actually do anything about. # I could make the game harder and more fun if I could improve the FPS # rate and the speed of the dx/dy, but again I cannot do so with the current # state of Pygame and the amount of "lag" and lack of refresh rate it has. # Importing of necessary things. from livewires import games, color import random # Initialize the game. games.init(screen_width = 400, screen_height = 480, fps = 500) class Flipper1(games.Sprite): """ An Orange "flipper" controlled by the Up and Down keys. """ image = games.load_image("Flipper1.bmp") def __init__(self): """ Initialize right Flipper object and create a Text object for score. """ super(Flipper1, self).__init__(image = Flipper1.image, x = 0, y = 240 ) self.score1 = games.Text(value = 0, size = 50, color = color.white, top = 5, right = games.screen.width - 250) games.screen.add(self.score1)
#Ali Spittel #Final Lab #based on flappy birds #also based loosly on pizza panic lab #OPEN LAUNCHSCREEN FIRST #Import needed programs and initialize screen from livewires import games, color import random games.init(screen_width=640, screen_height=600, fps=100) #create an animated bird with three different wing positions. Repeats indefinitely #found images online and then edited them to make them change class Bird(games.Animation): images = ["Bird1.png", "Bird2.png", "Bird3.png"] def __init__(self): super(Bird, self).__init__(images=Bird.images, x=300, y=300, dy=7, n_repeats=0, repeat_interval=8) self.score = games.Text(value=0, size=100, color=color.red, top=5, right=games.screen.width - 10) games.screen.add(self.score)
# Паника в пицерии # Игрок должен ловить падающую пиццу, пока она не достикла земли import random from livewires import games, color WIDTH = 640 HEIGHT = 480 games.init(screen_width=WIDTH, screen_height=HEIGHT, fps=50) class Pan(games.Sprite): """ Сковорда, в которую игрок может ловить падающую пиццу. """ image = games.load_image("img/pan.bmp") def __init__(self): """ Инициализирует объект Pan и создает объект Text для отображения счета. """ super(Pan, self).__init__(image=Pan.image, x=games.mouse.x, bottom=HEIGHT) self.score = games.Text(value=0, size=25, color=color.black, top=5, right=WIDTH - 10) games.screen.add(self.score)
#import modules, initialize screen, hide mouse and add background. from livewires import games, color import random games.init(640, 480, 50) games.mouse.is_visible = False game_background = games.load_image("images/background.png") games.screen.background = game_background #create a sprite class for the ball, include initialization method, #add score, update method with collision logic. class Ball(games.Sprite): """a ball the player must keep from hitting the bottom""" ball = games.load_image("images/ball.png") def __init__(self): """load the ball and score into the game""" #use ball image, place in center of screen, give x and y velocity #and add a score. super(Ball, self).__init__(image=Ball.ball, x=games.screen.width / 2, y=games.screen.height / 2, dy=2, dx=2) self.score = games.Text(0, size=30, color=color.red, x=games.screen.width - 10, y=15, is_collideable=False)
from livewires import games, color import math import random games.init(screen_width=1000, screen_height=500, fps=100) back=games.load_image(os.getcwd()+"\\files\\"+"\\Gunner\\"+"background.png") games.screen.background=back class gunner(games.Sprite): """Player controlled sprite""" man=games.load_image(os.getcwd()+"\\files\\"+"\\Gunner\\"+"gunman.png") def __init__(self): """Creates Gunner""" super(gunner, self).__init__(image=gunner.man, x=games.screen.width/2, y=games.screen.height/2) self.timer=50 def update(self): """Checks for user input""" self.timer-=1 if games.keyboard.is_pressed(games.K_LEFT): self.angle-=1 if games.keyboard.is_pressed(games.K_RIGHT): self.angle+=1 if games.keyboard.is_pressed(games.K_SPACE) and self.timer<=0: self.shoot() self.timer=50 def die(self): """Ends the game""" GrimReaper=games.Message(value="GAME OVER", size=100, color=color.red, x=games.screen.width/2, y=games.screen.height/2, lifetime=3*games.screen.fps, after_death=games.screen.quit, is_collideable=False) games.screen.add(GrimReaper) self.destroy() def shoot(self): """Fires a bullet"""
""" Python 3.1.1 Pygame 1.9.1 Evgeny Smirnov """ from livewires import games, color import math import random games.init(screen_width = 1600, screen_height = 1020, fps = 50) # screen class Ship(games.Sprite): """main class of all ships""" def update(self): if self.top > games.screen.height: self.bottom = 0 if self.bottom < 0: self.top = games.screen.height if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def attack(self): new_missle = Missle(self.x, self.y, self.angle) games.screen.add(new_missle) class Player(Ship): def __init__(self, game, x, y): """initialize sprite"""
#name=Pong2 #author=rgbvlc [email protected] #info=simple game in pygame, livewires # remake the classic pong game! #status=unfinished #final version= ~ summer 2018 #todo= acceleration the ball, AI, profile system from livewires import games import random, pygame, datetime games.init(screen_width=770, screen_height=525, fps=50) games.mouse.is_visible = False pygame.display.set_caption("Pong2") class Move(games.Sprite): maybe = (True, False) touch = 0 def balldirect(self): direct = random.choice(Move.maybe) self.direct = direct def collide(self): for ball in self.overlapping_sprites: ball.dx = -ball.dx Move.touch += 1 print(Ball.speed, "\t", Ball.dx, Ball.dy) def update(self):
red- food yellow- gold white- population grey- population capacity Different buildings/units require different levels of resources. In order to create a mountain climber, you must have a barracks, 50 food, 50 gold, and 50 wood. Building a church decreases the chances that your mountain climber will die on his journey. Hope you enjoy! """ import random, threading, time from livewires import games, color games.init(screen_width = 1920, screen_height = 1080, fps = 50) class Game(object): pres = ["Weiss", "Ham", "Ober", "Eich", "Andels", "Wach"] suff = ["berg", "dorn", "swil", "stein", "wald", "wier", "haft"] VILLAGE_NAME = str(random.choice(pres) + random.choice(suff)) # Randomely chosen village name based off of German fixes for fun :) def __init__(self, name = VILLAGE_NAME): #initializes game, sets resources, adds mountain to screen self.name_label = games.Text(value = "Your Village: " + str(name), size = 100, color = color.dark_gray, top = 15,
def main(): # create window games.init(screen_width=640, screen_height=480, fps=50) #Load background #still has problem if we give absolute path, i.e."C:\lkjlfs\dfdsfs" wall_image = games.load_image("CIMG2622.JPG", transparent=False) games.screen.background = wall_image # Add on additional sprite, animation object #~ cxtree_image = games.load_image("cxmastree.bmp") #~ xtree = games.Sprite(image = cxtree_image, x = 320, y=240) #~ games.screen.add(xtree) # Add on 3 pizzas for 3 girls p_image = games.load_image("pizza.bmp") #~ pizza1 = games.Sprite(image = p_image, x = 470, y=280, dx =1, dy =-1) #~ pizza2 = games.Sprite(image = p_image, x = 240, y=280, dx = -1, dy =-1) #~ pizza3 = games.Sprite(image = p_image, x = 320, y=280, dx =-1, dy =1) #Now calling derived class Pizza to make them bounce via over-ride update method. pizza1 = Pizza(image=p_image, x=470, y=280, dx=1, dy=-1) pizza2 = Pizza(image=p_image, x=240, y=280, dx=-1, dy=-1) pizza3 = Pizza(image=p_image, x=320, y=280, dx=-1, dy=1) games.screen.add(pizza1) games.screen.add(pizza2) games.screen.add(pizza3) # Display the girls' names as Text and Color demo amita = games.Text(value="Amita", size=20, color=color.blue, x=240, y=310) anika = games.Text(value="Anika", size=20, color=color.pink, x=470, y=310) alina = games.Text(value="Alina", size=20, color=color.yellow, x=320, y=310) games.screen.add(amita) games.screen.add(anika) games.screen.add(alina) #Display "Dinner Time" as Message demo eatMessage = games.Message(value="Dinner Time!!!", size=40, color=color.red, x=games.screen.width / 2, y=games.screen.height / 2, lifetime=250, after_death=games.screen.mainloop) games.screen.add(eatMessage) #Create Pan sprite and add to screen. pan_image = games.load_image("pan.bmp") pan = Pan(image=pan_image, x=games.mouse.x, y=games.mouse.y) games.screen.add(pan) #Setting mouse pinter not visible games.mouse.is_visible = False #Grab all graphic events games.screen.event_grab = True #Load music file playing as background games.music.load("theme.mid") games.music.play() #Load a sound file for use in case of collision, etc... missile_sound = games.load_sound("missile.wav") loop = 9999 #missile_sound.play(loop) #continuous #Display window on screen games.screen.mainloop()
from livewires import games games.init(screen_width=800, screen_height=600, fps=60) background = games.load_image("Texture.jpg", transparent=False) games.screen.background = background games.screen.mainloop()
from livewires import games, color import NavigationButton as NB import Vertex as VE import Edge as ED import random import GraphAlgorithm as GA import AlgorithmDisplay as AD import MyText as MT games.init(screen_width = 832, screen_height = 624, fps = 50) #################################### # IDs: # 0 - PhantomMouse # 1 - MyText #################################### #################################### # States: # 0 - Not entered application # 1 - Choose left branch size (1 - 10) # 2 - Choose right branch size (1 - 10) # 3 - Choose edges (manually or randomly) # 4 - If choosing edges manually, make choices on provided bipartite graph # 5 - Choose operation after choosing edges manually: # - automatically find a maximum matching # - find a maximum matching manually # - watch procedure of algorithm to find a maximum matching # - watch procedure of algorithm to find a maximum matching with steps # 6 - Choose operation after choosing edges randomly: # - automatically find a maximum matching
""" Program......: challenge11_3.py Author.......: Michael Rouse Date.........: 3/17/14 Description..: Create a one player pong game with the wall """ from livewires import games, color # Create the window and frame games.init(screen_width=1280, screen_height=816, fps=30) # Create the score score = games.Text(value=0, size=70, color=color.white, x=340, y=60, left=340) class Paddle(games.Sprite): """ Paddle to hit the ball """ image = games.load_image("challenge11_3_paddle.png") def __init__(self): super(Paddle, self).__init__(image=Paddle.image, x=600, y=games.mouse.y) # Move the paddle def update(self): self.y = games.mouse.y # Don't let paddle go above the top white line if self.y - 32 < 24: self.y = 24 + 32 # Don't let the paddle go below the bottom white line if self.y + 32 > 460:
# Ball panic # Player must catch falling balls before they hit the ground from livewires import games, color import random games.init(screen_width = 840, screen_height = 580, fps = 50) class Dog(games.Sprite): """ A dog controlled by player to catch falling balls. """ image = games.load_image("kg.png") def __init__(self): """ Initialize Dog object and create Text object for score. """ super(Dog, self).__init__(image = Dog.image, x = games.mouse.x, bottom = games.screen.height) self.score = games.Text(value = 0, size = 25, color = color.black, top = 5, right = games.screen.width - 10) games.screen.add(self.score) self.level = games.Text(value = 0, size = 25, color = color.blue, top = 5, left = games.screen.width - 800) games.screen.add(self.level) def update(self): """ Move to mouse x position. """ self.x = games.mouse.x
from livewires import games, color from tkinter import * import settings import random games.init(screen_width=735, screen_height=350, fps=35) class Bounce(games.Sprite): def update(self): if self.right > games.screen.width or self.left < 0: self.dx = -self.dx if self.top < 0: self.dy = -self.dy if self.bottom == 315 and self.overlapping_sprites: self.dy = -self.dy class Bar_moving(games.Sprite): def update(self): self.x = games.mouse.x self.y = 315 class handling_settings(): self.yr = settings.app.bbbbb()
from livewires import games, color import random, math games.init(screen_height=768, screen_width=1024, fps=50) class Wrap(games.Sprite): def update(self): if self.top > games.screen.height: self.bottom = 0 if self.bottom < 0: self.top = games.screen.height if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def die(self): self.destroy() class Collide(Wrap): def update(self): """ Check for overlapping sprites. """ super(Collide, self).update() if self.overlapping_sprites:
# Bryce Ogden # Duckstermination # Final Game # Shoot gun by pressing spacebar # Turn gun by pressing left and right arrow keys # (directions also in game) from livewires import games, color import random, math games.init(screen_width = 900, screen_height = 600, fps = 50) class Wrap(games.Sprite): """ A sprite that wraps around the screen """ def update(self): """ Wrap sprite around screen """ if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def die(self): """ Destroy self """ self.destroy() class Collide(games.Sprite): """ A Wrap that can collide with another object """ def update(self): """ Check for overlapping sprites """
from livewires import games import random, pygame from utilities import distance, LOC # General game properties and setup games.init(screen_width=1100, screen_height=700, fps=50) pygame.display.set_mode((1100, 700), pygame.FULLSCREEN) pygame.mouse.set_visible(False) class Surface(games.Sprite): """ Surface that portals can be shot onto """ image1 = games.load_image(LOC + r"\..\Images\surface1.bmp") image2 = games.load_image(LOC + r"\..\Images\surface2.bmp") image3 = games.load_image(LOC + r"\..\Images\surface3.bmp") images = [image1, image2, image3] orange1 = games.load_image(LOC + r"\..\Images\orange1.bmp") orange2 = games.load_image(LOC + r"\..\Images\orange2.bmp") orange3 = games.load_image(LOC + r"\..\Images\orange3.bmp") orange4 = games.load_image(LOC + r"\..\Images\orange4.bmp") oranges = [orange1, orange2, orange3, orange4] blue1 = games.load_image(LOC + r"\..\Images\blue1.bmp") blue2 = games.load_image(LOC + r"\..\Images\blue2.bmp") blue3 = games.load_image(LOC + r"\..\Images\blue3.bmp") blue4 = games.load_image(LOC + r"\..\Images\blue4.bmp") blues = [blue1, blue2, blue3, blue4] orangePortal = None bluePortal = None
#!/usr/bin/env python import sys import pygame from pygame import * import math, random from livewires import games, color from pygame.locals import K_ESCAPE games.init(screen_width = 900, screen_height = 700, fps = 40)
def Exodus(): games.init(screen_width=1000, screen_height=500, fps=50) background_image = games.load_image("media/cn.jpg", transparent=False) games.screen.background = background_image
#""Joe's GUI program in Python"" # Developed on December 4, 2007 #import from livewires graphic package from livewires import games, color import random # New for Rev2.0 ################################################# # Revision History: # Rev 1.0, Basic picture, pizzas flying, and pan, and bouncing, but no catching of pizzas yet # Rev 2.0, Implemented Catching and destroying of pizza object, and creating new ones. # Also keep track of score. ################################################# Sound = games.load_sound("missile.wav") #New for Rev 2.0 games.init(screen_width = 640, screen_height = 480, fps =50) #New for Rev 2.0 ################################################# #Making the pizzas bounce, making a derived class, and overriding the update method class Pizza(games.Sprite): #Base class of Sprite """A Bouncing Pizza.""" def update(self): """Reverse a velocity component if edge of screen reached.""" if self.right > games.screen.width or self.left < 0: self.dx = -self.dx if self.bottom > games.screen.height or self.top < 0: self.dy = -self.dy def handle_collide(self): # New for Rev2.0
#Calvin Field #4/26/15 #This is the same game as the quick_game.py, but using pygame, and not PIL import random from Tkinter import * import pygame from livewires import games, color import math #Creating screen window games.init(screen_width=700, screen_height=650, fps=50) #Make the class for creating the player controlled spaceship class Spaceship(games.Sprite): '''A spaceship controlled by the arrow keys''' image = games.load_image('8-bit_Spaceship_withBG.png') def __init__(self, y=590): '''Initiates the spaceship object and score text''' super(Spaceship, self).__init__( image=Spaceship.image, x=350, y=y, ) self.score = games.Text(value=0, size=30, color=color.red, top=5, right=games.screen.width - 10)
import os board = Board() board.loadBack('level1.map') board.setBoard('level1.units') images = [] units = [] act = 0 inactive = 1 screen_w = pygame.display.Info().current_w screen_h = pygame.display.Info().current_h CONST_TILE_SIZE = 60 CONST_SIDE_PANELS = 150 games.init(screen_width = (board.getWidth() * CONST_TILE_SIZE + CONST_SIDE_PANELS * 2), screen_height = (board.getHeight() * CONST_TILE_SIZE), fps = 50) print(os.getcwd()) explosion = games.load_sound('sounds/Flashbang-Kibblesbob-899170896.wav') #games.init(screen_width = (board.getLength() * 60), screen_height = (1500), fps = 50) mouse = games.Mouse() class HighlightBox(games.Sprite): def __init__(self, x, y): """ Draw a rounded rect onto a surface and use that surface as the image for a sprite. The surface is 80% transparent, so it seems like the unit is highlighted. RoundedRect equations from http://pygame.org/project-AAfilledRoundedRect-2349-.html
from livewires import games, color import math import random games.init(screen_width=600, screen_height=489, fps=50) class Player(games.Sprite): VELOCITY_STEP = .03 VELOCITY_STOP = .1 VELOCITY_MAX = 3 image = games.load_image('player1.png') def __init__(self, game, x, y): super(Player, self).__init__(image=Player.image, x=x, y=y) self.game = game def update(self): self.dx = min(max(self.dx, -Player.VELOCITY_MAX), Player.VELOCITY_MAX) self.dy = min(max(self.dy, -Player.VELOCITY_MAX), Player.VELOCITY_MAX) if self.dy < 0: tan = -self.dx / self.dy angle = math.atan(tan) self.angle = angle * 180 / math.pi elif self.dy > 0: tan = -self.dx / self.dy angle = math.atan(tan) self.angle = angle * 180 / math.pi + 180 elif self.dx > 0: self.angle = 90 elif self.dx < 0:
from livewires import games, color from random import randint import threading, string, random, time SCREEN_WIDTH = 1280 SCREEN_HEIGHT = 720 FPS = 50 VANISH_TIME_SEC = 5 PLANES_TOTAL_MIN = 1 PLANES_TOTAL_MAX = 4 games.init(screen_width=SCREEN_WIDTH, screen_height=SCREEN_HEIGHT, fps=FPS) class AirPlane(games.Sprite): image = games.load_image("rect.png") __text__ = None def __init__(self, x, y, text): super(AirPlane, self).__init__(image=AirPlane.image, x=x, y=y, dy=0, dx=0) self.__text__ = text def vanish(self): self.__text__.destroy() self.destroy()
# Bryce Ogden # Duckstermination # Final Game # Shoot gun by pressing spacebar # Turn gun by pressing left and right arrow keys # (directions also in game) from livewires import games, color import random, math games.init(screen_width=900, screen_height=600, fps=50) class Wrap(games.Sprite): """ A sprite that wraps around the screen """ def update(self): """ Wrap sprite around screen """ if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def die(self): """ Destroy self """ self.destroy() class Collide(games.Sprite): """ A Wrap that can collide with another object """
#Calvin Field #4/28/15 #Spaceship game import pygame from livewires import games, color import math import random from Tkinter import * import RespawnWin import NameSys games.init(screen_width=1600, screen_height=1000, fps=50) #Make all the global variables global_new_angle = 0 spaceshipX = 0 spaceshipY = 0 enemy_count = 0 user_dead = True already_made = True will_respawn = None score_value = 0 #Load images and sound for explosion explosion_files = [ 'Explode.png', 'Explode2.png', 'Explode3.png', 'Explode4.png', 'Explode5.png', 'Explode6.png', 'Explode7.png', 'Explode8.png',
from livewires import games games.init() class Ship(games.Sprite): """Spin ship special image, in due pushed button""" def update(self): if games.keyboard.is_pressed(games.K_RIGHT): self.angle += 1 if games.keyboard.is_pressed(games.K_LEFT): self.angle -= 1 if games.keyboard.is_pressed(games.K_1): self.angle = 0 if games.keyboard.is_pressed(games.K_2): self.angle = 90 if games.keyboard.is_pressed(games.K_3): self.angle = 180 if games.keyboard.is_pressed(games.K_4): self.angle = 270 def main(): nebula_image = games.load_image('nebula.jpg', transparent=False) games.screen.background = nebula_image ship_image = games.load_image('ship.bmp') the_ship = Ship(ship_image, x=games.screen.width / 2, y=games.screen.height / 2) games.screen.add(the_ship) games.screen.mainloop()
from livewires import games, color import random games.init(screen_width=680, screen_height=650, fps=50) ## Menu options def main(): choice = None while choice != "0": print( """ PyPong options 0 - Quit 1 - Display creator's name + credits 2 - Full game title 3 - game instructions 4 - start game """ ) choice = input("Choice: ") print() ##exit if choice == "0": print("Goodbye") ##creator name elif choice == "1": print("Alan Brincks, special thanks to Dr. Craven, Michael Dawson, and Carolyn Brodie")
#Sprite (THE HACKLAB!) from livewires import games games.init(screen_width = 800, screen_height = 500, fps = 50) hacklab_img = games.load_image("HackLab.png") hacklab = games.Sprite(image = hacklab_img, x = 400, y = 250) games.screen.add(hacklab) hacklab_BG = games.load_image("HackLabBG.png") games.screen.background = hacklab_BG games.screen.mainloop()
# Simplified classic Pong for 1 player. from livewires import games, color games.init(screen_width=630, screen_height=400, fps=50) class Ball(games.Sprite): ball_image = games.load_image("bb.png") def __init__(self): super(Ball, self).__init__(image=Ball.ball_image, x=games.screen.width / 2, y=20, dx=1, dy=1) self.score = games.Text(value=0, size=25, color=color.black, top=5, right=games.screen.width - 10) games.screen.add(self.score) def update(self): if self.right > games.screen.width or self.left < 0: self.dx = -self.dx elif self.top < 0: self.dy = -self.dy elif self.bottom > games.screen.height:
# Bouncing Pizza # Demonstrates dealing with screen boundaries from livewires import games games.init(screen_width=640, screen_height=480, fps=50) class Pizza(games.Sprite): """ A bouncing pizza. """ def update(self): """Rverse a velocity component if edge of screen reached.""" if self.right > games.screen.width or self.left < 0: self.dx = -self.dx if self.bottom > games.screen.height or self.top < 0: self.dy = -self.dy def main(): wall_image = games.load_image("wall.jpg", transparent=False) games.screen.background = wall_image pizza_image = games.load_image("pizza.png") the_pizza = Pizza(image = pizza_image, x = games.screen.width/2, y = games.screen.width/2, dx = 1, dy = 1) games.screen.add(the_pizza) games.screen.mainloop() # kick it off main()
""" Python 3.1.1 Pygame 1.9.1 Evgeny Smirnov """ from livewires import games, color import math import random games.init(screen_width=1600, screen_height=1020, fps=50) # screen class Ship(games.Sprite): """main class of all ships""" def update(self): if self.top > games.screen.height: self.bottom = 0 if self.bottom < 0: self.top = games.screen.height if self.left > games.screen.width: self.right = 0 if self.right < 0: self.left = games.screen.width def attack(self): new_missle = Missle(self.x, self.y, self.angle) games.screen.add(new_missle) class Player(Ship):
##GALAXE from livewires import color, games import random import os games.init(screen_width=1350, screen_height=725, fps=50) background=games.load_image(os.getcwd()+"\\files\\"+"\\Galaxe\\"+"Gbackground.png", transparent=False) games.music.load(os.getcwd()+"\\files\\"+"\\Galaxe\\"+"hyperspace.mp3") games.music.play(-1) class spaceship(games.Sprite): """Player's ship class""" pic=games.load_image(os.getcwd()+"\\files\\"+"\\Galaxe\\"+"ship.png") def __init__(self): """creates and sets up the class""" super(spaceship, self).__init__(image=spaceship.pic, x=games.screen.width/2, bottom=games.screen.height-5) self.missle_delay=125 self.paused=False def update(self): """Checks for input from the player""" if games.keyboard.is_pressed(games.K_LEFT) and self.paused==False: self.x-=3 if games.keyboard.is_pressed(games.K_RIGHT) and self.paused==False: self.x+=3 if games.keyboard.is_pressed(games.K_SPACE) and self.missle_delay<=0 and self.paused==False: self.shoot() self.missle_delay=50 if self.left<0: self.left=0 if self.right>games.screen.width: self.right=games.screen.width self.missle_delay-=1 if games.keyboard.is_pressed(games.K_p):
from livewires import games, colour import pygame import random games.init(screen_width=1024, screen_height=512, fps=60) class Hero(games.Sprite): points = 0 sound = games.load_sound('sounds/game_over.wav') scr = games.load_image('img/hero_11.png') reloading = 0 pause = 70 def __init__(self, dx): super(Hero, self).__init__(image=Hero.scr, x=games.screen.width / 2, bottom=games.screen.height - 90, dx=dx) self.dx = dx self.score = games.Text(value=Hero.points, size=32, color=colour.black, top=5, right=games.screen.width - 12) self.score_letter = games.Text(value='Score: ', size=32, color=colour.black, top=5,