From 8953dcc49b949e5ae3c79cfd49b9c3ff21e164ca Mon Sep 17 00:00:00 2001 From: Dinko Galetic Date: Thu, 10 Jun 2010 09:36:28 +0000 Subject: Set pygame screen to match gtk.gdk.screen_width/height(). Text boxes are now positioned relative to screen size. --- (limited to 'data') diff --git a/data/GSOC examples/Koch snowflake b/data/GSOC examples/Koch snowflake index 2fb218e..00159bd 100644 --- a/data/GSOC examples/Koch snowflake +++ b/data/GSOC examples/Koch snowflake @@ -3,13 +3,14 @@ import pippy, pygame, sys from pygame.locals import * from random import * -import math - +import math +import gtk + # always need to init first thing pygame.init() # XO screen is 1200x900 -size = width, height = 1200, 900 +size = width, height = gtk.gdk.screen_width(), gtk.gdk.screen_height() # create the window and keep track of the surface # for drawing into @@ -169,8 +170,8 @@ font = pygame.font.Font(None, font_size) text = font.render(use, True, font_colour) text_box = text.get_rect() # Where the box will be placed. -text_box.top = 100 -text_box.left = 50 +text_box.top = height / 15 + 30 +text_box.left = width / 30 lines = starting_lines @@ -196,8 +197,8 @@ while pippy.pygame.next_frame(): msg = "Step: " + str(depth) + "/6" text2 = font.render(msg , True, font_colour) text_box2 = text2.get_rect() - text_box2.top = 130 - text_box2.left = 50 + text_box2.top = height / 15 + text_box2.left = width / 30 # Write the instructions and the current step on the screen. screen.blit(text, text_box) screen.blit(text2, text_box2) diff --git a/data/GSOC examples/Sierpinski - graphics b/data/GSOC examples/Sierpinski - graphics index 449277a..f61111a 100644 --- a/data/GSOC examples/Sierpinski - graphics +++ b/data/GSOC examples/Sierpinski - graphics @@ -15,6 +15,7 @@ import pippy, pygame, sys from pygame.locals import * from math import sin, cos from math import pi as Pi +import gtk class Triangle(object): def __init__(self, first_vertex, length, displacement_angle = 0 ): @@ -57,7 +58,7 @@ class Triangle(object): pygame.init() # XO screen is 1200x900 -size = width, height = 1200, 800 +size = width, height = gtk.gdk.screen_width(), gtk.gdk.screen_height() # create the window and keep track of the surface # for drawing into @@ -70,11 +71,12 @@ font = pygame.font.Font(None, font_size) black = (0, 0, 0) white = (255, 255, 255) +# Practice: Could you make this depend on the current resolution? +# (hint: variables "height" and "width" could help) starting_point = (200, 750) side_length = 800 t1 = Triangle(starting_point, side_length) -t2 = Triangle((800, 600), 150) depth = 0 @@ -106,13 +108,13 @@ while pippy.pygame.next_frame(): msg = "Step: " + str(depth) + "/8" text = font.render(msg , True, black) text_box = text.get_rect() - text_box.top = 130 - text_box.left = 50 + text_box.top = height / 10 + text_box.left = width / 20 # Display the instructions text2 = font.render("Use left and right arrows.", True, black) text_box2 = text2.get_rect() - text_box2.top = 100 - text_box2.left = 50 + text_box2.top = height / 10 - 30 + text_box2.left = width / 20 # Write the instructions and the current step on the screen. screen.blit(text, text_box) screen.blit(text2, text_box2) diff --git a/data/GSOC examples/rotate polygon b/data/GSOC examples/rotate polygon index fdf1a37..5bd2dcc 100644 --- a/data/GSOC examples/rotate polygon +++ b/data/GSOC examples/rotate polygon @@ -16,12 +16,13 @@ from pygame.locals import * from random import * from math import cos, sin from math import pi as Pi +import gtk # always need to init first thing pygame.init() # XO screen is 1200x900 -size = width, height = 1200, 800 +size = width, height = gtk.gdk.screen_width(), gtk.gdk.screen_height() # create the window and keep track of the surface # for drawing into @@ -152,10 +153,10 @@ while pippy.pygame.next_frame(): msg2 = "Use up and down arrows for controling size. Size : " + str(side_length) text1 = font.render(msg , True, font_colour) text_box1 = text1.get_rect() - text_box1.top = 5 + text_box1.top = height / 20 text2 = font.render(msg2 , True, font_colour) text_box2 = text2.get_rect() - text_box2.top = 20 + text_box2.top = height / 20 + 14 # if the L or R arrow is pressed (and held), keep adjusting speed # You'll have to click it real fast if you with to change the speed by -- cgit v0.9.1