From 6649503de407cb726ac7a395cefccf5c79dd689c Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:11:49 -0400 Subject: [PATCH 01/29] Create slither.py --- slither/slither.py | 316 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 slither/slither.py diff --git a/slither/slither.py b/slither/slither.py new file mode 100644 index 0000000..1126cb5 --- /dev/null +++ b/slither/slither.py @@ -0,0 +1,316 @@ +# SLITHER FOR PYTHON 2 AND 3 +# Hi there, code divers! +# There's a lot of cool stuff here that has comments so you can understand what's going on. +# You can even mess around with it yourself :) +# If you think your messing around might help, go to: +# https://github.com/PySlither/Slither +# and make a pull request! + +import pygame +import sys, os, collections, warnings, math + +WIDTH, HEIGHT = (800, 600) +SCREEN_SIZE = (WIDTH, HEIGHT) + +sprites = [] # List of all sprites +clock = pygame.time.Clock() # Used to control framerate +eventnames = ['QUIT', 'ACTIVEEVENT', 'KEYDOWN', 'KEYUP', 'MOUSEMOTION', 'MOUSEBUTTONUP', 'MOUSEBUTTONDOWN', + 'JOYAXISMOTION', 'JOYBALLMOTION', 'JOYHATMOTION', 'JOYBUTTONUP', 'JOYBUTTONDOWN', + 'VIDEORESIZE', 'VIDEOEXPOSE', 'USEREVENT'] +eventCallbacks = { + getattr(pygame, name): lambda e=None: True + for name in eventnames + } # Create a dict of callbacks that do nothing +globalscreen = None + +keysPressed = [] + +try: + scriptdir = os.path.dirname(os.path.realpath(__import__("__main__").__file__)) +except AttributeError: + warnings.warn("Couldn't find scripts dir, some functions may not work.") + scriptdir = os.path.realpath(".") + + +def keysDown(): + "returns the keys that are currently pressed" + return keysPressed[:] + +# Convienience functions +# Taken from http://stackoverflow.com/questions/4183208/how-do-i-rotate-an-image-around-its-center-using-pygame +def rotateCenter(image, angle): + '''rotate a Surface, maintaining position.''' + rot_sprite = pygame.transform.rotate(image, angle) + return rot_sprite + +class Mouse: + """A class for getting and setting mouse properties + This is a static class, all functions should be called directly through the class""" + _v = True + + @staticmethod + def buttonsPressed(): + """Returns a three-tuple of bools that gives the state + of the left, middle, and right buttons""" + return tuple(bool(state) for state in pygame.mouse.get_pressed()) + + @staticmethod + def leftPressed(): + return Mouse.buttonsPressed()[0] + + @staticmethod + def middlePressed(): + return Mouse.buttonsPressed()[1] + + @staticmethod + def rightPressed(): + return Mouse.buttonsPressed()[2] + + @staticmethod + def pos(): + return pygame.mouse.get_pos() + + @staticmethod + def xPos(): + return Mouse.pos()[0] + + @staticmethod + def yPos(): + return Mouse.pos()[1] + + @staticmethod + def relativeMovement(): + "Returns how much the mouse has moved since the last call to this function" + return pygame.mouse.get_rel() + + @staticmethod + def setPos(x, y): + pygame.mouse.set_pos(x, y) + + @staticmethod + def setXPos(x): + pygame.mouse.set_pos(x, Mouse.yPos()) + + @staticmethod + def setYPos(y): + pygame.mouse.set_pos(Mouse.xPos(), y) + + @staticmethod + def isVisible(): + return Mouse._v + + @staticmethod + def setVisible(status): + Mouse._v = pygame.mouse.set_visible(status) + + @staticmethod + def isFocused(): + return bool(pygame.mouse.get_focused()) + +# Stage class +class Stage(): + def __init__(self): + self.snakey = pygame.image.load(os.path.join(os.path.dirname(__file__), "snakey.png")) + self.costumes = collections.OrderedDict({"costume0" : self.snakey}) + self.costumeNumber = 0 + self.costumeName = "costume0" + self.currentCostume = None + self.bgColor = (255, 255, 255) + + # Functions shared by sprites + def addCostume(self, costumePath, costumeName): + '''Add a costume based on a given path and name.''' + costume = pygame.image.load(os.path.join(scriptdir, costumePath)) + self.costumes[costumeName] = costume + self.costumeName = costumeName # Switch to the new costume + + def deleteCostumeByName(self, name): + '''Delete a costume by name.''' + self.costumes.pop(name, None) + self.recalculateNumberFromName(self.costumeName) # Make sure we recalculate the costume data! + + def deleteCostumeByNumber(self, number): + '''Delete a costume by number.''' + if number < len(self.costumes): + costumeName = self.costumes.keys()[number] + self.deleteCostumeByName(costumeName) # TODO: Fix this stupid "get name from number" thing + + @property + def costumeNumber(self): + '''The number of the costume the sprite is showing''' + return self._costumeNumber + + @costumeNumber.setter + def costumeNumber(self, val): + val = val % len(self.costumes) + self.costumeName = list(self.costumes.keys())[val] + self.currentCostume = self.costumes[self.costumeName] + self._costumeNumber = val + + @property + def costumeName(self): + '''The name of the costume the sprite is showing''' + return self._costumeName + + @costumeName.setter + def costumeName(self, val): + if val in self.costumes: + self._costumeName = val + self.currentCostume = self.costumes[self.costumeName] + + +slitherStage = Stage() + +# The Sprite inherits things such as the costumes from the stage so everything can be kept in one place. +class Sprite(Stage): + def __init__(self): + Stage.__init__(self) # Get all the stuff from the stage, too + self.currentCostume = self.snakey # By default we should be set to Snakey + self.xpos = 0 # X Position + self.ypos = 0 # Y Position + self.direction = 0 # Direction is how much to change the direction, hence why it starts at 0 and not 90 + self.show = True + self.scale = 1 # How much to multiply it by in the scale + self.zindex = 0 # How high up are we in the "z" axis? + sprites.append(self) # Add this sprite to the global list of sprites + + @property + def zindex(self): + '''The location of the sprite in the z-axis. Those with higher z-indexes are displayed above those with lower ones.''' + return self._zindex + + @zindex.setter + def zindex(self, val): + #if val < 0 or int(val) != val: + # raise ValueError("zindex must be a non-negative integer") + self._zindex = val + reorderSprites() + + def goto(self, xpos, ypos): + '''Go to xpos, ypos.''' + self.xpos = xpos + self.ypos = ypos + + def moveSteps(self, numSteps): + """Move numSteps steps in the current direction""" + self.goto(self.xpos + math.cos(math.radians(self.direction)) * numSteps, + self.ypos + math.sin(math.radians(self.direction)) * numSteps) + + def isVisible(self): + '''Check if the object is visible, not just showing. + This is better than Sprite.show because it also checks the scale.''' + return self.show and self.scale > 0 + + def delete(self): + '''Remove the sprite from the global sprites list, causing it not to be drawn.''' + sprites.remove(self) + + def isTouching(self, collideSprite): + '''Detects if one sprite is touching another.''' + ourRect = self.currentCostume.get_rect() + theirRect = collideSprite.currentCostume.get_rect() + ourRect.center = (self.xpos, self.ypos) + theirRect.center = (collideSprite.xpos, collideSprite.ypos) + return ourRect.colliderect(theirRect) + +pygame.mixer.init(44100, -16, 2, 2048) + +class Sound(): + # Based on pygame examples, http://stackoverflow.com/questions/8690301/pygame-memoryerror + def loadSound(self, name): + '''Load a sound. Set this function to a variable then call variable.play()''' + try: + pygame.mixer.get_init() + except: + pass + class NoneSound: + def play(self): pass + if not pygame.mixer: + return NoneSound() + fullname = os.path.join(scriptdir, name) + try: + sound = pygame.mixer.Sound(fullname) + except pygame.error as e: + print ('Cannot load sound: %s' % fullname) + raise e + return sound + +slitherSound = Sound() + +def setup(caption=sys.argv[0]): + '''Sets up PyGame and returns a screen object that can be used with blit().''' + global globalscreen + pygame.init() + screen = pygame.display.set_mode(SCREEN_SIZE) + caption = pygame.display.set_caption(caption) + globalscreen = screen + return screen + +projectFPS = 60 # 60 is the default +def setFPS(fps): + '''Set the FPS of the project. Default is 60, and Scratch runs at 30.''' + global projectFPS + projectFPS = fps # projectFPS is the FPS that the main loop uses + +def reorderSprites(): + global sprites + sprites = sorted(sprites, key=(lambda s: s.zindex)) + +def blit(screen): + '''Takes a screen as an argument and draws objects to the screen. THIS MUST BE CALLED FOR SLITHER TO DISPAY OBJECTS.''' + if screen: + screen.fill(slitherStage.bgColor) + + if slitherStage.currentCostume: + screen.blit(pygame.transform.scale(slitherStage.currentCostume, SCREEN_SIZE), (0, 0)) + + for obj in sprites: + if obj.isVisible(): # Check if the object is showing before we do anything + image = obj.currentCostume # So we can modify it and blit the modified version easily + # These next few blocks of code check if the object has the defaults before doing anything. + if not obj.scale == 1: + imageSize = image.get_size() + image = pygame.transform.scale(image, (int(imageSize[0] * obj.scale), int(imageSize[1] * obj.scale))) + if not obj.direction == 0: + image = rotateCenter(image, -obj.direction) + new_rect = image.get_rect() + new_rect.center = (obj.xpos, obj.ypos) + screen.blit(image, new_rect) + + pygame.display.flip() + +def registerCallback(eventname, func=None): + '''Register the function func to handle the event eventname''' + if func: + # Direct call (registerCallback(pygame.QUIT, func)) + eventCallbacks[eventname] = func + else: + # Decorator call (@registerCallback(pygame.QUIT) + # def f(): pass + def f(func): + eventCallbacks[eventname] = func + return f + +def runQuitCallback(): + return eventCallbacks[pygame.QUIT]() + +def runMainLoop(frameFunc): + while True: + blit(globalscreen) + frameFunc() + for event in pygame.event.get(): + if event.type == pygame.QUIT: + if runQuitCallback(): + # runQuitCallback would run the function + # given to setQuitCallback, and return its result + pygame.quit() + sys.exit() + else: + if event.type == pygame.KEYDOWN: + keysPressed.append(pygame.key.name(event.key)) + elif event.type == pygame.KEYUP: + keysPressed.remove(pygame.key.name(event.key)) + eventCallbacks[event.type](event) + # eventCallbacks would be a dictionary mapping + # event types to handler functions. + clock.tick(projectFPS) # Run at however many FPS the user specifies From 8d5362f3f74f03164441a359c37a8f95e1268d68 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:12:53 -0400 Subject: [PATCH 02/29] Remove code move it to slither.py --- slither/__init__.py | 317 +------------------------------------------- 1 file changed, 1 insertion(+), 316 deletions(-) diff --git a/slither/__init__.py b/slither/__init__.py index 1126cb5..51ca2b5 100644 --- a/slither/__init__.py +++ b/slither/__init__.py @@ -1,316 +1 @@ -# SLITHER FOR PYTHON 2 AND 3 -# Hi there, code divers! -# There's a lot of cool stuff here that has comments so you can understand what's going on. -# You can even mess around with it yourself :) -# If you think your messing around might help, go to: -# https://github.com/PySlither/Slither -# and make a pull request! - -import pygame -import sys, os, collections, warnings, math - -WIDTH, HEIGHT = (800, 600) -SCREEN_SIZE = (WIDTH, HEIGHT) - -sprites = [] # List of all sprites -clock = pygame.time.Clock() # Used to control framerate -eventnames = ['QUIT', 'ACTIVEEVENT', 'KEYDOWN', 'KEYUP', 'MOUSEMOTION', 'MOUSEBUTTONUP', 'MOUSEBUTTONDOWN', - 'JOYAXISMOTION', 'JOYBALLMOTION', 'JOYHATMOTION', 'JOYBUTTONUP', 'JOYBUTTONDOWN', - 'VIDEORESIZE', 'VIDEOEXPOSE', 'USEREVENT'] -eventCallbacks = { - getattr(pygame, name): lambda e=None: True - for name in eventnames - } # Create a dict of callbacks that do nothing -globalscreen = None - -keysPressed = [] - -try: - scriptdir = os.path.dirname(os.path.realpath(__import__("__main__").__file__)) -except AttributeError: - warnings.warn("Couldn't find scripts dir, some functions may not work.") - scriptdir = os.path.realpath(".") - - -def keysDown(): - "returns the keys that are currently pressed" - return keysPressed[:] - -# Convienience functions -# Taken from http://stackoverflow.com/questions/4183208/how-do-i-rotate-an-image-around-its-center-using-pygame -def rotateCenter(image, angle): - '''rotate a Surface, maintaining position.''' - rot_sprite = pygame.transform.rotate(image, angle) - return rot_sprite - -class Mouse: - """A class for getting and setting mouse properties - This is a static class, all functions should be called directly through the class""" - _v = True - - @staticmethod - def buttonsPressed(): - """Returns a three-tuple of bools that gives the state - of the left, middle, and right buttons""" - return tuple(bool(state) for state in pygame.mouse.get_pressed()) - - @staticmethod - def leftPressed(): - return Mouse.buttonsPressed()[0] - - @staticmethod - def middlePressed(): - return Mouse.buttonsPressed()[1] - - @staticmethod - def rightPressed(): - return Mouse.buttonsPressed()[2] - - @staticmethod - def pos(): - return pygame.mouse.get_pos() - - @staticmethod - def xPos(): - return Mouse.pos()[0] - - @staticmethod - def yPos(): - return Mouse.pos()[1] - - @staticmethod - def relativeMovement(): - "Returns how much the mouse has moved since the last call to this function" - return pygame.mouse.get_rel() - - @staticmethod - def setPos(x, y): - pygame.mouse.set_pos(x, y) - - @staticmethod - def setXPos(x): - pygame.mouse.set_pos(x, Mouse.yPos()) - - @staticmethod - def setYPos(y): - pygame.mouse.set_pos(Mouse.xPos(), y) - - @staticmethod - def isVisible(): - return Mouse._v - - @staticmethod - def setVisible(status): - Mouse._v = pygame.mouse.set_visible(status) - - @staticmethod - def isFocused(): - return bool(pygame.mouse.get_focused()) - -# Stage class -class Stage(): - def __init__(self): - self.snakey = pygame.image.load(os.path.join(os.path.dirname(__file__), "snakey.png")) - self.costumes = collections.OrderedDict({"costume0" : self.snakey}) - self.costumeNumber = 0 - self.costumeName = "costume0" - self.currentCostume = None - self.bgColor = (255, 255, 255) - - # Functions shared by sprites - def addCostume(self, costumePath, costumeName): - '''Add a costume based on a given path and name.''' - costume = pygame.image.load(os.path.join(scriptdir, costumePath)) - self.costumes[costumeName] = costume - self.costumeName = costumeName # Switch to the new costume - - def deleteCostumeByName(self, name): - '''Delete a costume by name.''' - self.costumes.pop(name, None) - self.recalculateNumberFromName(self.costumeName) # Make sure we recalculate the costume data! - - def deleteCostumeByNumber(self, number): - '''Delete a costume by number.''' - if number < len(self.costumes): - costumeName = self.costumes.keys()[number] - self.deleteCostumeByName(costumeName) # TODO: Fix this stupid "get name from number" thing - - @property - def costumeNumber(self): - '''The number of the costume the sprite is showing''' - return self._costumeNumber - - @costumeNumber.setter - def costumeNumber(self, val): - val = val % len(self.costumes) - self.costumeName = list(self.costumes.keys())[val] - self.currentCostume = self.costumes[self.costumeName] - self._costumeNumber = val - - @property - def costumeName(self): - '''The name of the costume the sprite is showing''' - return self._costumeName - - @costumeName.setter - def costumeName(self, val): - if val in self.costumes: - self._costumeName = val - self.currentCostume = self.costumes[self.costumeName] - - -slitherStage = Stage() - -# The Sprite inherits things such as the costumes from the stage so everything can be kept in one place. -class Sprite(Stage): - def __init__(self): - Stage.__init__(self) # Get all the stuff from the stage, too - self.currentCostume = self.snakey # By default we should be set to Snakey - self.xpos = 0 # X Position - self.ypos = 0 # Y Position - self.direction = 0 # Direction is how much to change the direction, hence why it starts at 0 and not 90 - self.show = True - self.scale = 1 # How much to multiply it by in the scale - self.zindex = 0 # How high up are we in the "z" axis? - sprites.append(self) # Add this sprite to the global list of sprites - - @property - def zindex(self): - '''The location of the sprite in the z-axis. Those with higher z-indexes are displayed above those with lower ones.''' - return self._zindex - - @zindex.setter - def zindex(self, val): - #if val < 0 or int(val) != val: - # raise ValueError("zindex must be a non-negative integer") - self._zindex = val - reorderSprites() - - def goto(self, xpos, ypos): - '''Go to xpos, ypos.''' - self.xpos = xpos - self.ypos = ypos - - def moveSteps(self, numSteps): - """Move numSteps steps in the current direction""" - self.goto(self.xpos + math.cos(math.radians(self.direction)) * numSteps, - self.ypos + math.sin(math.radians(self.direction)) * numSteps) - - def isVisible(self): - '''Check if the object is visible, not just showing. - This is better than Sprite.show because it also checks the scale.''' - return self.show and self.scale > 0 - - def delete(self): - '''Remove the sprite from the global sprites list, causing it not to be drawn.''' - sprites.remove(self) - - def isTouching(self, collideSprite): - '''Detects if one sprite is touching another.''' - ourRect = self.currentCostume.get_rect() - theirRect = collideSprite.currentCostume.get_rect() - ourRect.center = (self.xpos, self.ypos) - theirRect.center = (collideSprite.xpos, collideSprite.ypos) - return ourRect.colliderect(theirRect) - -pygame.mixer.init(44100, -16, 2, 2048) - -class Sound(): - # Based on pygame examples, http://stackoverflow.com/questions/8690301/pygame-memoryerror - def loadSound(self, name): - '''Load a sound. Set this function to a variable then call variable.play()''' - try: - pygame.mixer.get_init() - except: - pass - class NoneSound: - def play(self): pass - if not pygame.mixer: - return NoneSound() - fullname = os.path.join(scriptdir, name) - try: - sound = pygame.mixer.Sound(fullname) - except pygame.error as e: - print ('Cannot load sound: %s' % fullname) - raise e - return sound - -slitherSound = Sound() - -def setup(caption=sys.argv[0]): - '''Sets up PyGame and returns a screen object that can be used with blit().''' - global globalscreen - pygame.init() - screen = pygame.display.set_mode(SCREEN_SIZE) - caption = pygame.display.set_caption(caption) - globalscreen = screen - return screen - -projectFPS = 60 # 60 is the default -def setFPS(fps): - '''Set the FPS of the project. Default is 60, and Scratch runs at 30.''' - global projectFPS - projectFPS = fps # projectFPS is the FPS that the main loop uses - -def reorderSprites(): - global sprites - sprites = sorted(sprites, key=(lambda s: s.zindex)) - -def blit(screen): - '''Takes a screen as an argument and draws objects to the screen. THIS MUST BE CALLED FOR SLITHER TO DISPAY OBJECTS.''' - if screen: - screen.fill(slitherStage.bgColor) - - if slitherStage.currentCostume: - screen.blit(pygame.transform.scale(slitherStage.currentCostume, SCREEN_SIZE), (0, 0)) - - for obj in sprites: - if obj.isVisible(): # Check if the object is showing before we do anything - image = obj.currentCostume # So we can modify it and blit the modified version easily - # These next few blocks of code check if the object has the defaults before doing anything. - if not obj.scale == 1: - imageSize = image.get_size() - image = pygame.transform.scale(image, (int(imageSize[0] * obj.scale), int(imageSize[1] * obj.scale))) - if not obj.direction == 0: - image = rotateCenter(image, -obj.direction) - new_rect = image.get_rect() - new_rect.center = (obj.xpos, obj.ypos) - screen.blit(image, new_rect) - - pygame.display.flip() - -def registerCallback(eventname, func=None): - '''Register the function func to handle the event eventname''' - if func: - # Direct call (registerCallback(pygame.QUIT, func)) - eventCallbacks[eventname] = func - else: - # Decorator call (@registerCallback(pygame.QUIT) - # def f(): pass - def f(func): - eventCallbacks[eventname] = func - return f - -def runQuitCallback(): - return eventCallbacks[pygame.QUIT]() - -def runMainLoop(frameFunc): - while True: - blit(globalscreen) - frameFunc() - for event in pygame.event.get(): - if event.type == pygame.QUIT: - if runQuitCallback(): - # runQuitCallback would run the function - # given to setQuitCallback, and return its result - pygame.quit() - sys.exit() - else: - if event.type == pygame.KEYDOWN: - keysPressed.append(pygame.key.name(event.key)) - elif event.type == pygame.KEYUP: - keysPressed.remove(pygame.key.name(event.key)) - eventCallbacks[event.type](event) - # eventCallbacks would be a dictionary mapping - # event types to handler functions. - clock.tick(projectFPS) # Run at however many FPS the user specifies +__all__ = ['slither'] From 51c04d022657aa3784c52f2c1092099709760d25 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:13:45 -0400 Subject: [PATCH 03/29] Update mover.py --- slither/examples/mover.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slither/examples/mover.py b/slither/examples/mover.py index 57b25a5..1d85726 100644 --- a/slither/examples/mover.py +++ b/slither/examples/mover.py @@ -1,5 +1,6 @@ # mover.py -import slither, pygame # We need pygame for the event constants and the key functions +import pygame # We need pygame for the event constants and the key functions +from slither import * from pygame.locals import * sprite = slither.Sprite() From 7c32f4c9504c1cbab855f5ac34d7e38851f22f17 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:14:06 -0400 Subject: [PATCH 04/29] Update turnAndMove.py --- slither/examples/turnAndMove.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/examples/turnAndMove.py b/slither/examples/turnAndMove.py index af22db6..7de9305 100644 --- a/slither/examples/turnAndMove.py +++ b/slither/examples/turnAndMove.py @@ -1,4 +1,4 @@ -import slither +from slither import * snakey = slither.Sprite() snakey.costumeName = "costume0" From 7d4ac07340440f8cb7294740664d416588f8e903 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:14:27 -0400 Subject: [PATCH 05/29] Update basicTest.py --- slither/tests/basicTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/basicTest.py b/slither/tests/basicTest.py index fb523b8..39f1536 100644 --- a/slither/tests/basicTest.py +++ b/slither/tests/basicTest.py @@ -1,4 +1,4 @@ -import slither +from slither import * snakey = slither.Sprite() snakey.costumeName = "costume0" # You can set the default costume (costume0) by name... From 5da09244cb9f00b2a3b77c73537a5305743f0413 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:14:56 -0400 Subject: [PATCH 06/29] Update bgTest.py --- slither/tests/bgTest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slither/tests/bgTest.py b/slither/tests/bgTest.py index 83e862c..4cb91b4 100644 --- a/slither/tests/bgTest.py +++ b/slither/tests/bgTest.py @@ -1,4 +1,5 @@ -import slither, math +import math +from slither import * snakey = slither.Sprite() snakey.ypos = 460 From a5fc2c9e9ad3ee92f147ecdac403a802644d8554 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:15:13 -0400 Subject: [PATCH 07/29] Update imageBounceTest.py --- slither/tests/imageBounceTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/imageBounceTest.py b/slither/tests/imageBounceTest.py index 7f1a36f..b5d4115 100644 --- a/slither/tests/imageBounceTest.py +++ b/slither/tests/imageBounceTest.py @@ -1,4 +1,4 @@ -import slither +from slither import * def create_circle(): circle = slither.Sprite() From a9e14dc950f6071c9dcaf293adb465db9887bec8 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:15:30 -0400 Subject: [PATCH 08/29] Update isTouchingTest.py --- slither/tests/isTouchingTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/isTouchingTest.py b/slither/tests/isTouchingTest.py index 5bdc81a..edb9173 100644 --- a/slither/tests/isTouchingTest.py +++ b/slither/tests/isTouchingTest.py @@ -1,5 +1,5 @@ # isTouchingTest.py -import slither +from slither import * toucher = slither.Sprite() toucher.addCostume("assets/arrow.png", "arrow") From 79512df62378cdf5f5f4acbbbce0f3d99201e72d Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:15:48 -0400 Subject: [PATCH 09/29] Update keysDownTest.py --- slither/tests/keysDownTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/keysDownTest.py b/slither/tests/keysDownTest.py index f4a5721..3966a90 100644 --- a/slither/tests/keysDownTest.py +++ b/slither/tests/keysDownTest.py @@ -1,7 +1,7 @@ # usr/bin/env python3 # keysDownTest.py - Test slither.keysDown() -import slither +from slither import * def run_a_frame(): print(slither.keysDown()) From ceefddae272f78f112c161979a9702c2737e7f49 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:16:09 -0400 Subject: [PATCH 10/29] Update mouseTest.py --- slither/tests/mouseTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/mouseTest.py b/slither/tests/mouseTest.py index cd74aec..51e0ff7 100644 --- a/slither/tests/mouseTest.py +++ b/slither/tests/mouseTest.py @@ -1,7 +1,7 @@ # usr/bin/env python3 # mouseTest.py -import slither +from slither import * from slither import Mouse def run_a_frame(): From 442e894e928db06eecb25266b7a022c413a0452c Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:16:31 -0400 Subject: [PATCH 11/29] Update mouseTest.py --- slither/tests/mouseTest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/slither/tests/mouseTest.py b/slither/tests/mouseTest.py index 51e0ff7..4f342e6 100644 --- a/slither/tests/mouseTest.py +++ b/slither/tests/mouseTest.py @@ -2,7 +2,6 @@ # mouseTest.py from slither import * -from slither import Mouse def run_a_frame(): print(Mouse.buttonsPressed()) From bf712ffc63ca6dcdf63be8a56d7b0a1a751c50cf Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:16:45 -0400 Subject: [PATCH 12/29] Update moveStepsTest.py --- slither/tests/moveStepsTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/moveStepsTest.py b/slither/tests/moveStepsTest.py index e5de8af..cd1da9c 100644 --- a/slither/tests/moveStepsTest.py +++ b/slither/tests/moveStepsTest.py @@ -1,5 +1,5 @@ # moveStepsTest.py -import slither +from slither import * sprite = slither.Sprite() sprite.addCostume("assets/arrow.png", "arrow") From 6a9e4e5a05f91f7f9763b69bf57a574d710a5ccf Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:17:02 -0400 Subject: [PATCH 13/29] Update soundtest.py --- slither/tests/soundtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/soundtest.py b/slither/tests/soundtest.py index 8485f92..d8812ab 100644 --- a/slither/tests/soundtest.py +++ b/slither/tests/soundtest.py @@ -1,5 +1,5 @@ # Sound works, make sure your volume is up. -import slither +from slither import * sound = slither.slitherSound.loadSound('assets/boom.wav') sound.play() From 3056321e35e756add27a01b3b4755b67f9625fdd Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:17:18 -0400 Subject: [PATCH 14/29] Update zindextest.py --- slither/tests/zindextest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/zindextest.py b/slither/tests/zindextest.py index 7cf08f6..0f18892 100644 --- a/slither/tests/zindextest.py +++ b/slither/tests/zindextest.py @@ -1,4 +1,4 @@ -import slither +from slither import * # Normally, since Snakey was made before SoExcited, SoExcited would be rendered after Snakey and be put on top. snakey = slither.Sprite() From f01a3c894537f23e7b9552b3fd416b2714325cd6 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Fri, 3 Jun 2016 17:19:14 -0400 Subject: [PATCH 15/29] Update __init__.py --- slither/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/__init__.py b/slither/__init__.py index 51ca2b5..f66f8a5 100644 --- a/slither/__init__.py +++ b/slither/__init__.py @@ -1 +1 @@ -__all__ = ['slither'] +__all__ = ['slither','Mouse','Stage','Sprite','Sound'] From e44ffd0c1b7bff9b135c8e221f23ce191de9e620 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Sun, 5 Jun 2016 11:37:28 -0400 Subject: [PATCH 16/29] Update __init__.py --- slither/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slither/__init__.py b/slither/__init__.py index f66f8a5..9f4bc5a 100644 --- a/slither/__init__.py +++ b/slither/__init__.py @@ -1 +1,3 @@ +from slither import slither + __all__ = ['slither','Mouse','Stage','Sprite','Sound'] From badbf8c89216b97ac29ea3582d99d28535f82a7e Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Sun, 5 Jun 2016 13:49:32 -0400 Subject: [PATCH 17/29] Update __init__.py --- slither/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/__init__.py b/slither/__init__.py index 9f4bc5a..c0f3907 100644 --- a/slither/__init__.py +++ b/slither/__init__.py @@ -1,3 +1,3 @@ -from slither import slither +from . import slither __all__ = ['slither','Mouse','Stage','Sprite','Sound'] From 2d9ac69cba426d9f83eb53bfb3852de0394d9b94 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Mon, 6 Jun 2016 19:16:15 -0400 Subject: [PATCH 18/29] Update __init__.py --- slither/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/__init__.py b/slither/__init__.py index c0f3907..2b383de 100644 --- a/slither/__init__.py +++ b/slither/__init__.py @@ -1,3 +1,3 @@ -from . import slither +from .slither import * __all__ = ['slither','Mouse','Stage','Sprite','Sound'] From 074da495bf65b7ac7dda4d0e765897ec157caf70 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:19:25 -0400 Subject: [PATCH 19/29] Update mover.py --- slither/examples/mover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/examples/mover.py b/slither/examples/mover.py index 1d85726..a70770f 100644 --- a/slither/examples/mover.py +++ b/slither/examples/mover.py @@ -1,6 +1,6 @@ # mover.py import pygame # We need pygame for the event constants and the key functions -from slither import * +import slither from pygame.locals import * sprite = slither.Sprite() From 092dbf2ed932149989287344d8583eb87cd375a2 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:19:51 -0400 Subject: [PATCH 20/29] Update turnAndMove.py --- slither/examples/turnAndMove.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/examples/turnAndMove.py b/slither/examples/turnAndMove.py index 7de9305..af22db6 100644 --- a/slither/examples/turnAndMove.py +++ b/slither/examples/turnAndMove.py @@ -1,4 +1,4 @@ -from slither import * +import slither snakey = slither.Sprite() snakey.costumeName = "costume0" From 9f40a31a917d228ed980b5e00a08eb4d2b6747bc Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:20:23 -0400 Subject: [PATCH 21/29] Update basicTest.py --- slither/tests/basicTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/basicTest.py b/slither/tests/basicTest.py index 39f1536..fb523b8 100644 --- a/slither/tests/basicTest.py +++ b/slither/tests/basicTest.py @@ -1,4 +1,4 @@ -from slither import * +import slither snakey = slither.Sprite() snakey.costumeName = "costume0" # You can set the default costume (costume0) by name... From 0c2939c4357aa1314eaf38e56b7a1d5bd13f447c Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:20:50 -0400 Subject: [PATCH 22/29] Update bgTest.py --- slither/tests/bgTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/bgTest.py b/slither/tests/bgTest.py index 4cb91b4..4c3e705 100644 --- a/slither/tests/bgTest.py +++ b/slither/tests/bgTest.py @@ -1,5 +1,5 @@ import math -from slither import * +import slither snakey = slither.Sprite() snakey.ypos = 460 From 4caed1764375a17f5de467db224baff6b5439c89 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:21:10 -0400 Subject: [PATCH 23/29] Update isTouchingTest.py --- slither/tests/isTouchingTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/isTouchingTest.py b/slither/tests/isTouchingTest.py index edb9173..5bdc81a 100644 --- a/slither/tests/isTouchingTest.py +++ b/slither/tests/isTouchingTest.py @@ -1,5 +1,5 @@ # isTouchingTest.py -from slither import * +import slither toucher = slither.Sprite() toucher.addCostume("assets/arrow.png", "arrow") From 80d85cf16586979eed8f45c9001ce6e96dece770 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:21:37 -0400 Subject: [PATCH 24/29] Update mouseTest.py --- slither/tests/mouseTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/mouseTest.py b/slither/tests/mouseTest.py index 4f342e6..86f3937 100644 --- a/slither/tests/mouseTest.py +++ b/slither/tests/mouseTest.py @@ -1,7 +1,7 @@ # usr/bin/env python3 # mouseTest.py -from slither import * +import slither def run_a_frame(): print(Mouse.buttonsPressed()) From 58a02fc49b84212bf83430ed83748aafa123fc98 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:22:00 -0400 Subject: [PATCH 25/29] Update moveStepsTest.py --- slither/tests/moveStepsTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/moveStepsTest.py b/slither/tests/moveStepsTest.py index cd1da9c..e5de8af 100644 --- a/slither/tests/moveStepsTest.py +++ b/slither/tests/moveStepsTest.py @@ -1,5 +1,5 @@ # moveStepsTest.py -from slither import * +import slither sprite = slither.Sprite() sprite.addCostume("assets/arrow.png", "arrow") From da0cbbccf4a0afdfefda388c3dcbdc672153e098 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:22:25 -0400 Subject: [PATCH 26/29] Update zindextest.py --- slither/tests/zindextest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/zindextest.py b/slither/tests/zindextest.py index 0f18892..7cf08f6 100644 --- a/slither/tests/zindextest.py +++ b/slither/tests/zindextest.py @@ -1,4 +1,4 @@ -from slither import * +import slither # Normally, since Snakey was made before SoExcited, SoExcited would be rendered after Snakey and be put on top. snakey = slither.Sprite() From c10381da5d7fd36e8162506bf0c3584367053c36 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:22:37 -0400 Subject: [PATCH 27/29] Update soundtest.py --- slither/tests/soundtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/soundtest.py b/slither/tests/soundtest.py index d8812ab..8485f92 100644 --- a/slither/tests/soundtest.py +++ b/slither/tests/soundtest.py @@ -1,5 +1,5 @@ # Sound works, make sure your volume is up. -from slither import * +import slither sound = slither.slitherSound.loadSound('assets/boom.wav') sound.play() From 0db1e1a95a6b514a2b91d82a7e56ffb0daeb17f4 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:23:26 -0400 Subject: [PATCH 28/29] Update keysDownTest.py --- slither/tests/keysDownTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/keysDownTest.py b/slither/tests/keysDownTest.py index 3966a90..f4a5721 100644 --- a/slither/tests/keysDownTest.py +++ b/slither/tests/keysDownTest.py @@ -1,7 +1,7 @@ # usr/bin/env python3 # keysDownTest.py - Test slither.keysDown() -from slither import * +import slither def run_a_frame(): print(slither.keysDown()) From 34be0286ebc1a428e95fbb27adadf9b4cd626929 Mon Sep 17 00:00:00 2001 From: Cosmic Web Services Date: Thu, 9 Jun 2016 21:23:36 -0400 Subject: [PATCH 29/29] Update imageBounceTest.py --- slither/tests/imageBounceTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tests/imageBounceTest.py b/slither/tests/imageBounceTest.py index b5d4115..7f1a36f 100644 --- a/slither/tests/imageBounceTest.py +++ b/slither/tests/imageBounceTest.py @@ -1,4 +1,4 @@ -from slither import * +import slither def create_circle(): circle = slither.Sprite()