コード例 #1
1
ファイル: rect_test.py プロジェクト: CTPUG/pygame_cffi
 def test_midtop( self ):
     """Changing the midtop attribute moves the rect and does not change
        the rect's size
     """
     r = Rect( 1, 2, 3, 4 )
     new_midtop= (r.centerx+20,r.top+30)
     expected_topleft = (r.left+20,r.top+30)
     old_size = r.size
     
     r.midtop = new_midtop
     self.assertEqual( new_midtop, r.midtop )
     self.assertEqual( expected_topleft, r.topleft )
     self.assertEqual( old_size, r.size )
コード例 #2
0
ファイル: rect_test.py プロジェクト: annie60/Xilarius
    def test_midtop(self):
        """Changing the midtop attribute moves the rect and does not change
           the rect's size
        """
        r = Rect(1, 2, 3, 4)
        new_midtop = (r.centerx + 20, r.top + 30)
        expected_topleft = (r.left + 20, r.top + 30)
        old_size = r.size

        r.midtop = new_midtop
        self.assertEqual(new_midtop, r.midtop)
        self.assertEqual(expected_topleft, r.topleft)
        self.assertEqual(old_size, r.size)
コード例 #3
0
ファイル: constants.py プロジェクト: thomasdelrue/1GAM
VIEWBOUNDS = (SHIPSIZE // 2, VIEWWIDTH - SHIPSIZE // 2) # the bounds within which the ship can move

SHIPSPEED = 200. # in pixels per second, how fast the backdrop moves
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]
コード例 #4
0
 def rect(self):
     r = Rect(0, 0, self.parent.width, Constants.HP_BAR_HEIGHT)
     r.midtop = self.parent.rect.midbottom
     return r