Mercurial > pygame
annotate docs/tut/MoveIt.html @ 3172:d1b367fc08bc tests-returncode
Use a return code of 1 when the tests fail.
| author | Thomas Kluyver <takowl@gmail.com> |
|---|---|
| date | Wed, 09 Jan 2013 10:13:57 +0000 |
| parents | 9e633ef40a29 |
| children |
| rev | line source |
|---|---|
| 279 | 1 <html><head> <!-- |
| 2 TUTORIAL:Help! How Do I Move An Image? | |
| 3 --> | |
| 4 <title>Pygame Tutorials - Help! How Do I Move An Image?</title> | |
| 5 </head> | |
| 6 <body> | |
| 7 | |
| 8 <h1 align="center"><font size="-1">Pygame Tutorials</font><br> | |
| 9 Help! How Do I Move An Image?</h1> | |
| 10 | |
| 11 <h2 align="center">by Pete Shinners<br> | |
| 12 <font size="-1">pete@shinners.org</font></h2> | |
| 13 | |
| 408 | 14 <h3 align="center">Revision 1.2, August 20, 2002</h3> |
| 279 | 15 <br> |
| 16 <br> | |
| 17 Many people new to programming and graphics have a hard time figuring | |
| 18 out how to make an image move around the screen. Without understanding | |
| 19 all the concepts, it can be very confusing. You're not the first person | |
| 20 to be stuck here, I'll do my best to take things step by step. We'll even | |
| 21 try to end with methods of keeping your animations efficient.<br> | |
| 22 <br> | |
| 23 Note that we won't be teaching you to program with python in this article, | |
| 24 just introduce you to some of the basics with pygame.<br> | |
| 25 | |
| 26 <h2>Just Pixels On The Screen</h2> | |
| 27 Pygame has a display Surface. This is basically an image that is visible | |
| 28 on the screen, and the image is made up of pixels. The main way you change | |
| 29 these pixels is by calling the blit() function. This copies the pixels | |
| 30 from one image onto another.<br> | |
| 31 <br> | |
| 32 This is the first thing to understand. When you blit an image onto the | |
| 33 screen, you are simply changing the color of the pixels on the screen. | |
| 34 Pixels aren't added or moved, we just change the colors of the pixels aready | |
| 35 on the screen. These images you blit to the screen are also Surfaces in | |
| 36 pygame, but they are in no way connected to the display Surface. When they | |
| 37 are blitted to the screen they are copied into the display, but you still | |
| 38 have a unique copy of the original.<br> | |
| 39 <br> | |
| 40 With this brief description. Perhaps you can already understand what | |
| 41 is needed to "move" an image. We don't actually move anything at all. We | |
| 42 simply blit the image in a new position. But before we draw the image in | |
| 43 the new position, we'll need to "erase" the old one. Otherwise the image | |
| 44 will be visible in two places on the screen. By rapidly erasing the image | |
| 45 and redrawing it in a new place, we achieve the "illusion" of movement.<br> | |
| 46 <br> | |
| 47 Through the rest of this tutorial we will break this process down into | |
| 48 simpler steps. Even explaining the best ways to have multiple images moving | |
| 49 around the screen. You probably already have questions. Like, how do we | |
| 50 "erase" the image before drawing it in a new position? Perhaps you're still | |
| 51 totally lost? Well hopefully the rest of this tutorial can straighten things | |
| 52 out for you.<br> | |
| 53 <br> | |
| 54 | |
| 55 <h2>Let's Go Back A Step</h2> | |
| 56 Perhaps the concept of pixels and images is still a little foreign to | |
| 57 you? Well good news, for the next few sections we are going to use code that | |
| 58 does everything we want, it just doesn't use pixels. We're going to create | |
| 59 a small python list of 6 numbers, and imagine it represents some fantastic | |
| 60 graphics we could see on the screen. It might actually be surprising how | |
| 61 closely this represents exactly what we'll later be doing with real graphics.<br> | |
| 62 <br> | |
| 63 So let's begin by creating our screen list and fill it with a beautiful | |
| 64 landscape of 1s and 2s.<br> | |
| 65 | |
| 283 | 66 <blockquote><pre> |
| 67 <b>>>></b> screen = [1, 1, 2, 2, 2, 1] | |
| 68 <b>>>></b> print screen | |
| 69 <b>[1, 1, 2, 2, 2, 1]</b> | |
| 70 </pre></blockquote> | |
| 279 | 71 Now we've created our background. It's not going to be very exciting |
| 72 unless we also draw a player on the screen. We'll create a mighty hero | |
| 73 that looks like the number 8. Let's stick him near the middle of the map | |
| 74 and see what it looks like.<br> | |
| 75 | |
| 283 | 76 <blockquote><pre> |
| 77 <b>>>></b> screen[3] = 8 | |
| 78 <b>>>></b> print screen | |
| 296 | 79 <b>[1, 1, 2, 8, 2, 1]</b> |
| 283 | 80 </pre></blockquote> |
| 279 | 81 This might have been as far as you've gotten if you jumped right in doing |
| 82 some graphics programming with pygame. You've got some nice looking stuff | |
| 83 on the screen, but it cannot move anywhere. Perhaps now that our screen | |
| 84 is just a list of numbers, it's easier to see how to move him?<br> | |
| 85 <br> | |
| 86 | |
| 87 <h2>Making The Hero Move</h2> | |
| 88 Before we can start moving the character. We need to keep track of some | |
| 89 sort of position for him. In the last section when we drew him, we just picked | |
| 90 an arbitrary position. Let's do it a little more officially this time.<br> | |
| 91 | |
| 283 | 92 <blockquote><pre> |
| 93 <b>>>></b> playerpos = 3 | |
| 94 <b>>>></b> screen[playerpos] = 8 | |
| 95 <b>>>></b> print screen | |
| 96 <b>[1, 1, 2, 8, 2, 1]</b> | |
| 97 </pre></blockquote> | |
| 279 | 98 Now it is pretty easy to move him to a new position. We simple change |
| 99 the value of playerpos, and draw him on the screen again.<br> | |
| 100 | |
| 283 | 101 <blockquote><pre> |
| 102 <b>>>></b> playerpos = playerpos - 1 | |
| 103 <b>>>></b> screen[playerpos] = 8 | |
| 104 <b>>>></b> print screen | |
| 105 <b>[1, 1, 8, 8, 2, 1]</b> | |
| 106 </pre></blockquote> | |
| 107 Whoops. Now we can see two heros. One in the old position, and one | |
| 279 | 108 in his new position. This is exactly the reason we need to "erase" the hero |
| 109 in his old position before we draw him in the new position. To erase him, | |
| 110 we need to change that value in the list back to what it was before the hero | |
| 111 was there. That means we need to keep track of the values on the screen before | |
| 112 the hero replaced them. There's several way you could do this, but the easiest | |
| 113 is usually to keep a separate copy of the screen background. This means | |
| 114 we need to make some changes to our little game.<br> | |
| 115 <br> | |
| 116 | |
| 117 <h2>Creating A Map</h2> | |
| 118 What we want to do is create a separate list we will call our background. | |
| 119 We will create the background so it looks like our original screen did, | |
| 120 with 1s and 2s. Then we will copy each item from the background to the screen. | |
| 121 After that we can finally draw our hero back onto the screen.<br> | |
| 122 | |
| 283 | 123 <blockquote><pre> |
| 124 <b>>>></b> background = [1, 1, 2, 2, 2, 1] | |
| 125 <b>>>></b> screen = [0]*6 <i>#a new blank screen</i> | |
| 126 <b>>>></b> for i in range(6): | |
| 127 <b>...</b> screen[i] = background[i] | |
| 128 <b>>>></b> print screen | |
| 129 <b>[1, 1, 2, 2, 2, 1]</b> | |
| 130 <b>>>></b> playerpos = 3 | |
| 131 <b>>>></b> screen[playerpos] = 8 | |
| 132 <b>>>></b> print screen | |
| 133 <b>[1, 1, 2, 8, 2, 1]</b> | |
| 134 </pre></blockquote> | |
| 135 It may seem like a lot of extra work. We're no farther off than we were | |
| 279 | 136 before the last time we tried to make him move. But this time we have the |
| 137 extra information we need to move him properly.<br> | |
| 138 <br> | |
| 139 | |
| 140 <h2>Making The Hero Move (Take 2)</h2> | |
| 141 This time it will be easy to move the hero around. First we will erase | |
| 142 the hero from his old position. We do this by copying the correct value | |
| 143 from the background onto the screen. Then we will draw the character in his | |
| 144 new position on the screen<br> | |
| 145 | |
| 283 | 146 <blockquote><pre> |
| 147 <b>>>></b> print screen | |
| 148 <b>[1, 1, 2, 8, 2, 1]</b> | |
| 149 <b>>>></b> screen[playerpos] = background[playerpos] | |
| 150 <b>>>></b> playerpos = playerpos - 1 | |
| 151 <b>>>></b> screen[playerpos] = 8 | |
| 152 <b>>>></b> print screen | |
| 153 <b>[1, 1, 8, 2, 2, 1]</b> | |
| 154 </pre></blockquote> | |
| 279 | 155 There it is. The hero has moved one space to the left. We can use this |
| 156 same code to move him to the left again.<br> | |
| 157 | |
| 283 | 158 <blockquote><pre> |
| 159 <b>>>></b> screen[playerpos] = background[playerpos] | |
| 160 <b>>>></b> playerpos = playerpos - 1 | |
| 161 <b>>>></b> screen[playerpos] = 8 | |
| 162 <b>>>></b> print screen | |
| 163 <b>[1, 8, 2, 2, 2, 1]</b> | |
| 164 </pre></blockquote> | |
| 279 | 165 Excellent! This isn't exactly what you'd call smooth animation. But with |
| 166 a couple small changes, we'll make this work directly with graphics on | |
| 167 the screen.<br> | |
| 168 <br> | |
| 296 | 169 |
| 170 | |
| 171 <h2>Definition: "blit"</h2> | |
| 172 In the next sections we will transform our program from using lists to | |
| 173 using real graphics on the screen. When displaying the graphics we will | |
| 174 use the term <u>blit</u> frequently. If you are new to doing graphics | |
| 175 work, you are probably unframiliar with this common term.<br> | |
| 176 <br> | |
| 177 <b>BLIT:</b> Basically, blit means to copy graphics from one image | |
| 178 to another. A more formal definition is to copy an array of data | |
| 179 to a bitmapped array destination. You can think of blit as just | |
| 180 <i>"assigning"</i> pixels. Much like setting values in our screen-list | |
| 181 above, blitting assigns the color of pixels in our image.<br> | |
| 182 <br> | |
| 183 Other graphics libraries will use the word <i>bitblt</i>, or just <i>blt</i>, | |
| 184 but they are talking about the same thing. It is basically copying | |
| 185 memory from one place to another. Actually, it is a bit more advanced than | |
| 186 straight copying of memory, since it needs to handle things like pixel | |
| 187 formats, clipping, and scanline pitches. Advanced blitters can also | |
| 188 handle things like transparancy and other special effects.<br> | |
| 189 <br> | |
| 190 | |
| 279 | 191 |
| 192 <h2>Going From The List To The Screen</h2> | |
| 193 To take the code we see in the above to examples and make them work with | |
| 194 pygame is very straightforward. We'll pretend we have loaded some pretty | |
| 296 | 195 graphics and named them "terrain1", "terrain2", and "hero". Where before |
| 279 | 196 we assigned numbers to a list, we now blit graphics to the screen. Another |
| 197 big change, instead of using positions as a single index (0 through 5), we | |
| 198 now need a two dimensional coordinate. We'll pretend each of the graphics | |
| 199 in our game is 10 pixels wide.<br> | |
| 200 | |
| 283 | 201 <blockquote><pre> |
| 202 <b>>>></b> background = [terrain1, terrain1, terrain2, terrain2, terrain2, terrain1] | |
| 203 <b>>>></b> screen = create_graphics_screen() | |
| 204 <b>>>></b> for i in range(6): | |
| 205 <b>...</b> screen.blit(background[i], (i*10, 0)) | |
| 408 | 206 <b>>>></b> playerpos = 3 |
| 283 | 207 <b>>>></b> screen.blit(playerimage, (playerpos*10, 0)) |
| 208 </pre></blockquote> | |
| 279 | 209 Hmm, that code should seem very familiar, and hopefully more importantly; |
| 210 the code above should make a little sense. Hopefully my illustration of setting | |
| 211 simple values in a list shows the similarity of setting pixels on the screen | |
| 296 | 212 (with blit). The only part that's really extra work is converting the player position |
| 279 | 213 into coordinates on the screen. For now we just use a crude "(playerpos*10, |
| 214 0)", but we can certainly do better than that. Now let's move the player | |
| 215 image over a space. This code should have no surprises.<br> | |
| 216 | |
| 283 | 217 <blockquote><pre> |
| 218 <b>>>></b> screen.blit(background[playerpos], (playerpos*10, 0)) | |
| 219 <b>>>></b> playerpos = playerpos - 1 | |
| 220 <b>>>></b> screen.blit(playerimage, (playerpos*10, 0)) | |
| 221 </pre></blockquote> | |
| 279 | 222 There you have it. With this code we've shown how to display a simple background |
| 223 with a hero's image on it. Then we've properly moved that hero one space | |
| 224 to the left. So where do we go from here? Well for one the code is still | |
| 225 a little awkward. First thing we'll want to do is find a cleaner way to represent | |
| 226 the background and player position. Then perhaps a bit of smoother, real | |
| 227 animation.<br> | |
| 228 <br> | |
| 229 | |
| 230 <h2>Screen Coordinates</h2> | |
| 231 To position an object on the screen, we need to tell the blit() function | |
| 232 where to put the image. In pygame we always pass positions as an (X,Y) coordinate. | |
| 233 This represents the number of pixels to the right, and the number of pixels | |
| 234 down to place the image. The top-left corner of a Surface is coordinate (0, | |
| 235 0). Moving to the right a little would be (10, 0), and then moving down just | |
| 236 as much would be (10, 10). When blitting, the position argument represents | |
| 237 where the topleft corner of the source should be placed on the destination.<br> | |
| 238 <br> | |
| 239 Pygame comes with a convenient container for these coordinates, it is a | |
| 240 Rect. The Rect basically represents a rectangular area in these coordinates. | |
| 241 It has topleft corner and a size. The Rect comes with a lot of convenient | |
| 242 methods which help you move and position them. In our next examples we will | |
| 243 represent the positions of our objects with the Rects.<br> | |
| 244 <br> | |
| 245 Also know that many functions in pygame expect Rect arguments. All of these | |
| 246 functions can also accept a simple tuple of 4 elements (left, top, width, | |
| 247 height). You aren't always required to use these Rect objects, but you will | |
| 248 mainly want to. Also, the blit() function can accept a Rect as it's position | |
| 249 argument, it simply uses the topleft corner of the Rect as the real position.<br> | |
| 250 <br> | |
| 251 <br> | |
| 252 | |
| 253 <h2>Changing The Background</h2> | |
| 254 In all our previous sections, we've been storing the background as a list | |
| 255 of different types of ground. That is a good way to create a tile-based game, | |
| 256 but we want smooth scrolling. To make that a little easier, we're going to | |
| 257 change the background into a single image that covers the whole screen. This | |
| 258 way, when we want to "erase" our objects (before redrawing them) we only need | |
| 259 to blit the section of the erased background onto the screen.<br> | |
| 260 <br> | |
| 261 By passing an optional third Rect argument to blit, we tell blit to only | |
| 262 use that subsection of the source image. You'll see that in use below as we | |
| 263 erase the player image.<br> | |
| 264 <br> | |
| 265 Also note, now when we finish drawing to the screen, we call pygame.display.update() | |
| 266 which will show everything we've drawn onto the screen.<br> | |
| 267 <br> | |
| 268 | |
| 269 <h2>Smooth Movement</h2> | |
| 270 To make something appear to move smoothly, we only want to move it a couple | |
| 271 pixels at a time. Here is the code to make an object move smoothly across | |
| 272 the screen. Based on what we already now know, this should look pretty simple.<br> | |
| 273 <br> | |
| 274 | |
| 283 | 275 <blockquote><pre> |
| 276 <b>>>></b> screen = create_screen() | |
| 277 <b>>>></b> player = load_player_image() | |
| 278 <b>>>></b> background = load_background_image() | |
| 279 <b>>>></b> screen.blit(background, (0, 0)) <i>#draw the background</i> | |
| 280 <b>>>></b> position = player.get_rect() | |
| 281 <b>>>></b> screen.blit(player, position) <i>#draw the player</i> | |
| 282 <b>>>></b> pygame.display.update() <i>#and show it all</i> | |
| 283 <b>>>></b> for x in range(100): <i>#animate 100 frames</i> | |
| 284 <b>...</b> screen.blit(background, position, position) <i>#erase</i> | |
| 285 <b>...</b> position = position.move(2, 0) <i>#move player</i> | |
| 286 <b>...</b> screen.blit(player, position) <i>#draw new player</i> | |
| 287 <b>...</b> pygame.display.update() <i>#and show it all</i> | |
| 288 <b>...</b> pygame.time.delay(100) <i>#stop the program for 1/10 second</i> | |
| 289 </pre></blockquote> | |
| 279 | 290 There you have it. This is all the code that is needed to smoothly animate |
| 291 an object across the screen. We can even use a pretty background character. | |
| 292 Another benefit of doing the background this way, the image for the player | |
| 293 can have transparancy or cutout sections and it will still draw correctly | |
| 294 over the background (a free bonus).<br> | |
| 295 <br> | |
| 296 We also throw in a call to pygame.time.delay() at the end of our loop above. | |
| 297 This slows down our program a little, otherwise it might run so fast you might | |
| 298 not see it.<br> | |
| 299 <br> | |
| 300 | |
| 301 <h2>So, What Next?</h2> | |
| 302 Well there we have it. Hopefully this article has done everything it promised | |
| 303 to do. But, at this point the code really isn't ready for the next bestselling | |
| 304 game. How do we easily have multiple moving objects? What exactly are those | |
| 305 mysterious functions like load_player_image()? We also need a way to get simple | |
| 306 user input, and loop for more than 100 frames. We'll take the example we | |
| 307 have here, and turn it into an object oriented creation that would make momma | |
| 308 proud.<br> | |
| 309 <br> | |
| 310 | |
| 311 <h2>First, The Mystery Functions</h2> | |
| 312 Full information on these types of functions can be found in other tutorials | |
| 313 and reference. The pygame.image module has a load() function which will do | |
| 314 what we want. The lines to load the images should become this.<br> | |
| 315 | |
| 283 | 316 <blockquote><pre> |
| 317 <b>>>></b> player = pygame.image.load('player.bmp').convert() | |
| 318 <b>>>></b> background = pygame.image.load('liquid.bmp').convert() | |
| 319 </pre></blockquote> | |
| 320 We can see that's pretty simple, the load function just takes a filename | |
| 279 | 321 and returns a new Surface with the loaded image. After loading we make a call |
| 322 to the Surface method, convert(). Convert returns us a new Surface of the | |
| 323 image, but now converted to the same pixel format as our display. Since the | |
| 324 images will be the same format at the screen, they will blit very quickly. | |
| 325 If we did not convert, the blit() function is slower, since it has to convert | |
| 326 from one type of pixel to another as it goes.<br> | |
| 327 <br> | |
| 328 You may also have noticed that both the load() and convert() return new | |
| 329 Surfaces. This means we're really creating two Surfaces on each of these | |
| 330 lines. In other programming languages, this results in a memory leak (not | |
| 331 a good thing). Fortunately Python is smart enough to handle this, and pygame | |
| 332 will properly clean up the Surface we end up not using.<br> | |
| 333 <br> | |
| 334 The other mystery function we saw in the above example was create_screen(). | |
| 335 In pygame it is simple to create a new window for graphics. The code to create | |
| 336 a 640x480 surface is below. By passing no other arguments, pygame will just | |
| 337 pick the best colordepth and pixel format for us.<br> | |
| 338 <br> | |
| 339 | |
| 283 | 340 <blockquote><pre> |
| 341 <b>>>></b> screen = pygame.display.set_mode((640, 480)) | |
| 342 </pre></blockquote> | |
| 343 <br> | |
| 279 | 344 <h2>Handling Some Input</h2> |
| 298 | 345 We desparately need to change the main loop to look for any user input, (like |
| 346 when the user closes the window). We need to add "event handling" to our | |
| 347 program. All graphical programs use this Event Based design. The program | |
| 348 gets events like "keyboard pressed" or "mouse moved" from the computer. Then | |
| 349 the program responds to the different events. Here's what the code should | |
| 350 look like. Instead of looping for 100 frames, we'll keep looping until the | |
| 351 user asks us to stop.<br> | |
| 283 | 352 <blockquote><pre> |
| 353 <b>>>></b> while 1: | |
| 354 <b>...</b> for event in pygame.event.get(): | |
| 355 <b>...</b> if event.type in (QUIT, KEYDOWN): | |
| 356 <b>...</b> sys.exit() | |
| 298 | 357 <b>...</b> move_and_draw_all_game_objects() |
| 283 | 358 </pre></blockquote> |
| 279 | 359 What this code simply does is, first loop forever, then check if there are |
| 360 any events from the user. We exit the program if the user presses the keyboard | |
| 361 or the close button on the window. After we've checked all the events we | |
| 362 move and draw our game objects. (We'll also erase them before they move, | |
| 363 too)<br> | |
| 364 | |
| 365 <h2>Moving Multiple Images</h2> | |
| 366 Here's the part where we're really going to change things around. Let's | |
| 367 say we want 10 different images moving around on the screen. A good way to | |
| 368 handle this is to use python's classes. We'll create a class that represents | |
| 369 our game object. This object will have a function to move itself, and then | |
| 370 we can create as many as we like. The functions to draw and move the object | |
| 371 need to work in a way where they only move one frame (or one step) at a time. | |
| 372 Here's the python code to create our class.<br> | |
| 283 | 373 <blockquote><pre> |
| 374 <b>>>></b> class GameObject: | |
| 375 <b>...</b> def __init__(self, image, height, speed): | |
| 376 <b>...</b> self.speed = speed | |
| 377 <b>...</b> self.image = image | |
| 378 <b>...</b> self.pos = image.get_rect().move(0, height) | |
| 379 <b>...</b> def move(self): | |
| 380 <b>...</b> self.pos = self.pos.move(0, self.speed) | |
| 381 <b>...</b> if self.pos.right > 600: | |
| 382 <b>...</b> self.pos.left = 0 | |
| 383 </pre></blockquote> | |
| 279 | 384 So we have two functions in our class. The init function constructs our object. |
| 385 It positions the object and sets its speed. The move method moves the object | |
| 386 one step. If it's gone too far, it moves the object back to the left.<br> | |
| 387 <br> | |
| 388 <h2>Putting It All Together</h2> | |
| 389 Now with our new object class, we can put together the entire game. Here | |
| 390 is what the main function for our program will look like.<br> | |
| 283 | 391 <blockquote><pre> |
| 392 <b>>>></b> screen = pygame.display.set_mode((640, 480)) | |
| 393 <b>>>></b> player = pygame.image.load('player.bmp').convert() | |
| 394 <b>>>></b> background = pygame.image.load('background.bmp').convert() | |
| 395 <b>>>></b> screen.blit(background, (0, 0)) | |
| 396 <b>>>></b> objects = [] | |
| 397 <b>>>></b> for x in range(10): <i>#create 10 objects</i> | |
| 398 <b>...</b> o = GameObject(player, x*40, x) | |
| 399 <b>...</b> objects.append(o) | |
| 400 <b>>>></b> while 1: | |
| 401 <b>...</b> for event in pygame.event.get(): | |
| 402 <b>...</b> if event.type in (QUIT, KEYDOWN): | |
| 403 <b>...</b> sys.exit() | |
| 404 <b>...</b> for o in objects: | |
| 405 <b>...</b> screen.blit(background, o.pos, o.pos) | |
| 371 | 406 <b>...</b> for o in objects: |
| 407 <b>...</b> o.move() | |
| 408 <b>...</b> screen.draw(o.image, o.pos) | |
| 283 | 409 <b>...</b> pygame.display.update() |
| 410 <b>...</b> pygame.time.delay(100) | |
| 411 </pre></blockquote> | |
| 279 | 412 And there it is. This is the code we need to animate 10 objects on the screen. |
| 413 The only point that might need explaining is the two loops we use to clear | |
| 414 all the objects and draw all the objects. In order to do things properly, | |
| 415 we need to erase all the objects before drawing any of them. In our sample | |
| 416 here it may not matter, but when objects are overlapping, using two loops | |
| 417 like this becomes important.<br> | |
| 418 <br> | |
|
3161
9e633ef40a29
Fix spelling error in MoveIt tutorial. Thanks Samuel Villegas.
Rene Dudfield <renesd@gmail.com>
parents:
408
diff
changeset
|
419 <h2>You Are On Your Own From Here</h2> |
| 279 | 420 <p>So what would be next on your road to learning? Well first playing around |
| 421 with this example a bit. The full running version of this example is available | |
| 422 in the pygame examples directory. It is the example named "moveit.py". Take | |
| 423 a look at the code and play with it, run it, learn it.</p> | |
| 424 <p>Things you may want to work on is maybe having more than one type of object. | |
| 425 Finding a way to cleanly "delete" objects when you don't want to show them | |
| 426 anymore. Also updating the display.update() call to pass a list of the areas | |
| 427 onscreen that have changed.</p> | |
| 428 <p>There are also other tutorials and examples in pygame that cover these | |
| 429 issues. So when you're ready to keep learning, keep on reading. :-)</p> | |
| 430 <p>Lastly, you can feel free to come to the pygame mailing list or chatroom | |
| 431 with any questions on this stuff. There's always folks on hand who can help | |
| 432 you out with this sort of business.</p> | |
| 433 <p>Lastly, have fun, that's what games are for!<br> | |
| 434 </p> | |
| 283 | 435 </body> |
| 436 </html> |
