Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you can do is use the sprite class</p> <p>make a class for a block like so:</p> <pre><code>from pygame.locals import * import pygame import os #added spaces show up as part of the code class Block(pygame.sprite.Sprite): def __init__(self, pos): #make it a sprite pygame.sprite.Sprite.__init__(self) #create a rect at position (pos) that is 25 by 25 pixels self.image = pygame.Rect(pos[0], pos[1] 25, 25) #make the rect a class variable that can be moved self.rect = self.image.get_rect() def update(self): #move rect 20 pixels each update (can be adjusted) self.rect.y += 20 #if it goes to to the bottom of the screen delete it if self.rect.y &gt; screen_height: self.kill() </code></pre> <p>then create a block like this:</p> <pre><code>block = Block([20, 20]) </code></pre> <p>then draw it and update it in the main loop like so:</p> <pre><code>block.update() block.draw() </code></pre> <p>you can create multiple blocks that will fall by using a sprite group:</p> <pre><code>block_list = pygame.sprite.Group() for i in xrange(10): block = Block([i,i]) block_list.add(block) </code></pre> <p>now you can update the whole group the same way:</p> <pre><code>block_list.draw() block_list.update() </code></pre> <p>you should do the same thing with the player and use an image instead of drawing him with lines</p> <p><a href="http://pygame.org/docs/ref/sprite.html" rel="nofollow">the Sprite class</a></p> <p><a href="http://pygame.org/docs/ref/rect.html" rel="nofollow">the Rect class</a></p> <p>Im sorry if i overwhelmed you it is very hard at first but very useful to learn </p> <p>Good luck :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload