Ejemplo n.º 1
0
from threading import Thread
import time

from pygame import *
from pygame.locals import *

import color as colour
import games
import netComms
from game_calcs import *
from Errors import *

try:
    reload(games)
    games.init(screen_width=1024, screen_height=768, fps=30)
    pass
except Exception as ex:
    print "Error in game init: " + str(ex)
    games.screen.quit()
    quit()
    games.init(screen_width=1024, screen_height=768, fps=30)


class superSquare(games.Sprite):
    """A generic square class"""
    def __init__(self, enemy, x, y):
        if enemy:
            image = games.load_image("res/Enemy.png")
        else:
            image = games.load_image("res/Friendly.png")
        super(superSquare, self).__init__(image=image, x=x, y=y)
# Astrocrash02
# Extending Astrocrash01 to add the Ship sprite class
# Added the ship sprite rotation
# Create the ship sprite object

import random
import livewires import games

games.init(screen_width = 640, screen_height = 480, fps = 50)

class Asteroid(games.Sprite):
    """ An asteroid which floats across the screen. """
    SMALL = 1
    MEDIUM = 2
    LARGE = 3
    images = {SMALL: games.load_image("asteroid_small.bmp"),
              MEDIUM: games.load_image("asteroid_med.bmp"),
              LARGE: games.load_image("asteroid_big.bmp") }
    SPEED = 2

    def __init__(self, x, y, size):
        """ Initialize asteroid sprite. """
        super(Asteroid, self).__init__(
            image = Asteroid.images[size],
            x = x, y = y,
            dx = random.choice([1, -1]) * Asteroid.SPEED * random.random()/size,
            dy = random.choice([1, -1]) * Asteroid.SPEED * radom.random()/size)
        self.size = size

    def update(self):
        """ Wrap around screen. """
Ejemplo n.º 3
0
#Breakout / Alleyway clone
#Kyle Robles

from livewires import color
import games

games.init(screen_width = 640, screen_height = 480, fps = 50)

class Player(games.Sprite):
	"""Main object user interacts with"""
	#Set Image and ball conditional
	image = games.load_image("bouncer.jpg")
	ballOut = False
	
	#Initialize screen position of player
	def __init__(self):
		super(Player, self).__init__(image = Player.image,
									x = games.screen.width/2,
									bottom = games.screen.height - 30)
										
	#Check movement and set boundaries
	def update(self):
		#Keyboard controls with a and s
		if games.keyboard.is_pressed(games.K_a):
			self.x -= 5
		if games.keyboard.is_pressed(games.K_s):
			self.x += 5
		if games.keyboard.is_pressed(games.K_SPACE) and self.ballOut == False:
			ball = Ball()
			games.screen.add(ball)
			self.ballOut = True		
from threading import Thread
import time

from pygame import *
from pygame.locals import *

import color as colour
import games
import netComms
from game_calcs import *
from Errors import *


try:
    reload(games)
    games.init(screen_width=1024, screen_height=768, fps=30)
    pass
except Exception as ex:
    print "Error in game init: " + str(ex)
    games.screen.quit()
    quit()
    games.init(screen_width=1024, screen_height=768, fps=30)


class superSquare(games.Sprite):
    """A generic square class"""
    def __init__(self, enemy, x, y):
        if enemy:
            image = games.load_image("res/Enemy.png")
        else:
            image = games.load_image("res/Friendly.png")
Ejemplo n.º 5
0
#Pizza Panic
import games, __init__, color, random

score = 0
games.init(screen_width=800, screen_height=600, fps=100)
chefimage = games.load_image("Chef.gif")
bowlimage = games.load_image("Bowl.gif")
pizzaimage = games.load_image("Pizza.gif")
wallimage = games.load_image("wall.gif")
games.screen.background = wallimage


class Chef(games.Sprite):
    def update(self):
        if self.right > 800:
            self.dx = -self.dx
            bounced_pos = "right"
        if self.left < 0:
            self.dx = -self.dx
            bounced_pos = "left"
        if bounced_pos == 'left':
            self.x += 3
        else:
            self.x -= 3
        n = random.randint(1, 3)
        if n == 2:
            games.screen.add(Pizza, x=self.x + 120, y=self.y)

    def __init__(self):
        super(Pan, self).__init__(image=bowlimage,
                                  x=games.mouse.x,
Ejemplo n.º 6
0
from pygame import *
import __init__, color, games
games.init(screen_width=1000, screen_height=700, fps=50)
image = games.load_image("pic.jpg")
image2 = games.Sprite(image=image,
                      x=games.screen.width / 2,
                      y=games.screen.height / 2)
games.screen.add(image2)
games.screen.mainloop()
Ejemplo n.º 7
0
from pygame import *
import __init__, color, games
games.init(screen_width=1000, screen_height=700, fps=50)
image=games.load_image("pic.jpg")
image2=games.Sprite(image=image, x=games.screen.width/2, y=games.screen.height/2)
games.screen.add(image2)
games.screen.mainloop()