コード例 #1
0
ファイル: renderer.py プロジェクト: lmcneill42/space_game
 def rect_to_screen(self, rect, coords):
     """ Convert a rectangle into screen coordinates. """
     if coords == Renderer.COORDS_SCREEN:
         return rect
     else:
         tl = self.world_to_screen(rect.topleft)
         br = self.world_to_screen(rect.bottomright)
         ret = Rect()
         ret.topleft = tl
         ret.bottomright = br
         return ret
コード例 #2
0
ファイル: rect_test.py プロジェクト: annie60/Xilarius
    def test_bottomright(self):
        """Changing the bottomright attribute moves the rect and does not change
           the rect's size
        """
        r = Rect(1, 2, 3, 4)
        new_bottomright = (r.right + 20, r.bottom + 30)
        expected_topleft = (r.left + 20, r.top + 30)
        old_size = r.size

        r.bottomright = new_bottomright
        self.assertEqual(new_bottomright, r.bottomright)
        self.assertEqual(expected_topleft, r.topleft)
        self.assertEqual(old_size, r.size)
コード例 #3
0
ファイル: rect_test.py プロジェクト: CTPUG/pygame_cffi
 def test_bottomright( self ):
     """Changing the bottomright attribute moves the rect and does not change
        the rect's size
     """
     r = Rect( 1, 2, 3, 4 )
     new_bottomright = (r.right+20,r.bottom+30)
     expected_topleft = (r.left+20,r.top+30)
     old_size = r.size
     
     r.bottomright = new_bottomright
     self.assertEqual( new_bottomright, r.bottomright )
     self.assertEqual( expected_topleft, r.topleft )
     self.assertEqual( old_size, r.size )
コード例 #4
0
ファイル: constants.py プロジェクト: thomasdelrue/1GAM
MOVESPEED = 500. # for the ship moving sideways

BOLTLENGTH = SHIPSIZE // 2
BOLTWIDTH = 3
BOLTSPEED = 500. # pixels per second

ALIENBOLT = 1
SHIPBOLT = 2

SCOREBOARD = Rect(0, 0, VIEWWIDTH, SHIPSIZE)
SCOREBOARD.midbottom = VIEWPORT.midtop
STATUSBAR = Rect(0, 0, VIEWWIDTH, SHIPSIZE)
STATUSBAR.midtop = VIEWPORT.midbottom

DEBUGWINDOW = Rect(0, 0, (SCREENSIZE[0] - VIEWWIDTH) // 2, SCREENSIZE[1])
DEBUGWINDOW.bottomright = SCREENSIZE

NR_OF_STARS = 50

# at what score, the player receives an extra life
EXTRA_LIVES = [30000, 100000]



# key mapping. 
# how to check whether keyboard is azerty or qwerty?
LEFT_KEYS = [K_LEFT, K_q]
RIGHT_KEYS = [K_RIGHT, K_d]
FIRE_KEYS = [K_SPACE, K_j, K_UP]