Пример #1
0
def pokemon_game():
    global state, array, turns, image
    state = []
    array = {}
    turns = 0
    label.set_text("Turns = %d" % turns)
    image = []
    for i in range(8):
        image.append(simplegui.load_image('http://dex.pm222.com/images/pokemon_img_cg/%03d.png' % (i * 3 + 1)))
        # print 'http://dex.pm222.com/images/pokemon_img_cg/%03d.png' % (i * 3 + 1)
    image[7] = simplegui.load_image('http://dex.pm222.com/images/pokemon_img_cg/025.png')
    image.extend(image)
    for i in range(4):
        for j in range(4):
            array[(i, j)] = image.pop(random.randrange(len(image)))
Пример #2
0
 def __init__(self, game):
     self._draw_instruction = False
     self._rows = game.get_grid_height()
     self._cols = game.get_grid_width()
     self._frame = simplegui.create_frame(
         '2048', self._cols * TILE_SIZE + 2 * BORDER_SIZE,
         self._rows * TILE_SIZE + 2 * BORDER_SIZE)
     self._frame.add_button('New Game', self.start, 100)
     for labels in range(20):
         self._frame.add_label("", 200)
     self._button = self._frame.add_button("How to Play", self.instruction,
                                           100)
     self._frame.set_keydown_handler(self.keydown)
     self._frame.set_draw_handler(self.draw)
     self._frame.set_canvas_background("#BCADA1")
     self._frame.start()
     self._game = game
     url = URL
     self._tiles = simplegui.load_image(url)
     self._directions = {
         "up": UP,
         "down": DOWN,
         "left": LEFT,
         "right": RIGHT
     }
Пример #3
0
    def load(self):  # type: () -> None
        """
        **Start loading** of all images and sounds added
        since last `Loader.load()` execution.

        * In standard Python with SimpleGUICS2Pygame: draw a progression bar on canvas and wait until the loading is finished.
        * In SimpleGUI of CodeSkulptor: *don't* wait.
        """  # noqa
        if Loader.__SIMPLEGUICS2PYGAME:
            from SimpleGUICS2Pygame.simpleguics2pygame import load_image, load_sound  # pylint: disable=import-outside-toplevel  # noqa
        else:
            from simplegui import load_image, load_sound  # type: ignore  # pytype: disable=import-error  # pylint: disable=import-outside-toplevel,import-error  # noqa

        if Loader.__SIMPLEGUICS2PYGAME:
            handler_saved = self._frame._canvas._draw_handler  # pylint: disable=protected-access  # noqa
            self._frame._canvas._draw_handler = self._draw_loading  # pylint: disable=protected-access  # noqa

        for name in self._sounds:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()  # pylint: disable=protected-access
            if isinstance(self._sounds[name], str):
                self._sounds[name] = load_sound(self._sounds[name])

        for name in self._images:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()  # pylint: disable=protected-access
            if isinstance(self._images[name], str):
                self._images[name] = load_image(self._images[name])

        if Loader.__SIMPLEGUICS2PYGAME:
            self._frame._canvas._draw()  # pylint: disable=protected-access
            self._frame._canvas._draw_handler = handler_saved  # pylint: disable=protected-access  # noqa
Пример #4
0
    def load(self):
        """
        **Start loading** of all images and sounds added
        since last `Loader.load()` execution.

        * In standard Python with SimpleGUICS2Pygame: draw a progression bar on canvas and wait until the loading is finished.
        * In SimpleGUI of CodeSkulptor: *don't* wait.
        """
        if Loader.__SIMPLEGUICS2PYGAME:
            from SimpleGUICS2Pygame.simpleguics2pygame import load_image, \
                load_sound
        else:
            from simplegui import load_image, load_sound

        if Loader.__SIMPLEGUICS2PYGAME:
            handler_saved = self._frame._canvas._draw_handler
            self._frame._canvas._draw_handler = self._draw_loading

        for name in self._sounds:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._sounds[name], str):
                self._sounds[name] = load_sound(self._sounds[name])

        for name in self._images:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._images[name], str):
                self._images[name] = load_image(self._images[name])

        if Loader.__SIMPLEGUICS2PYGAME:
            self._frame._canvas._draw()
            self._frame._canvas._draw_handler = handler_saved
Пример #5
0
    def load(self):
        """
        **Start loading** of all images and sounds added
        since last `Loader.load()` execution.

        * In standard Python with SimpleGUICS2Pygame: draw a progression bar on canvas and wait until the loading is finished.
        * In SimpleGUI of CodeSkulptor: *don't* wait.
        """
        if Loader.__SIMPLEGUICS2PYGAME:
            from SimpleGUICS2Pygame.simpleguics2pygame import load_image, \
                load_sound
        else:
            from simplegui import load_image, load_sound

        if Loader.__SIMPLEGUICS2PYGAME:
            handler_saved = self._frame._canvas._draw_handler
            self._frame._canvas._draw_handler = self._draw_loading

        for name in self._sounds:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._sounds[name], str):
                self._sounds[name] = load_sound(self._sounds[name])

        for name in self._images:
            if Loader.__SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._images[name], str):
                self._images[name] = load_image(self._images[name])

        if Loader.__SIMPLEGUICS2PYGAME:
            self._frame._canvas._draw()
            self._frame._canvas._draw_handler = handler_saved
Пример #6
0
 def __init__(self, player, pos, xBox, yBox, filename, items):
     self.pos = pos
     self.xBox = xBox
     self.yBox = yBox
     self.player = player
     self.filename = filename
     self.image = simplegui.load_image(self.filename)
     self.items = items
 def __init__(self):
     """
     Create a frame and load the cancer data
     """
     self._frame = simplegui.create_frame("Cancer risk visualization", CANVAS_WIDTH, CANVAS_HEIGHT)
     self._frame.set_canvas_background("White")
     self._frame.set_draw_handler(self.draw)
     self._frame.add_input("Enter cutoff (scaled by 0.00001)", self.enter_cutoff, 200)
     self._frame.add_button("Print data table in CSV", self.print_table, 200)
     self._data_table = self.load_data()
     self.enter_cutoff("0.0")
     self._USA_Counties = simplegui.load_image(MAP_URL)
     self._frame.start()
Пример #8
0
    def __init__(self, center, width, height, type="none"):
        self.__center = center
        self.__width = width
        self.__height = height
        self.__top_left = Vector(self.__center.x - self.__width / 2,
                                 self.__center.y - self.__height / 2)
        self.__top_right = Vector(self.__center.x + self.__width / 2,
                                  self.__center.y - self.__height / 2)
        self.__bot_left = Vector(self.__center.x - self.__width / 2,
                                 self.__center.y + self.__height / 2)
        self.__bot_right = Vector(self.__center.x + self.__width / 2,
                                  self.__center.y + self.__height / 2)
        self.__walls = [
            Wall(self.__top_left, self.__top_right, "N"),
            Wall(self.__top_right, self.__bot_right, "E"),
            Wall(self.__bot_right, self.__bot_left, "S"),
            Wall(self.__bot_left, self.__top_left, "W")
        ]
        self.__type = type
        self.__characters = []
        self.__neighbours = {"N": None, "E": None, "S": None, "W": None}
        self.__doors = {}
        self.__enemies = []

        self.__tileset = simplegui.load_image(
            "https://i.imgur.com/a55akyp.png")
        self.__wall_sprite_size = (32, 32)
        self.__wall_sprite_pos_dict = {
            "N": (16, (64 + self.__wall_sprite_size[1] / 2)),
            "E": ((32 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2)),
            "S": ((96 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2)),
            "W": ((64 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2))
        }
        self.__corner_sprite_pos_dict = {
            "NW": ((128 + 16), (64 + 16)),
            "NE": (16, (96 + 16)),
            "SE": ((32 + 16), (96 + 16)),
            "SW": ((64 + 16), (96 + 16))
        }
        self.__door_sprite_size = (64, 32)
        self.__door_sprite_pos = ((128),
                                  (128 + self.__door_sprite_size[1] / 2))

        if (type == "end"):
            self.__ladder_pos = ((96 + 16), (96 + 16))
            self.__ladder_size = (32, 32)
            self.__level_door = Door("C", self.__center)
Пример #9
0
 def drawLines(self, canvas):
     for i in range(self.platform - 1):
         #print(self.coords)
         #y = (i + 1) * self.yVal
         #canvas.draw_line(self.coords[i].getp1().getP(),self.coords[i].getp2().getP(), self.coords[i].thickness, "red")
         img = simplegui.load_image("https://i.imgur.com/HocnWqj.png")
         #self.coords[i].yCoord +=1
         canvas.draw_image(img, (128 / 2, 32 / 2), (128, 32),
                           (self.coords[i].getp1().getP()[0] +
                            (self.coords[i].getp2().getP()[0] -
                             self.coords[i].getp1().getP()[0]) / 2,
                            self.coords[i].getp1().getP()[1]),
                           (abs(self.coords[i].getp2().getP()[0] -
                                self.coords[i].getp1().getP()[0]),
                            self.coords[i].thickness * 16))
Пример #10
0
 def __init__(self, keyboard, game):
     self.game = game
     self.game.newRound(1)
     self.keyboard = keyboard
     self.projectiles = []
     self.explosions = []
     self.trails = []
     self.currentlyColliding = {}
     self.pauseCounter = 100
     self.isPaused = False
     self.setMappings()
     self.mousePos = self.game.player.pos
     for line in self.game.terrain.lines:
         self.currentlyColliding[(self.game.player, line)] = False
     self.cursor = simplegui.load_image('https://i.imgur.com/GYXjv5a.png')
Пример #11
0
 def __init__(self):
     """
     Create a frame and load the cancer data
     """
     self._frame = simplegui.create_frame("Cancer risk visualization",
                                          CANVAS_WIDTH, CANVAS_HEIGHT)
     self._frame.set_canvas_background("White")
     self._frame.set_draw_handler(self.draw)
     self._frame.add_input("Enter cutoff (scaled by 0.00001)",
                           self.enter_cutoff, 200)
     self._frame.add_button("Print data table in CSV", self.print_table,
                            200)
     self._data_table = self.load_data()
     self.enter_cutoff("0.0")
     self._USA_Counties = simplegui.load_image(MAP_URL)
     self._frame.start()
Пример #12
0
 def __init__(self, game):
     self._rows = game.get_grid_height()
     self._cols = game.get_grid_width()
     self._frame = simplegui.create_frame('2048',
                     self._cols * TILE_SIZE + 2 * BORDER_SIZE,
                     self._rows * TILE_SIZE + 2 * BORDER_SIZE)
     self._frame.add_button('New Game', self.start)
     self._frame.set_keydown_handler(self.keydown)
     self._frame.set_draw_handler(self.draw)
     self._frame.set_canvas_background("#BCADA1")
     self._frame.start()
     self._game = game
     url = codeskulptor.file2url(IMAGENAME)
     self._tiles = simplegui.load_image(url)
     self._directions = {"up": UP, "down": DOWN,
                         "left": LEFT, "right": RIGHT}
Пример #13
0
 def draw(self, canvas, lives, health, score, gun, money):
     offset = 100
     image = simplegui.load_image(
         'https://raw.githubusercontent.com/NJHewadewa/DebtRunners/master/Sprites/HRT.png'
     )
     if self.visible == True:
         for x in range(lives):
             canvas.draw_image(image, (896 / 2, 896 / 2), (896, 896),
                               [offset + (50 * x), self.canvasHeight - 68],
                               (64, 64))
         canvas.draw_polygon([[250, 620], [(250 + health), 620],
                              [(250 + health), 645], [250, 645]], 1,
                             'Black', 'Red')
         canvas.draw_text(str(health), [250, 670], 15, 'Red')
         StringScore = "Score: " + str(score)
         canvas.draw_text(StringScore, [1050, 635], 20, 'Yellow')
         CurrentGun = "Gun: " + gun
         canvas.draw_text(CurrentGun, [850, 635], 20, 'Yellow')
         CurrentMoney = "£ " + str(money)
         canvas.draw_text(CurrentMoney, [750, 635], 20, 'Yellow')
Пример #14
0
    def __init__(self, game):
        self._game = game
        self._rows = game.get_grid_height()
        self._cols = game.get_grid_width()
        self._frame = simplegui.create_frame('2048',
                        self._cols * TILE_SIZE + 2 * BORDER_SIZE,
                        self._rows * TILE_SIZE + 2 * BORDER_SIZE)
        self._frame.add_button('New Game', self.start)
        self._frame.set_keydown_handler(self.keydown)
        self._frame.set_draw_handler(self.draw)
        self._frame.set_canvas_background("#BCADA1")
        # url = codeskulptor.file2url(IMAGENAME)
        # url = 'http://commondatastorage.googleapis.com/codeskulptor-assets/' \
        #        + IMAGENAME
        url = 'https://raw.githubusercontent.com/guohengkai/' \
                + 'hw-poc/master/assets/' + IMAGENAME

        self._tiles = simplegui.load_image(url)
        self._directions = {"up": UP, "down": DOWN,
                            "left": LEFT, "right": RIGHT}
        self._frame.start()
Пример #15
0
 def __init__(self, game):
     self._rows = game.get_grid_height()
     self._cols = game.get_grid_width()
     self._frame = simplegui.create_frame(
         '2048', self._cols * TILE_SIZE + 2 * BORDER_SIZE,
         self._rows * TILE_SIZE + 2 * BORDER_SIZE)
     self._frame.add_button('New Game', self.start)
     self._frame.set_keydown_handler(self.keydown)
     self._frame.set_draw_handler(self.draw)
     self._frame.set_canvas_background("#BCADA1")
     #self._frame.start() # this did not work, as the frame disturbed the initialization process while starting
     self._game = game
     #url = codeskulptor.file2url(IMAGENAME) # this is the origial version
     url = 'http://codeskulptor-assets.commondatastorage.googleapis.com/assets_2048.png'
     self._tiles = simplegui.load_image(url)
     self._directions = {
         "up": UP,
         "down": DOWN,
         "left": LEFT,
         "right": RIGHT
     }
     self._frame.start()
Пример #16
0
    def __init__(self, damage, pos, vel, angle):
        super().__init__(damage)
        self.pos = pos
        self.vel = vel
        self.angle = angle

        # Sprite date
        self.spritesheet = simplegui.load_image(
            "https://i.imgur.com/T8BwM8E.png")
        self.img_width = 840
        self.img_height = 54
        self.img_columns = 10
        self.img_rows = 6

        # Fram data
        self.frame_width = self.img_width / self.img_columns
        self.frame_height = self.img_height / self.img_rows
        self.frame_centre_x = self.frame_width / 2
        self.frame_centre_y = self.frame_height / 2
        self.frame_index = [1, 0]
        self.frame_duration = 2
        self.frameclock = 0
        self.radius = self.frame_width / 2
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw_handler)

labelA = frame.add_label('Formation Control')
button1 = frame.add_button('Circle Formation', button_handler_c)
label1 = frame.add_label(' ')
button2 = frame.add_button('V Formation', button_handler_v)
label2 = frame.add_label(' ')
label3 = frame.add_label(' ')
label4 = frame.add_label(' ')
labelA = frame.add_label('Circle Diameter Control')
buttonA = frame.add_button('+', button_cplus, 25)
label5 = frame.add_label(' ')
buttonB = frame.add_button('-', button_cminus, 25)

label6 = frame.add_label(' ')
label7 = frame.add_label(' ')
labelB = frame.add_label('V Distance Control')
buttonC = frame.add_button('+', button_vplus, 25)
label8 = frame.add_label(' ')
buttonD = frame.add_button('-', button_vminus, 25)

#images
imageR = simplegui.load_image('file:///X:/GIT_ROOT/cluster-bird-formation-sim/images/right_bird.gif')
imageL = simplegui.load_image('file:///X:/GIT_ROOT/cluster-bird-formation-sim/images/left_bird.gif') 
bg = simplegui.load_image('file:///X:/GIT_ROOT/cluster-bird-formation-sim/images/bg.png')


frame.start()
Пример #18
0
## pygame - http://www.pygame.org/download.shtml
## SimpleGUICS2Pygame - https://simpleguics2pygame.readthedocs.org/

## Module was initially intended to be run with CodeSkulptor http://www.codeskulptor.org/#examples-blackjack_template.py
## In order to run on local Phython instance, call to import module 'simplegui' has been modified.

# Mini-project #6 - Blackjack

# import simplegui
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card sprite - 936x384 - source: jfitz.com
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
card_images = simplegui.load_image(
    "http://storage.googleapis.com/codeskulptor-assets/cards_jfitz.png")

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = (36, 48)
card_back = simplegui.load_image(
    "http://storage.googleapis.com/codeskulptor-assets/card_jfitz_back.png")

# initialize some useful global variables
in_play = False
outcome = ""
score = 0

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {
Пример #19
0
        return self.size

    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated

   
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim

debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/" + random.choice(debris_choice))

nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/" + random.choice(nebula_choice))

splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")

ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://i.imgur.com/Y28T5p1.png")

missile_info = ImageInfo([5,5], [10, 10], 3, 50)
missile_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/" + random.choice(missile_choice))

asteroid_info = ImageInfo([45, 45], [90, 90], 40)
asteroid_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/" + random.choice(asteroid_choice))
        canvas.draw_image(image, ((50+100*card), 75), (100, 150), ((50+i), 75), (100, 150))
        canvas.draw_line((100+i,0),(100+i,150), 1,'white')
        i += 100
    i = 0
    for back in exposed:
        if back:
            canvas.draw_image(image_back, (354/2, 540/2), (354, 540), ((50+i), 75), (100, 150))
            
#if you don't like my design - uncomment next line
           #canvas.draw_line((50+i, 0), (50+i,150), 100, 'Green')
            canvas.draw_line((100+i,0),(100+i,150), 1,'black')
        i += 100
        

# create frame and add a button and labels
frame = simplegui.create_frame("Memory", 1600, 150)
frame.add_button("Reset", new_game)
label = frame.add_label("Turns = 0")

# register event handlers
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)
image = simplegui.load_image('http://s24.postimg.org/gkpjo5745/image.jpg')
image_back = simplegui.load_image('http://www.ukrcards.com.ua/catalog/1330218527.jpg')
# get things rolling
new_game()
frame.start()


# Always remember to review the grading rubric
Пример #21
0
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import sys

import xmlrpclib
import time
from service_thread import ServiceThread
from SimpleXMLRPCServer import SimpleXMLRPCServer

# ## Globals (state)
message = "GUI Test"
store = 0
inData = 0
#im = Image.open("/home/i2cat/Documents/test.png", mode='r')
#im = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/gutenberg.jpg")
im = simplegui.load_image("/home/i2cat/Documents/test.png")

### Helper functions

### Classes


### Define event handlers
# Handler for mouse click
def click(pos=None):
    global message
    global mag_pos
    message = "Click"
    if pos:
        mag_pos = list(pos)
# global constants
WIDTH = 600
HEIGHT = 600

click_pos = [WIDTH / 2, HEIGHT / 2]

IMG_WIDTH = 720
IMG_HEIGHT = 720
SCALE = 0.5
img_center = [IMG_WIDTH // 2, IMG_HEIGHT // 2]
img_size = [IMG_WIDTH, IMG_HEIGHT]

w_size = [IMG_WIDTH * SCALE, IMG_HEIGHT * SCALE]

# load test image
img = simplegui.load_image('http://i.imgur.com/sX0CCcJ.jpg')


# mouseclick handler
def click(pos):
    global click_pos
    click_pos = list(pos)


# draw handler
def draw(canvas):
    canvas.draw_image(img, img_center, img_size, click_pos, w_size)


# create frame and register draw handler
frame = simplegui.create_frame("Test image", WIDTH, HEIGHT)
Пример #23
0
#HANGMAN GAME
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random
num_guesses=6
happ=["_","_",'_','_','_','_']
game_1,play,head,body,left_arm,right_arm,left_leg,right_leg,word=False,False,False,False,False,False,False,False,False
secret,game=True,True
start= True
win_image = simplegui.load_image("http://www.newyorker.com/wp-content/uploads/2016/01/Duca-Donald-Trumps-Path-to-Victory-290x149-1453933086.jpg")
lose_image = simplegui.load_image("http://static.tvtropes.org/pmwiki/pub/images/hanging2_3655.jpg")
start_first = True
loss = False
win = False

loss_sound = simplegui.load_sound("D:\Pygame\csProject\hangman_loss.ogg")
win_sound = simplegui.load_sound("D:\Pygame\csProject\hangman_win.ogg")

def draw(canvas):
    global num_guesses
    canvas.draw_text("*H-A-N-G-M-A-N*",(50,50),40,"Red")
    if start:
        canvas.draw_text(" CHOOSE AN OPTION ",(40,120),30,"Red")
        canvas.draw_polygon([(30,170),(190,170),(190,230),(30,230)],6,"Red")
        canvas.draw_polygon([(30,250),(190,250),(190,310),(30,310)],6,"Red")
        canvas.draw_polygon([(30,330),(190,330),(190,390),(30,390)],6,"Red")
        canvas.draw_polygon([(210,170),(370,170),(370,230),(210,230)],6,"Red")
        canvas.draw_polygon([(210,250),(370,250),(370,310),(210,310)],6,"Red")
        canvas.draw_polygon([(210,330),(370,330),(370,390),(210,390)],6,"Red")
        canvas.draw_text("ANIMALS",(40,210),30,"Red")
        canvas.draw_text("VOCAB",(40,290),30,"Red")
        canvas.draw_text("SOCIAL",(40,370),30,"Red")
Пример #24
0
# implementation of card game - Memory

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

back_image = simplegui.load_image("https://dl.dropboxusercontent.com/u/38413745/back_card.png")

#Start a new game
def new_game():
    global cards, state, turn, exposed
    turn = 0
    state = 0 			   # State of cards
    exposed = [False] * 16 # By default all cards are facing down
    list1 = range(8)
    cards = list1 + list1
    random.shuffle(cards) # creates random deck of card  
    label.set_text("Turns = " + str(turn))
                    
# Mouse click event handlers
def mouseclick(pos):
    global exposed, state, first_card, second_card, turn
    start = 0
    end = 49
    for i in range(16):
        if pos[0] >= start and pos[0] <= end and exposed[i] == False: 
            if state == 0:
                state = 1
                first_card = i
            elif state == 1:
                state = 2
                second_card = i
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated


# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim

# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png"
)

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "http://i.space.com/images/i/000/023/673/wS1/vista-look-at-helix-nebula-1600.jpg?1352931499"
)

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png"
)

# ship image
Пример #26
0
    def get_animated(self):
        """ Return animation. """
        return self.animated
    
    def get_frames (self):
        """ Return number of frames if object animated. """
        return self.frames

# load images and create ImageInfo objects to store its features    
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects
    
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image1 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris1_blue.png")
debris_image2 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
debris_image3 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris3_blue.png")
debris_image4 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris4_blue.png")
debris_image5 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris1_brown.png")
debris_image6 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_brown.png")
debris_image7 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris3_brown.png")
debris_image8 = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris4_brown.png")
    # create group of images for random choice
debris_image_group = [debris_image1, debris_image2, debris_image3, debris_image4, debris_image5, debris_image6, debris_image7, debris_image8]
debris_image = debris_image1

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_1_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2013.png")
nebula_2_image = simplegui.load_image ("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_brown.png")
 
        self.age += 1
        return self.age > self.lifespan
 
    def collide(self, other_object):
        return dist(self.pos, other_object.pos) <= self.radius + other_object.radius

 
# art assets created by Kim Lathrop, may be freely re-used in
# non-commercial projects, please credit Kim
 
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png,
# debris_blend.png        3D effects
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
 
# nebula images - nebula_brown.png, nebula_blue.png    background
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "https://dl.dropboxusercontent.com/u/280794727/spaceglory/spice%20background.jpg")


blood_effect_info = ImageInfo([400, 300], [800, 600])
blood_effect_image = simplegui.load_image(
    "https://dl.dropboxusercontent.com/u/280794727/spaceglory/emergency.png")

# splash image    click to start image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "https://dl.dropboxusercontent.com/u/280794727/spaceglory/space%20glory.png")
 def __init__(self, img):
     self._img =  simplegui.load_image(img)
Пример #29
0
# Implementation of classic arcade game Pong

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random
import time

# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400       
BALL_RADIUS = 25
PAD_WIDTH = 20
PAD_HEIGHT = 120
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
fatality = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/Pong/fatality.png")
ball = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/Pong/ball.png")
paddle1 = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/Pong/p1.png")
paddle2 = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/Pong/p2.png")
background = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/Pong/bg.jpg")
ball_pos = [300, 200]
ball_rot = 0
paddle1_pos = [10, 200]
paddle2_pos = [590, 200]
vel = [0, 0]
paddle1_vel = 0
paddle2_vel = 0
in_play = "False"
direction = "left"
score1 = 0
score2 = 0
fatal_tick = 4
Пример #30
0
 def __init__(self, pos, vel, angle):
     self.damage = 7
     super().__init__(self.damage, pos, vel, angle)
     self.spritesheet = simplegui.load_image(
         "https://i.imgur.com/DYGyWeB.png")
Пример #31
0
    def get_center(self):
        return self.center

    def get_size(self):
        return self.size

    def get_radius(self):
        return self.radius
    def get_lifespan(self):
        return self.lifespan
    def get_animated(self):
        return self.animated

# debris images    
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2014.png")
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 50)
missile_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/shot2.png")
# asteroid images - asteroid_blue.png, asteroid_brown.png, asteroid_blend.png
asteroid_info = ImageInfo([45, 45], [90, 90], 40)
asteroid_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/asteroid_blue.png")
Пример #32
0
# Implementation of simplified version of Blackjack

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card images - 949x392
CARD_SIZE = (73, 98)
CARD_CENTER = (36.5, 49)
card_images = simplegui.load_image("https://dl.dropboxusercontent.com/u/38413745/blackjack_cards.png")

# back image for dealers hole card
CARD_BACK_SIZE = (71, 96)
CARD_BACK_CENTER = (35.5, 48)
card_back = simplegui.load_image("https://dl.dropboxusercontent.com/u/38413745/blackjack_card_back.png")    

# global variables
in_play = False
outcome = ""
message = ""
last_game = ""
score = 0
card_deck = []
player_hand = []
dealers_hand = []

# global variable for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}

# card class
Пример #33
0
radius=3
vel=[random.randrange(-1,2,2),random.randrange(-1,2)]
score_1=0
score_2=0
Pad_Top_Left_y=0
Pad_Bottom_Left_y=50
Pad_Top_Right_y=0
Pad_Bottom_Right_y=50
Pad_Right=[Pad_Top_Right_y,Pad_Bottom_Right_y]
Pad_Height=0
Pad_Height_1=0
Pad_Left=[Pad_Top_Left_y,Pad_Bottom_Left_y]
LEFT,RIGHT=False,False
start = True
controls = False
w_key = simplegui.load_image("https://www.wpclipart.com/computer/keyboard_keys/letters/computer_key_W.png")
s_key = simplegui.load_image("https://www.wpclipart.com/computer/keyboard_keys/letters/computer_key_S.png")
up_key = simplegui.load_image("https://www.wpclipart.com/computer/keyboard_keys/arrow_keys/computer_key_Arrow_Up.png")
down_key = simplegui.load_image("https://www.wpclipart.com/computer/keyboard_keys/arrow_keys/computer_key_Arrow_Down.png")
multi_arrow_image=simplegui.load_image("https://cdn2.iconfinder.com/data/icons/crystalproject/crystal_project_256x256/apps/restart-1.png")

pong_sound = simplegui.load_sound("D:\Pygame\csProject\pong_music.ogg")
pong_sound.set_volume(.5)
pong_sound.play()

pong_image = simplegui.load_image("http://www.slashgear.com/wp-content/uploads/2015/07/PONG.jpg")
pong_restart = simplegui.load_sound("D:\Pygame\csProject\pong_restart.ogg")

#HANDLER(S)
def draw(canvas):
    global vel,score_1,LEFT,RIGHT,score_2,Pad_Height,Pad_Right,Pad_Left,Pad_Height_1
Пример #34
0
        """ Return animation. """
        return self.animated

    def get_frames(self):
        """ Return number of frames if object animated. """
        return self.frames


# load images and create ImageInfo objects to store its features
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects

# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image1 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris1_blue.png"
)
debris_image2 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png"
)
debris_image3 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris3_blue.png"
)
debris_image4 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris4_blue.png"
)
debris_image5 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris1_brown.png"
)
debris_image6 = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_brown.png"
Пример #35
0
    global turns
    height = 50
    for num in range(len(grid)):
        width = 25
        for cell in range(len(grid[num])):
            if exposed_grid[num][cell]:
                canvas.draw_text(str(grid[num][cell]),
                                 (width - 15, height + 20), 50, 'blue')
            else:
                canvas.draw_image(image, (413 / 2, 620 / 2), (413, 620),
                                  (width, height), (50, 100))
            width += 50
        height += 100

    label.set_text("Turns = " + str(turns))


# create frame and add a button and labels
frame = simplegui.create_frame("Memory", 200, 400)
frame.add_button("Reset", new_game)
label = frame.add_label("Turns = 0")
image = simplegui.load_image(
    'https://image.shutterstock.com/image-vector/playing-card-back-side-600w-90984266.jpg'
)
# register event handlers
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)

new_game()
frame.start()
Пример #36
0
"""
Blackjack
"""

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card sprite - 936x384 - source: jfitz.com
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
CARD_IMAGES = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/cards_jfitz.png")

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = (36, 48)
CARD_BACK = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/card_jfitz_back.png")    

# initialize global variables that are changed during the programm
in_play_G = False
score_G = 0

# Define global constants for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}



class Card:
    """
    The card class. Gives information of a card like suits and rank and draws a card.
    """
Пример #37
0
# Mini-project #6 - Blackjack ----
# http://www.codeskulptor.org/#user26_pq1IrU26LU_0.py

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card sprite
CARD_SIZE = (73, 98)
CARD_SIZE_ = (125, 177)
CARD_CENTER = (62.5, 88.5)
card_images = simplegui.load_image("http://i.imgur.com/Mn3ONv1.jpg")

# load card back
CARD_BACK_SIZE = (73, 98)
CARD_BACK_SIZE_ = (125, 177)
CARD_BACK_CENTER = (62.5, 88.5)
card_back = simplegui.load_image("http://i.imgur.com/8ionrg6.jpg")

# load bground image
background_image = simplegui.load_image("http://i.imgur.com/N9ka4dG.jpg")

# initialize some useful global variables
in_play = False
outcome = ""
score = 0

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}
Пример #38
0

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random
import math


CARD_SIZE = (73, 98)
CARD_CENTER = (36.5, 49)
card_images = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")

CARD_BACK_SIZE = (71, 96)
CARD_BACK_CENTER = (35.5, 48)
card_back = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/card_back.png")    


in_play = False
outcome = ""
score = 0


SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}



class Card:
    def __init__(self, suit, rank):
        if (suit in SUITS) and (rank in RANKS):
            self.suit = suit
Пример #39
0
 def __init__(self, image):
     self.image = simpleguics2pygame.load_image(image)
     self.dimOriginal = Vector(self.image.get_width(),
                               self.image.get_height())
     self.dimCamera = Vector(0, 0)
Пример #40
0
# demo of animation using asteroid sprite sheet

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

# load 64 frame sprite sheer for asteroid - image source is opengameart, artist is warspawn
ROCK_CENTER = [64, 64]
ROCK_SIZE = [128, 128]
ROCK_DIM = 64
rock_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/asteroid1.opengameart.warspawn.png"
)

# global time for animation
time = 0


# draw handler
def draw(canvas):
    global time
    current_rock_index = (time % ROCK_DIM) // 1
    current_rock_center = [
        ROCK_CENTER[0] + current_rock_index * ROCK_SIZE[0], ROCK_CENTER[1]
    ]
    canvas.draw_image(rock_image, current_rock_center, ROCK_SIZE, ROCK_CENTER,
                      ROCK_SIZE)
    time += 0.2


# create frame and size frame based on 128x128 pixel sprite
frame = simplegui.create_frame("Asteroid sprite", ROCK_SIZE[0], ROCK_SIZE[1])
Пример #41
0
# Implementation of Memory Game

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

WIDTH = 600
HEIGHT = 400
width_height = (WIDTH/9,HEIGHT/4.5)
IMAGE_WIDTH = 175
IMAGE_HEIGHT = 240
Back_Center =  (910,660)

    
# load image from public domain picture of cards
image = simplegui.load_image("https://imgur.com/download/zchHPnd")


# helper function to initialize globals
def new_game():    
    global deck, first_click, second_click, first_index, second_index, new_game, show_all
    global winning_list, counter, screen_center_list, center_position 
    #List of tuples giving center position of each card in image and card value
    Center_List = [(91, 126,"A"),(296,126,"2"),(500,126,"3"),(705,126,"4"),(910, 393,"10"),(91, 660,"J"),(296, 660,"Q"),(501, 660,"K")]
    first_index = -1
    second_index = -1
    show_all = False
    first_click = False
    second_click = False
    new_game = True
    center_position = []
    winning_list = []
Пример #42
0
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated


# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim

# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png"
)

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2014.png"
)

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png"
)

# ship image
Пример #43
0
# import modules
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card sprite - 949x392 - source: jfitz.com
CARD_SIZE = (73, 98)
CARD_CENTER = (36.5, 49)
card_images = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")


CARD_BACK_SIZE = (71, 96)   
CARD_BACK_CENTER = (35.5, 48)
card_back = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/BlackJack/rsz_card_back.jpg")

BG_WIDTH, BG_HEIGHT = 600, 600
BG_IMAGE = simplegui.load_image("https://dl.dropboxusercontent.com/u/280794727/BlackJack/rsz_green_wool_7x7_pool_table_cloth.jpg")

# initialize some useful global variables
in_play = False
outcome = ""
message = ""
score = 0
FRAME_WIDTH = 600 
FRAME_HEIGHT = 600

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}

# load some sound
# Mini-project #6 - Blackjack

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# load card sprite - 936x384 - source: jfitz.com
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
card_images = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/cards_jfitz.png")

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = [36, 48]
card_back = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/card_jfitz_back.png")    
cent = simplegui.load_image('http://s1.sendimage.me/PnFaQnFR.png')
blackjack = simplegui.load_image('http://s1.sendimage.me/srhlAnGv.png')
bender = simplegui.load_image('http://s1.sendimage.me/EAbAHnGu.jpeg')
# initialize some useful global variables
in_play = False
money = 330
bet = 30
# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}


# define card class
class Card:
    def __init__(self, suit, rank):
        if (suit in SUITS) and (rank in RANKS):
            self.suit = suit
Пример #45
0
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

# 1521x1818 pixel map of native American language
# source - Gutenberg project

image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/gutenberg.jpg"
)

# Image dimensions
MAP_WIDTH = 1521
MAP_HEIGHT = 1818

# Scaling factor
SCALE = 3

# Canvas size
CAN_WIDTH = MAP_WIDTH // SCALE
CAN_HEIGHT = MAP_HEIGHT // SCALE

# Size of magnifier pane and initial center
MAG_SIZE = 120
mag_pos = [CAN_WIDTH // 2, CAN_HEIGHT // 2]


# Event handlers
# Move magnifier to clicked position
def click(pos):
    global mag_pos
    mag_pos = list(pos)
Пример #46
0
 def __init__(self, image):
     self.image = simplegui.load_image(image)
     self.width = self.image.get_width()
     self.height = self.image.get_height()
     self.frameSize = (self.width, self.height)
     self.frameCentre = (self.frameSize[0] / 2, self.frameSize[1] / 2)
Пример #47
0
    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated


# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
#debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
debris_image = simplegui.load_image("http://127.0.0.1:8080/debris2_blue.png")

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
# nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2014.png")
nebula_image = simplegui.load_image(
    "http://127.0.0.1:8080/nebula_blue.f2014.png")

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
# splash_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")
splash_image = simplegui.load_image("http://127.0.0.1:8080/splash.png")

# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
# ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
Пример #48
0
        puzzle_state = list(initState)
        timer.start()


def button_quit_application():
    """
    :description: Button function to quit program
    :return: None
    """
    if timer.is_running() is True:
        timer.stop()
    frame.stop()


# Sets the image file for the logo
image_logo = simplegui.load_image(
    'file:///X:/GIT_ROOT/8-puzzle-solver/logo.png')

# Frame initialisation
frame = simplegui.create_frame("8 Puzzle Solver", WIDTH, HEIGHT)

# Frame settings and control handlers initialisation
frame.set_canvas_background(CANVAS_BG)
frame.set_draw_handler(draw)
frame.set_mouseclick_handler(mouse_handler_input)
label1 = frame.add_label('8 Puzzle Solver')
blankSpace1 = frame.add_label('')
label2 = frame.add_label('Instruction:')
label3 = frame.add_label('1. Enter initial and goal states')
label4 = frame.add_label('  by clicking one tile at a time')
label5 = frame.add_label(' on keypad on the right')
label6 = frame.add_label('2. Click Find Solution button')
Пример #49
0
# Mini-project #6 - Blackjack by Vladimir Gosic

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random

# for printing values to the console set this to True
USE_PRINT = False

# load card images (949x460)
CARD_SIZE = (73, 115)
CARD_CENTER = (CARD_SIZE[0] / 2, CARD_SIZE[1] / 2)
CARD_SPACE = 10
card_images_standard = simplegui.load_image("http://i.imgur.com/bX4bLvm.png")
card_images_fancy = simplegui.load_image("http://i.imgur.com/D8SarJM.png")
card_images = card_images_fancy

# load card back images (73x115)
card_back_standard = simplegui.load_image("http://i.imgur.com/BDt4CCh.png")
card_back_fancy = simplegui.load_image("http://i.imgur.com/Ib5yDTJ.png")
card_back = card_back_fancy

# load background image (600x600)
BG_SIZE = (600, 600)
BG_CENTER = (BG_SIZE[0] / 2, BG_SIZE[1] / 2)
bg_image = simplegui.load_image("http://i.imgur.com/GhxDeyu.png")

# initialize the text items draw positions
SCORES_TOP = 570
LOC_DEALER = 200
LOC_PLAYER = 400
LEFT_MARGIN = 50
Пример #50
0
# Scott's Revenge

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

# images
joe = simplegui.load_image("http://farm9.staticflickr.com/8560/8876956295_fa57030cf4_o.png")
img_sz = (171, 370)
img_ctr = (img_sz[0] // 2, img_sz[1] // 2)

# globals
COLORS = ["Blue", "Red", "Yellow", "Green", "Maroon",
          "Aqua", "Fuchsia", "Lime", "Teal", "Olive",
          "Silver", "Purple"]
color_key = 0
ties = []


# classes
class Tie:
    def __init__(self):
        self.height = 150
        self.width = 30
        self.color = "White"
        self.location = (50, 200)

    def __str__(self):
        return "I am a " + self.color + " tie."

    def draw(self, canvas):
        x, y = self.location[0], self.location[1]
        w, h = self.width, self.height
Пример #51
0
# demo for drawing using tiled images

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

# define globals for cards
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
SUITS = ('C', 'S', 'H', 'D')

# card sprite - 950x392
CARD_CENTER = (36.5, 49)
CARD_SIZE = (73, 98)
card_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png"
)


# define card class
class Card:
    def __init__(self, suit, rank):
        self.rank = rank
        self.suit = suit

    def draw(self, canvas, loc):
        i = RANKS.index(self.rank)
        j = SUITS.index(self.suit)
        card_pos = [
            CARD_CENTER[0] + i * CARD_SIZE[0],
            CARD_CENTER[1] + j * CARD_SIZE[1]
        ]
        canvas.draw_image(card_image, card_pos, CARD_SIZE, loc, CARD_SIZE)

def canvas_Menu(canvas):  #HomeScreen

    canvas.draw_text('Snake Game', (140, 40), 46, 'Red')
    canvas.draw_text('Instructions', (40, 140), 36, 'Green')
    canvas.draw_text(
        " Don't run the snake into the wall, or his own tail: you die.",
        (40, 200), 19, 'Blue')  #Instructions
    canvas.draw_text(" Eat the red apples to gain points.  ", (40, 240), 19,
                     'Blue')
    canvas.draw_text(" Your score depends on the Difficulty  ", (40, 280), 19,
                     'Blue')


image = sg.load_image('https://image.ibb.co/g9rRoR/background2.png')


def input_handler(int_input):  #Function to input difficulty
    pass


def button_HighScoreScreen():  #Highscore screen
    read_highscores()
    frame.set_draw_handler(canvas_HighScoreScreen)


def read_highscores():  #Reads the highscore file
    global scores_list  #Stores the previous highscores
    scores_list = []
    highscore_text = open("Highscores.txt", "r")
Пример #53
0
        return self.radius
 
    def get_lifespan(self):
        return self.lifespan
 
    def get_animated(self):
        return self.animated
 
 
# art assets created by Kim Lathrop
 
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png,
# debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
 
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.png")
 
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")
 
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
Пример #54
0
 
    def get_lifespan(self):
        return self.lifespan
 
    def get_animated(self):
        return self.animated
 
 
# art assets created by Kim Lathrop, may be freely re-used in
# non-commercial projects, please credit Kim
 
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png,
# debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "https://www.dropbox.com/s/yno5lc731x34b4k/debris.png?dl=1")
 
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "https://www.dropbox.com/s/0e015b0pfk3p0e6/nebula.jpg?dl=1")
 
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "https://www.dropbox.com/s/8cgid4m470njdfb/asteroids_blue_tee.jpg?dl=1")
 
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image(
    "https://www.dropbox.com/s/n0p6q91huhlltxz/spaceship%2Bboost.png?dl=1")