This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pygame | ||
import screen | ||
img = pygame.image.load("mr_brown.png") | ||
|
||
screen = screen.get_screen() | ||
|
||
i=0 | ||
|
||
def goldencut (base): | ||
return base * 0.382 | ||
|
||
def middle (base): | ||
return round (base * 0.5, 0) | ||
|
||
while True: | ||
events = pygame.event.get() | ||
mouse_pos = pygame.mouse.get_pos() | ||
|
||
screen.fill( (246, 198, 0) ) # fill screen with an rgb color | ||
|
||
screen.blit( | ||
img, | ||
(middle(480)-20, goldencut(800)-20) | ||
) | ||
|
||
for event in events: | ||
print event | ||
if event.type == pygame.MOUSEBUTTONDOWN: | ||
if pygame.Rect( | ||
(middle(480)-20, goldencut(800)-20), | ||
(40, 40) | ||
).collidepoint(mouse_pos): #funktioniert noch nicht, muss verschoben werden | ||
print "Hey you tickled the shit!" | ||
|
||
pygame.display.flip() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pygame | ||
|
||
def get_screen(): | ||
try: | ||
screen = __get_screen_framebuffer() | ||
except: | ||
screen = __get_screen_xserver() | ||
|
||
return screen | ||
|
||
def __get_screen_xserver(): | ||
SIZE = 480, 800 | ||
pygame.init() | ||
screen = pygame.display.set_mode(SIZE) | ||
return screen | ||
|
||
def __get_screen_framebuffer(): | ||
"Ininitializes a new pygame screen using the framebuffer" | ||
# Based on "Python GUI in Linux frame buffer" | ||
# http://www.karoltomala.com/blog/?p=679 | ||
disp_no = os.getenv("DISPLAY") | ||
if disp_no: | ||
print "I'm running under X display = {0}".format(disp_no) | ||
|
||
# Check which frame buffer drivers are available | ||
# Start with fbcon since directfb hangs with composite output | ||
drivers = ['fbcon', 'directfb', 'svgalib'] | ||
found = False | ||
for driver in drivers: | ||
# Make sure that SDL_VIDEODRIVER is set | ||
if not os.getenv('SDL_VIDEODRIVER'): | ||
os.putenv('SDL_VIDEODRIVER', driver) | ||
try: | ||
pygame.display.init() | ||
except pygame.error: | ||
print 'Driver: {0} failed.'.format(driver) | ||
continue | ||
found = True | ||
break | ||
|
||
if not found: | ||
raise Exception('No suitable video driver found!') | ||
|
||
size = (pygame.display.Info().current_w, pygame.display.Info().current_h) | ||
print "Framebuffer size: %d x %d" % (size[0], size[1]) | ||
return pygame.display.set_mode(size, pygame.FULLSCREEN) | ||
# Clear the screen to start | ||
self.screen.fill((0, 0, 0)) | ||
# Initialise font support | ||
pygame.font.init() | ||
# Render the screen | ||
pygame.display.update() |