Skip to content

Commit

Permalink
- Added experimental pgzero repository
Browse files Browse the repository at this point in the history
- Added an alternative method to run pgzero
-- Add runpgzero.py as a wrapper to the wrapper
- Added pgzero banner
  • Loading branch information
SteveClement committed Dec 12, 2016
1 parent f86ae5f commit 53a33cd
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
67 changes: 67 additions & 0 deletions 020_AlternativeRunnerFor_019.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This line imports the local module runpgzero.py in the current directory
from runpgzero import *
# Import our color module, this time we do not need to catch the exception
# because we invoke our script directly with the python3 command. This also
# means it is executable via a GUI
from colors import *

# Define our 800x600 screen
WIDTH = 800
HEIGHT = 600

# This will literally put a rectangle with certain properties into the variable BOX
BOX1 = Rect((0,0), (0,0))
BOX2 = Rect((20,20), (100,100))

# As we know, we need the draw function to put stuff on the screen
def draw():
# What if we do not clear the screen?
screen.clear()

# Needs to be define before we use growMin and growMax
mouseFont = fontNormalized(mousePos[1])

# We simply draw, to the screen, the variable BOX with the color in RED
screen.draw.rect(BOX1, RED)
screen.draw.rect(BOX2, BLUE)

# 2 Lines to show when we stop growing our font
screen.draw.line((0,growMin), (WIDTH, growMin),(GREEN),3)
screen.draw.line((0,growMax), (WIDTH, growMax),(GREEN10),3)

# Draw some text on the screen to give an idea where our mouse is at
screen.draw.text(
'mouseX: {0} mouseY: {1}'.format(mousePos[0], mousePos[1]),
center=((WIDTH/2), 20),
fontsize=48,
color=YELLOW,
)

screen.draw.text(
'{}'.format(mousePos),
center=mousePos,
fontsize=mouseFont,
color=PINK,
)

def on_mouse_move(pos):
global mousePos
x, y = pos
BOX1.size = (x, y)
BOX2.center = (x, y)
mousePos = pos

def fontNormalized(posY):
global growMin
global growMax
growMin = 40
growMax = 100

if posY < growMin:
return growMin
elif posY > growMax:
return growMax
else:
return posY

run_pgzero()
Binary file added images/pygame_logo_zero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
emoji
numpy
pgzero
hg+http://bitbucket.org/pygame/pygame
hg+http://bitbucket.org/SteveClement/pgzero
21 changes: 21 additions & 0 deletions runpgzero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Expose pgzero objects as a builtins
from pgzero.builtins import *
from pgzero.runner import *
import pgzero.screen


def run_pgzero():
pygame.init()
PGZeroGame(sys.modules['__main__']).run()
pygame.quit()


# Pygame won't run from a normal virtualenv copy of Python on a Mac
##if not check_python_ok_for_pygame():
## substitute_full_framework_python()
if __debug__:
warnings.simplefilter('default', DeprecationWarning)
path = sys.argv[0]
loaders.set_root(path)

screen= pgzero.screen.Screen(pygame.display.set_mode((1, 1), DISPLAY_FLAGS))

0 comments on commit 53a33cd

Please sign in to comment.