1
# German translation for quickly
2
# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012
3
# This file is distributed under the same license as the quickly package.
4
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
8
"Project-Id-Version: quickly\n"
9
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10
"POT-Creation-Date: 2011-04-04 08:43-0400\n"
11
"PO-Revision-Date: 2012-02-28 10:46+0000\n"
12
"Last-Translator: Launchpad Translations Administrators <Unknown>\n"
13
"Language-Team: German <de@li.org>\n"
15
"Content-Type: text/plain; charset=UTF-8\n"
16
"Content-Transfer-Encoding: 8bit\n"
17
"X-Launchpad-Export-Date: 2012-02-29 04:43+0000\n"
18
"X-Generator: Launchpad (build 14874)\n"
20
#: data/templates/ubuntu-pygame/help/tutorial.xml:13(firstname)
24
#: data/templates/ubuntu-pygame/help/tutorial.xml:14(surname)
28
#: data/templates/ubuntu-pygame/help/tutorial.xml:16(corpauthor)
32
#: data/templates/ubuntu-pygame/help/tutorial.xml:20(date) data/templates/ubuntu-pygame/help/tutorial.xml:25(invpartnumber)
36
#: data/templates/ubuntu-pygame/help/tutorial.xml:0(application)
37
msgid "Quickly PyGame Template"
40
#: data/templates/ubuntu-pygame/help/tutorial.xml:24(productnumber)
44
#: data/templates/ubuntu-pygame/help/tutorial.xml:26(title)
45
msgid "<application>Quickly PyGame Template</application> 0.6.1 Tutorial"
48
#: data/templates/ubuntu-pygame/help/tutorial.xml:31(title)
49
msgid "About This Guide"
52
#: data/templates/ubuntu-pygame/help/tutorial.xml:32(para)
54
"Use <application>The Quickly Pygame Template</application> to write old "
55
"school arcade games for running on Ubuntu. PyGame is a framework that "
56
"handles sprites, collisons, sounds, and everything you need to make a game. "
57
"You just need to add the game play. The Quickly template creates a starter "
58
"game for you and comes ready for you to turn into your fun game, and then "
59
"easily package and share it with other Ubuntu users."
62
#: data/templates/ubuntu-pygame/help/tutorial.xml:35(para)
64
"The Quickly Pygame Template inherits from the Quickly Application template. "
65
"So you get all the commands that you get from the that template, except "
69
#: data/templates/ubuntu-pygame/help/tutorial.xml:41(title)
70
msgid "Creating and Running Your Game"
73
#: data/templates/ubuntu-pygame/help/tutorial.xml:44(para)
75
"In this tutorial we will start making a top down shooter reminiscent of the "
76
"space arcade shooters of the 1980s."
79
#: data/templates/ubuntu-pygame/help/tutorial.xml:50(para)
81
"We'll do this by creating a default game, editing some of the generated "
82
"code, writing some new code, and adding our images for sprits."
85
#: data/templates/ubuntu-pygame/help/tutorial.xml:53(para)
87
"Creating a default working game couldn't be simpler. First, open a terminal "
88
"window to type commands into. When it's open, type the command:"
91
#: data/templates/ubuntu-pygame/help/tutorial.xml:56(programlisting)
95
"$quickly create ubuntu-pygame shooter\n"
99
#: data/templates/ubuntu-pygame/help/tutorial.xml:60(para)
101
"This will create a shooter sub directory containing a complete directory "
102
"tree and files for an empty python application. The command finishes by "
103
"running the newly created game. The game is played by using the \"s\" and "
104
"\"f\" keys to rotate the guy, the \"j\" key to shoot, and the \"l\" key to "
108
#: data/templates/ubuntu-pygame/help/tutorial.xml:63(para)
110
"You can play the newly created game. Notice that the <application>Quickly "
111
"PyGame Template</application> inferred that the game title is \"Shooter\". "
112
"Also note that there is a guy that you can control with the s,f,j, and l "
113
"keys. There is an enemy and a homing missle. You also get a \"Game Over\" "
114
"screen, scoring, and levels build in for free."
117
#: data/templates/ubuntu-pygame/help/tutorial.xml:66(para)
119
"Close the game by closing the window or using the Esc key. Since the game "
120
"isn't installed into Ubuntu yet, you can't start the game from the "
121
"application menu yet. To start the game, use the terminal to first cd into "
122
"the new subdirectory, and then use \"quickly run\" to start the program."
125
#: data/templates/ubuntu-pygame/help/tutorial.xml:69(programlisting)
134
#: data/templates/ubuntu-pygame/help/tutorial.xml:75(title)
135
msgid "Creating your own Sprites"
138
#: data/templates/ubuntu-pygame/help/tutorial.xml:79(listitem)
140
"Ink Scape is a great and free tool for creating your sprites. It's in the "
141
"Featured Applications section of the Software Center."
144
#: data/templates/ubuntu-pygame/help/tutorial.xml:80(listitem)
146
"If you use Ink Scape, you'll want to export the images as PNGs. But keep the "
147
"Ink Scape files around in case you want to edit the sprites later."
150
#: data/templates/ubuntu-pygame/help/tutorial.xml:81(listitem)
152
"Whatever size you make the sprites, that's the size they will be in the game."
155
#: data/templates/ubuntu-pygame/help/tutorial.xml:82(listitem)
157
"The game will look for sprites in the data/media folder, so make sure you "
161
#: data/templates/ubuntu-pygame/help/tutorial.xml:76(para)
163
"The first think you probably noticed about the game is that the graphics are "
164
"so blah! Let's start by adding our own sprites. We;ll do a compbination of "
165
"replacing sprites with our own images, and also add a new sprite which we'll "
166
"use later. Here's a few things to keep in mind: <placeholder-1/>"
169
#: data/templates/ubuntu-pygame/help/tutorial.xml:85(para)
171
"I made new images for the guy (the sprite the player controls), enemies, "
172
"bullets, and the game background. I also made a new sprite called "
173
"\"enemy_bullet.png\" which we'll add into the game later. <placeholder-1/> "
174
"Just drag your new sprite images into the shooter/data/media and tell it to "
175
"replace the images. Now when you run the game, you'll see your new sprites "
176
"at work. <placeholder-2/> Oops. As you can see, the background image I "
177
"created was for a game of different dimensions. It's for a game that's 400 "
178
"pixels wide by 500 pixels high. In the next section, we'll make the game "
182
#: data/templates/ubuntu-pygame/help/tutorial.xml:98(title)
183
msgid "Changing the Screen Dimensions"
186
#: data/templates/ubuntu-pygame/help/tutorial.xml:99(para)
188
"The first change we'll make is to change the screen dimensions to be "
189
"oriented from top to bottom. We do this by changing a little code. So let's "
190
"fire up the code editor first. Run the edit command to fire up the editor."
193
#: data/templates/ubuntu-pygame/help/tutorial.xml:102(programlisting)
195
msgid "$quickly edit"
198
#: data/templates/ubuntu-pygame/help/tutorial.xml:104(programlisting)
202
"#screen dimensions\n"
203
"screen_width = 400\n"
204
"screen_height = 500\n"
207
#: data/templates/ubuntu-pygame/help/tutorial.xml:103(para)
209
"This command should open your code in Gedit. The screen dimensions are set "
210
"in the file \"shooterconfig.py\". So just go to that file and change the "
211
"width to 400 and the height to 500. <placeholder-1/> Save the file and run "
212
"the game again. Notice that the screen wrapping and centering and everything "
213
"was taken care of for you. That's because you made the change in the "
214
"shooterconfig.py file. This is the right place to add and change variables "
215
"that should be availble throughout the game. We'll be make a few more "
216
"changes here later."
219
#: data/templates/ubuntu-pygame/help/tutorial.xml:114(title)
220
msgid "Programming the Guy"
223
#: data/templates/ubuntu-pygame/help/tutorial.xml:115(para)
225
"For this game, what we want is the guy to move left and right across the "
226
"bottom and not wrap through the screen. Also, we want to make the bullets "
227
"look like they are coming out of the guy's front."
230
#: data/templates/ubuntu-pygame/help/tutorial.xml:121(listitem)
232
"Place the guy at the beginning of each level at the middle and bottom of the "
236
#: data/templates/ubuntu-pygame/help/tutorial.xml:122(listitem)
238
"Add functions to guy.py for moving and stop movig right and left, and remove "
239
"the rotate functions."
242
#: data/templates/ubuntu-pygame/help/tutorial.xml:123(listitem)
244
"Change the keyboard input in the bin/shooter file to call these new "
248
#: data/templates/ubuntu-pygame/help/tutorial.xml:118(para)
249
msgid "To make the guy move just left and right we need to: <placeholder-1/>"
252
#: data/templates/ubuntu-pygame/help/tutorial.xml:128(programlisting)
256
" def init_position(self):\n"
257
" \"\"\"init_position - resets the Guy's position near the\n"
258
" bottom of the screen\n"
261
" sw = shooterconfig.screen_width\n"
262
" sh = shooterconfig.screen_height\n"
265
" self.y = sh - 80\n"
268
#: data/templates/ubuntu-pygame/help/tutorial.xml:143(listitem)
269
msgid "start_moving_left: the user pressed the \"s\" key"
272
#: data/templates/ubuntu-pygame/help/tutorial.xml:144(listitem)
273
msgid "stop_moving_left: the user released the \"s\" key"
276
#: data/templates/ubuntu-pygame/help/tutorial.xml:145(listitem)
277
msgid "start_moving_right: the user pressed the \"f\" key"
280
#: data/templates/ubuntu-pygame/help/tutorial.xml:146(listitem)
281
msgid "stop_moving_right: the user released the \"f\" key"
284
#: data/templates/ubuntu-pygame/help/tutorial.xml:150(listitem)
285
msgid "Create two tracking variables, _moving_left and _moving_right"
288
#: data/templates/ubuntu-pygame/help/tutorial.xml:151(listitem)
290
"Set these tracking variables to True or False in the "
291
"start/stop_moving_left/right functions"
294
#: data/templates/ubuntu-pygame/help/tutorial.xml:152(listitem)
296
"In the guy's update function, change the x coordinates of the guy based on "
300
#: data/templates/ubuntu-pygame/help/tutorial.xml:126(para)
302
"The functionaly that is specific to the player's sprite is in the guy.py "
303
"file. The first thing we will do is work on placing the guy properly. "
304
"Fortunately, the is an existing function that we can modify for this. The "
305
"function init_position is called to each time the guy needs to be placed on "
306
"the screen, like after he gets killed for instance . When created, the guy "
307
"calls the based class function center_on_screen. As you may guess, we will "
308
"want to change this function. so the guys is positionedhalfway down the "
309
"screen, and we want him to start a few pixels from the bottom. Fortunaately "
310
"we know how to get the screen dimensions, so it's easy make the change to "
311
"init_position. <placeholder-1/> Now when you run the game, the guy starts at "
312
"the bottom, which is what we want, but he also rotates when we use the s and "
313
"the d button, which we do not want. So let's change that next by "
314
"implementing four new functions: <placeholder-2/> Here's how we will "
315
"implement these functions: <placeholder-3/>"
318
#: data/templates/ubuntu-pygame/help/tutorial.xml:158(programlisting)
322
" self._moving_left = False\n"
323
" self._moving_right = False\n"
326
#: data/templates/ubuntu-pygame/help/tutorial.xml:164(programlisting)
330
" def start_moving_right(self):\n"
331
" self._moving_left = False\n"
332
" self._moving_right = True\n"
334
" def start_moving_left(self):\n"
335
" self._moving_left = True\n"
336
" self._moving_right = False\n"
338
" def stop_moving_left(self):\n"
339
" self._moving_left = False\n"
341
" def stop_moving_right(self):\n"
342
" self._moving_right = False\n"
346
#: data/templates/ubuntu-pygame/help/tutorial.xml:156(para)
348
"First, add the tracking variables to the Guy.__init__function. Add these "
349
"after the call to BaseSprite.__init__(). <placeholder-1/> Now the functions "
350
"for responding to keys simply set those tracking variables as appropriate. "
351
"So we add these four new functions to guy.py. <placeholder-2/>"
354
#: data/templates/ubuntu-pygame/help/tutorial.xml:181(para)
356
"Now we need change the guy's coordinates based on the tracking variable. "
357
"Every sprite has an update function. This function is called for every "
358
"\"tick\" in the game, and the sprite looks at it's internal data, and "
359
"updates itself appropriately. By default, the guy's rotation is handled by "
360
"BaseSprite, so we can ignore that, especially since we won't be using "
361
"rotation anyway. We're also not using acceleration for the guy, so we can "
362
"delete a bit of code. Funally, we don't want the guy to \"wrap\" though the "
363
"screen, so we whould catch that condition."
366
#: data/templates/ubuntu-pygame/help/tutorial.xml:186(programlisting)
370
" def update(self):\n"
371
" \"\"\"update - Update internal data for a game tick\"\"\" \n"
373
" BaseSprite.update(self)\n"
375
" if self._moving_left:\n"
377
" if self.x < 0:\n"
379
" if self._moving_right:\n"
381
" if self.x + self.rect.width > shooterconfig.screen_width:\n"
382
" self.x = shooterconfig.screen_width - self.rect.width\n"
385
#: data/templates/ubuntu-pygame/help/tutorial.xml:184(para)
387
"Let's start with moving the guy 5 pixels per tick. So we can change the top "
388
"of the update function to look like this: <placeholder-1/>"
391
#: data/templates/ubuntu-pygame/help/tutorial.xml:202(para)
393
"So the guy is ready. He starts in the right place, tracks whether he is "
394
"moving left or right, and updates his position as desired. Now we just need "
395
"to hook him up the keys."
398
#: data/templates/ubuntu-pygame/help/tutorial.xml:205(para)
400
"Keyboard contol is handled in the shoort file in the bin directory. For each "
401
"click of the clock, the controller_tick function is called. Detecting "
402
"keyboard input and directing it as appropriate is handled in this funciton. "
403
"So what we wante to do is find where the f and s key events are handled, and "
404
"call the guy's start/stop_moving_left/right functions there."
407
#: data/templates/ubuntu-pygame/help/tutorial.xml:211(listitem)
408
msgid "Call the start_moving functions instead of rotate functions."
411
#: data/templates/ubuntu-pygame/help/tutorial.xml:212(listitem)
412
msgid "Remove the call to the accelerate function."
415
#: data/templates/ubuntu-pygame/help/tutorial.xml:213(listitem)
416
msgid "Remve the call to the hyperspace function."
419
#: data/templates/ubuntu-pygame/help/tutorial.xml:216(programlisting)
423
" #control the guy\n"
424
" if not game.paused: \n"
425
" if event.key == pygame.K_f:\n"
426
" g.start_moving_right()\n"
427
" if event.key == pygame.K_s:\n"
428
" g.start_moving_left()\n"
429
" if event.key == pygame.K_j:\n"
434
#: data/templates/ubuntu-pygame/help/tutorial.xml:208(para)
436
"Key down events are handled first, in a section commented \"control\" the "
437
"guy. We want to make a few changes here. <placeholder-1/> These last two "
438
"functions aren't needed for our new game. So let's make the changes and this "
439
"part of the controller_tick function will change to this: <placeholder-2/>"
442
#: data/templates/ubuntu-pygame/help/tutorial.xml:230(programlisting)
446
" #key up events, typically stop actions\n"
447
" if event.type == pygame.KEYUP:\n"
448
" if event.key == pygame.K_F11:\n"
449
" pygame.display.toggle_fullscreen() \n"
450
" if event.key == pygame.K_f:\n"
451
" g.stop_moving_right()\n"
452
" if event.key == pygame.K_s:\n"
453
" g.stop_moving_left()\n"
457
#: data/templates/ubuntu-pygame/help/tutorial.xml:228(para)
459
"We'll handle the key up functions similarly. <placeholder-1/><placeholder-2/>"
462
#: data/templates/ubuntu-pygame/help/tutorial.xml:248(listitem)
464
"The bullets accelerate and go way to fast, they'll miss enemies by skipping "
468
#: data/templates/ubuntu-pygame/help/tutorial.xml:249(listitem)
470
"The bullets should go to the top of the screen, and not stop before or wrap "
474
#: data/templates/ubuntu-pygame/help/tutorial.xml:250(listitem)
476
"The bullets should appear to come out of the middle of the guy, instead of "
480
#: data/templates/ubuntu-pygame/help/tutorial.xml:253(programlisting)
484
" self.max_velocity = 20\n"
485
" self.max_ticks = 20\n"
488
#: data/templates/ubuntu-pygame/help/tutorial.xml:258(programlisting)
492
" def update(self):\n"
493
" \"\"\"update - update internal data and position.\n"
494
" Typically called by the game controller each game\n"
499
" BaseSprite.update(self)\n"
501
" if self.y < 1:\n"
503
" if self.y == shooterconfig.screen_height:\n"
507
#: data/templates/ubuntu-pygame/help/tutorial.xml:282(programlisting)
511
" def shoot(self):\n"
512
" \"\"\"shoot - fire a bullet. Adds the bullet to the bullet sprite "
514
" If the maximum number of bullets premitted would be exceeded, \n"
515
" the bullet will not fire. If the guy is exploding, the guy will no\n"
521
" #only allow max numbe of bullets on the screen at a time\n"
522
" if len(self.bullets.sprites()) < self.max_bullets:\n"
523
" center_x = (self.x + self.rect.width / 2) - 3\n"
524
" b = Bullet(center_x,self.y,self.orientation)\n"
525
" self.bullets.add(b)\n"
528
#: data/templates/ubuntu-pygame/help/tutorial.xml:245(para)
530
"Now we've got the guy working the way we want, but we need to make a few "
531
"changes to to how the guy's bullets are working: <placeholder-1/> We'll "
532
"handle the first problem my changing the Bullet class in the bullet.py file. "
533
"The acceleration and speed of bullets in the game is configured in the "
534
"__init__ function of this file. The rate at whcih a bullet accelerates is "
535
"controlled by member variable acceleration_divisor. We won't need to change "
536
"that. However, the maximum speed a bullet will reach is defined ny "
537
"max_velocity, and the lifetme of the bullet is defined by max_ticks. Let's "
538
"make the bullets go slower, but last longer, by changing max_velocity to 20, "
539
"and max_ticks to 20 in the Bullet __init__ funciton. <placeholder-2/> This "
540
"simple change is all that is necessary to control the bullets throughout the "
541
"game. Note that making this change in the Bullet class means all bullets in "
542
"the game, including enemy bullets, will now work this way. So let's quickly "
543
"deal with stopping bullets from wrapping as well. We'll add to the Bullet "
544
"class's update function to see if the bullet is above or below the screen, "
545
"and if so, we'll remove it. So we'll change the to of the update function in "
546
"bullet.py to look like this: <placeholder-3/> Note that a Sprite's kill "
547
"function, removes it from the game immediately, and with no fanfare. "
548
"Finally, we need to adjust the bullet so it comes out from the guys the way "
549
"we want it to. Since this is only related to the way the guy shoots bullets "
550
"and won't have anything to do with enemy bullets, we'll configure how "
551
"bullets emerge in the guy.py file. Let's just tweak the shoot function a "
552
"bit. As you can see in this function, when you create a bullet, you provide "
553
"it x and y coordinates. We'll just calculate at better x coordinate to "
554
"start. We'll find the middle of the width of the guy's image, and offset it "
555
"a bit so the bullet sprite looks like it comes out correctly. "
556
"<progamlisting> center_x = (self.x + self.rect.width / 2) - 3 "
557
"</progamlisting> So we change change the ugy's shoot funciton to look like "
558
"this: <placeholder-4/>"
561
#: data/templates/ubuntu-pygame/help/tutorial.xml:299(para)
563
"<placeholder-1/> Now we have the guy working as desired. Moves back and "
564
"forth across the bottom and shoots bullets the way we want. Next we'll go on "
565
"to changing the way the enemies work."
568
#: data/templates/ubuntu-pygame/help/tutorial.xml:308(title)
569
msgid "Programming Enemies"
572
#: data/templates/ubuntu-pygame/help/tutorial.xml:309(para)
574
"The generated game always adds two enemies for each level, a homing missle "
575
"and a stock \"enemy\". The homing missle does pretty much what's it name "
576
"suggests, homes in on the guy and kills him. The Enemy doesn't do much of "
577
"anything. Just kind of plunks down and waits to get killed. First we're "
578
"going to remove the homing missle from the game, and then we'll customize "
579
"the enemies to be a bit more menancing."
582
#: data/templates/ubuntu-pygame/help/tutorial.xml:314(programlisting)
586
" #TODO: set up enemies here\n"
587
" #You can add more enemies or use different enemies\n"
588
" #depening on the level\n"
589
" for i in xrange(0,game.level + 3):\n"
590
" enemies.add(Enemy())\n"
593
#: data/templates/ubuntu-pygame/help/tutorial.xml:312(para)
595
"The bin/shooter fileset up a SpriteGroup already. It's called \"enemies\" "
596
"and gets populated each time a new level is created. New levels are created "
597
"in the next_level function in the bin/shooter file. The next_level function "
598
"is pretty simple, it increments the game level bu 1, removes any remaining "
599
"emenemities for the SpriteGroup and then repulates the enemies SpriteGroup. "
600
"Let's make a couple of basic chagnnges here. First, we'll change the xrange "
601
"so that it creates more enemies with each level, and second, we'll just "
602
"delete the line that creates the homing missle. Change the next_level "
603
"function to make the last few lines as below. <placeholder-1/> So for the "
604
"first level, there will by for enemies, and each time there is an new level "
605
"created the number of enemies will increase by 1. Aslo, no more homing "
606
"missles. <placeholder-2/>"
609
#: data/templates/ubuntu-pygame/help/tutorial.xml:326(para)
611
"However, there are two things we need to do to enhance the game play with "
612
"our enemies. First, as you can see, they can start quite close to the guy, "
613
"even under. We'll need to fix that. Also, we should put them in motion so "
614
"they are a bit more of a challenge to shoot. We'll do both of the things by "
615
"modifying the Enemy class in the enemy.py file. Specifically in the "
616
"init_postion function."
619
#: data/templates/ubuntu-pygame/help/tutorial.xml:329(para)
621
"If you open the enemy.py file and look for the init_position function, "
622
"you'll see there is a call to the function in __init__ but there is no "
623
"function for it. That's because enemy inherits from BaseSprite, which has a "
624
"default init_position implementation that randomly places it on the screen. "
625
"So we'll simply override the init_position function in the Enemy class in "
629
#: data/templates/ubuntu-pygame/help/tutorial.xml:334(programlisting)
633
" sh = shooterconfig.screen_height\n"
634
" sw = shooterconfig.screen_width\n"
637
#: data/templates/ubuntu-pygame/help/tutorial.xml:339(programlisting)
644
#: data/templates/ubuntu-pygame/help/tutorial.xml:343(programlisting)
648
" self.x = random.randint(20,sw - self.rect.width - 20)\n"
649
" self.y = random.randint(20,sh/2)\n"
652
#: data/templates/ubuntu-pygame/help/tutorial.xml:348(programlisting)
656
" self.velocity_x = random.randint(-30,30)\n"
659
#: data/templates/ubuntu-pygame/help/tutorial.xml:352(programlisting)
663
" def init_position(self):\n"
664
" sh = shooterconfig.screen_height\n"
665
" sw = shooterconfig.screen_width\n"
667
" self.x = random.randint(20,sw - self.rect.width - 20)\n"
668
" self.y = random.randint(20,sh/2)\n"
669
" self.velocity_x = random.randint(-30,30)\n"
672
#: data/templates/ubuntu-pygame/help/tutorial.xml:332(para)
674
"First, to make it a bitter easier to code, grab a reference to the screen "
675
"height and widgth that you configured and keep those in easier to use "
676
"variables. <placeholder-1/> Next, we want to choose random start position "
677
"along the X axis. But we don't want the enemy to start too close to either "
678
"side or it might get stuck in a spot where the guy can't shoot it. To "
679
"generate random integers, use the randome module, so you'll have to add an "
680
"import to the top of the file. <placeholder-2/> We can use the screenwidth "
681
"to and the enemies own width to determine the right most starting position. "
682
"For the Y axis, we want the enemies to be far enough away that they can't "
683
"too easily kill the guy. We'll also make sure they don't get out of reach of "
684
"the guy's bullets. So between 20 and half way down seems about right. "
685
"<placeholder-3/> Finally, let's put each enemy in motion by picking a random "
686
"velocity_x within some reasonable bounds. <placeholder-4/> Notice that one "
687
"in 60 of the enemies won't be moving. That's okay because we added padding "
688
"to keep the enemies from ending up too close to the sides. The full "
689
"init_position function you need to add looks like this: <placeholder-5/> "
690
"When you run the game, you can see that the enemies are moving and are good "
691
"targets to shoot at. But next we'll make the enemies fight back."
694
#: data/templates/ubuntu-pygame/help/tutorial.xml:366(listitem)
695
msgid "Figure out where to place the bullet on the screen"
698
#: data/templates/ubuntu-pygame/help/tutorial.xml:367(listitem)
699
msgid "Configure the bullet's velocity and maximum speed"
702
#: data/templates/ubuntu-pygame/help/tutorial.xml:368(listitem)
703
msgid "Create the bullet object and add it to a SpriteGroup"
706
#: data/templates/ubuntu-pygame/help/tutorial.xml:371(programlisting)
710
"#create the player's guy and some enemies\n"
711
"bullets = pygame.sprite.RenderUpdates()\n"
713
"enemies = pygame.sprite.RenderUpdates()\n"
714
"enemy_bullets = pygame.sprite.RenderUpdates()\n"
717
#: data/templates/ubuntu-pygame/help/tutorial.xml:380(listitem)
719
"Clear out all the sprites in the group when creating a new level or "
720
"resetting a level after the guy dies."
723
#: data/templates/ubuntu-pygame/help/tutorial.xml:381(listitem)
725
"Tell the bullets in the sprite group to update themselves at the right time."
728
#: data/templates/ubuntu-pygame/help/tutorial.xml:382(listitem)
729
msgid "Tell the bullets to draw themselves at the right time."
732
#: data/templates/ubuntu-pygame/help/tutorial.xml:383(listitem)
734
"Pass a reference to the sprite group to each enemy that is created, so it "
735
"can add it's bullets to the group."
738
#: data/templates/ubuntu-pygame/help/tutorial.xml:386(programlisting)
745
#: data/templates/ubuntu-pygame/help/tutorial.xml:390(programlisting)
749
"def update_sprites():\n"
750
" \"\"\"update_sprites - call update() for all sprites\"\"\"\n"
752
" bullets.update()\n"
753
" enemies.update() \n"
754
" enemy_bullets.update()\n"
757
#: data/templates/ubuntu-pygame/help/tutorial.xml:399(programlisting)
762
" enemies.draw(screen)\n"
763
" enemy_bullets.draw(screen)\n"
766
#: data/templates/ubuntu-pygame/help/tutorial.xml:405(programlisting)
770
" def __init__(self,enemy_bullets):\n"
771
" \"\"\"Creates an Enemy \"\"\"\n"
772
" self.enemy_bullets = enemy_bullets\n"
776
#: data/templates/ubuntu-pygame/help/tutorial.xml:412(programlisting)
780
" enemies.add(Enemy(enemy_bullets))\n"
783
#: data/templates/ubuntu-pygame/help/tutorial.xml:416(programlisting)
787
"from bullet import Bullet\n"
790
#: data/templates/ubuntu-pygame/help/tutorial.xml:421(programlisting)
794
" def shoot(self):\n"
796
" b = Bullet(self.x,self.y, 180)\n"
797
" b.max_velocity = 6\n"
798
" b.max_ticks = 50\n"
799
" self.enemy_bullets.add(b)\n"
802
#: data/templates/ubuntu-pygame/help/tutorial.xml:431(programlisting)
806
" if not game.paused:\n"
807
" for e in enemies:\n"
808
" if random.randint(0,20) == 1:\n"
812
#: data/templates/ubuntu-pygame/help/tutorial.xml:441(programlisting)
816
"enemy_bullet_image = image_path + \"enemy_bullet.png\"\n"
819
#: data/templates/ubuntu-pygame/help/tutorial.xml:445(programlisting)
823
" def shoot(self):\n"
825
" img = shooterconfig.enemy_bullet_image\n"
826
" b = Bullet(self.x,self.y, 180, img)\n"
827
" b.max_velocity = 6\n"
828
" b.max_ticks = 50\n"
829
" self.enemy_bullets.add(b)\n"
832
#: data/templates/ubuntu-pygame/help/tutorial.xml:363(para)
834
"Let's add the ability for an enemy to drop a bomb. By default, enemies can't "
835
"do anything like that, so we'll have to add a new function. The function "
836
"will need to do the following things: <placeholder-1/> We should probably "
837
"start with this last part. We'll want to create a special sprite group for "
838
"the bullets to go into. This is primarily so that we can use the "
839
"SpriteGroups collision detection capabilities later. Also it's easier to "
840
"manage updates of sprites when they are in a group. First things first, "
841
"we'll create the sprite group. There's a place in the bin/shooter for "
842
"setting up enemies and such, so create another sprite group there. You "
843
"create a sprite group by calling a function in the pygame.sprite module "
844
"called \"RenderUpdates\". Lookk for the code block below, and notice the new "
845
"line creating the new sprite group by calling RenderUpdates. <placeholder-"
846
"2/> Now that we have the sprite group called enemy_bullets we want to do "
847
"three more things with it for now. <placeholder-3/> So for the first part, "
848
"we'll call the sprite group's empty function in next_level and reset_level "
849
"This function simply removes each sprite in the sprite group from game play. "
850
"Do this as the first thing for each of these function. <placeholder-4/> For "
851
"the second point, we'll add to the function in bin/shooter called "
852
"update_sprites. As you may have guessed, this function is called each tick "
853
"and tells each sprite to update. For sprites in a sprite group, this is "
854
"easy, because the SpriteGroup class includes an update function that calls "
855
"update for each of it's sprites. So just add that to the end of the "
856
"update_sprites function in bin/shooter, so it looks like the listing here: "
857
"<placeholder-5/> The view_tick function is called once per tick as well. "
858
"This funciton updates the view on the screen. We'll add a line of code to "
859
"tell the bullets to draw themselves right under where the enemies draw "
860
"themselves. <placeholder-6/> Finally, we need to pass a reference to each "
861
"enemy as it is created and create a member variable to store that reference. "
862
"So we need to make a change in the enemy.py fil, to add an argument for the "
863
"SpriteGroup in the __init__ function, and also we need to pass the "
864
"SpriteGroup when creating enemies. So change the Enemy class in enemy.py so "
865
"the top of the __init__ function looks like so: <placeholder-7/> And then "
866
"back in the bin/shooter file in the next_level function when creating "
867
"enemies, pass in enemy_bullets. <placeholder-8/> Now we have a functioning "
868
"sprite group and the enemies have a reference to it, we are ready to start "
869
"actually adding some bullets to it. We'll do this by adding a member "
870
"function called \"shoot\" to the enemy. Don't forget to import the Bullet "
871
"class into the enemy.py file. <placeholder-9/> First thing is we'll check "
872
"that the enemy is alive. We don't have to do this, but for this game, we "
873
"don't want it to shoot if it's int the process of exploding. Then we'll just "
874
"create a bullet and add it to the SpriteGroup. The last argument we'll pass "
875
"in is to set the orientatin to 180. Orientation goes clockwise for 360 "
876
"degrees, with zero being directly up, and 180 being directly down. In code, "
877
"it looks like the listing below. <placeholder-10/> So now we just need to "
878
"tell the enemies to shoot. We'll do this back in the bin/shooter file, in "
879
"the\"controller_tick function. After the section where we respond to "
880
"keyboard input, we'll add a few lines to make the enemies shoot. First, "
881
"we'll make sure the game is not paused, not very fair to shoot in a paused "
882
"game, is it? Next we'll loop through the enemies and desider if we should "
883
"call shoot. using our friend random.randint, we'll do this say, one time "
884
"twenty. So if you add this code to the end of the controller_tick function, "
885
"your enemies will start dropping bombs. <placeholder-11/><placeholder-12/> "
886
"So if you run the game, you'll see that the enemies are dropping bulltes "
887
"like bombs. Nice. However, maybe it would be nicer if the sprites for the "
888
"enemy bullets were different than the sprites for the guy's bullets. "
889
"Remember at the beginning of the tutorial we added an image called "
890
"enemy_bullet.png to the data/media directory. Now we'll write a bit of code "
891
"to use that image. First thing, we should add a reference to it in the "
892
"shooterconfig.py file. In this way, the Enemy class will be able to find it. "
893
"Just add the following line along with the other image path setting code in "
894
"shooterconfig.py. <placeholder-13/> So now we need to tell the bullets in "
895
"the Enemy class to use that image. Fortunately the Bullet class takes an "
896
"optional parameter for the name of an image to use. So just modify the shoot "
897
"function in the Enemy class to include the path. <placeholder-14/> Now the "
898
"enemies are dropping bombs with our new image. <placeholder-15/>"
901
#: data/templates/ubuntu-pygame/help/tutorial.xml:459(para)
903
"But of course, you many notice the bombs aren't too menancing. In the next "
904
"chapter we'll add collision detection to make the bombs kill the guy."
907
#: data/templates/ubuntu-pygame/help/tutorial.xml:464(title)
908
msgid "Collision Detection"
911
#: data/templates/ubuntu-pygame/help/tutorial.xml:465(para)
913
"Collision detection is when you check for sprites that are overlapping, and "
914
"run code based on what happened. PyGame makes this very easy by providing "
915
"some functions to check for overlapping sprites for you. As you will see, it "
916
"works for individual sprites as well as sprite groups."
919
#: data/templates/ubuntu-pygame/help/tutorial.xml:470(programlisting)
923
" b = pygame.sprite.spritecollideany(g, enemy_bullets)\n"
929
#: data/templates/ubuntu-pygame/help/tutorial.xml:481(programlisting)
933
" hits_dict = pygame.sprite.groupcollide(bullets, enemy_bullets, True, "
937
#: data/templates/ubuntu-pygame/help/tutorial.xml:468(para)
939
"Ok, so let's start by making the bombs that the enemies drop actually kill "
940
"the guy. To do this, we want to check if the bombs ever collide with the "
941
"guy, and if they do, we'll tell the guy to explode, and then we'll remove "
942
"the bomb from the screen. So the logic is \"tell me if the guy collides with "
943
"any enemy_bullets\". There is a funciton for this called, "
944
"pygame.sprite.spritecollideany, which takes a single sprite and a sprite "
945
"group and returns a reference to any sprite in the sprite group that "
946
"collided with the single sprite. If there were no collisions, than e will be "
947
"None. Otherwise, we'll want to tell the guy to explode and tell the bullet "
948
"to just \"kill\", which will remove it from play. So we can call it like "
949
"this: <placeholder-1/> There is a function in bin/shooter called "
950
"check_collisions which is called once per tick, and is the perfect place to "
951
"add this code. Add it right under the similar test for the guy colliding "
952
"with enemies. Now those bombs can kill the guys. <placeholder-2/> If you "
953
"play for a bit, you may notice that the bullets and the bombs just kind of "
954
"pass by each other. We can ramp up the game play by making the enemy bullets "
955
"destroy the guy's bullets, but not visa versa. So that logic here is, have "
956
"any of the sprites in the bullets sprite group collided with the bullets in "
957
"the enemy bullets sprite group. There is function for this as well, "
958
"pygame.sprite.groupcollide. groupcollide takes two sprite lists and returns "
959
"a dictionary. The keys in the dictionary are any sprites from the first "
960
"group that are involved in a collision, and the values are the sprites from "
961
"the second group that collided with the sprite that for key. It's a bit hard "
962
"to explain, but I bet the code is pretty readable. Add this line to the "
963
"check_collisions function. <placeholder-3/> Now if you run the game, it's a "
964
"bit more challenging as the enemies are a bit more offensive. This code just "
965
"kills the bullets involed in any collisions. Notice that I passed in True "
966
"False at the end of this function. These paramaters determine whether to "
967
"kill sprites form either group involved in the collusion. The True tells the "
968
"function to kill any bullets involved in collisions, so this was simple to "
972
#: data/templates/ubuntu-pygame/help/tutorial.xml:488(title)
973
msgid "Playing Sounds"
976
#: data/templates/ubuntu-pygame/help/tutorial.xml:491(programlisting)
980
"tink_sound = sound_path + \"tink.wav\" \n"
984
#: data/templates/ubuntu-pygame/help/tutorial.xml:495(programlisting)
988
"#set up some objects and models\n"
989
"tink_sound = pygame.mixer.Sound(shooter.shooterconfig.tink_sound) \n"
993
#: data/templates/ubuntu-pygame/help/tutorial.xml:500(programlisting)
997
" hits_dict = pygame.sprite.groupcollide(bullets, enemy_bullets, True, "
999
" if len(hits_dict) > 0:\n"
1000
" tink_sound.play() \n"
1004
#: data/templates/ubuntu-pygame/help/tutorial.xml:506(programlisting)
1008
" self.launch_sound = "
1009
"pygame.mixer.Sound(shooterconfig.guy_shoot_sound)\n"
1010
" self.launch_sound.set_volume(.2)\n"
1011
" self.launch_sound.play() \n"
1015
#: data/templates/ubuntu-pygame/help/tutorial.xml:489(para)
1017
"The game is pretty much done in terms of game play, but I want to make one "
1018
"small enhancement. When the enemy bullets kill one of the guy's bullets, I'd "
1019
"like to play a little sound to signify this. So first, I added a little "
1020
"\"tink\" sound to the data/media directory. After you add your sound, you "
1021
"need to add a reference to it in the shootercongif.py file. <placeholder-1/> "
1022
"Now, I want to add a little code after the collision detection between the "
1023
"bullets to play that sound if they collided. I can't just hop straight to "
1024
"that though, first I have to create a sound object.In pygame you manage "
1025
"sounds with the \"mixer\" module. I don't want to create this object over "
1026
"and over again. So I'll add it to the bin/shooter file where the other "
1027
"objects and such for the game are set up. <placeholder-2/> Now that I've "
1028
"told the mixer module to give me a sound, I can go ahead and check if there "
1029
"were any collisions between bullets, and play my sound. <placeholder-3/> So "
1030
"it seems to be working well, but what if you are finding that one of the "
1031
"sounds is too quiet or too loud? Or perhpas you want a certain sound to be "
1032
"loud sometimes and queit other times, for example to simulate distance. This "
1033
"is easy to do because each sound object has a set_volume function that you "
1034
"can use to set the sound between 0 (for slient) and 1 (for normal volume). "
1035
"The bullet launch sound I used was a bit loud, so in the bullet.py file, "
1036
"I'll adjust the Bullet class to play the sound a bit more quietly. "
1040
#: data/templates/ubuntu-pygame/help/tutorial.xml:514(title)
1044
#: data/templates/ubuntu-pygame/help/tutorial.xml:518(listitem)
1045
msgid "Creating a game using $quickly create ubuntu-pygame"
1048
#: data/templates/ubuntu-pygame/help/tutorial.xml:519(listitem)
1049
msgid "Adding your own sprites to the game"
1052
#: data/templates/ubuntu-pygame/help/tutorial.xml:520(listitem)
1053
msgid "Setting the screen size and other info in the config file"
1056
#: data/templates/ubuntu-pygame/help/tutorial.xml:521(listitem)
1057
msgid "Programming a player's guy to respond to keyboard input and to shoot"
1060
#: data/templates/ubuntu-pygame/help/tutorial.xml:522(listitem)
1061
msgid "Programming enemies to move and shoot"
1064
#: data/templates/ubuntu-pygame/help/tutorial.xml:523(listitem)
1065
msgid "Using collision detection to blow up Sprites"
1068
#: data/templates/ubuntu-pygame/help/tutorial.xml:524(listitem)
1069
msgid "Playing and adjusting sounds"
1072
#: data/templates/ubuntu-pygame/help/tutorial.xml:528(listitem)
1074
"The bullets that the guy shoots and the bombs that the enemies drop make the "
1075
"same sound, it would probably be nicer if they each made a different sounds."
1078
#: data/templates/ubuntu-pygame/help/tutorial.xml:529(listitem)
1080
"The default explosions are crayon drawings, they don't fit in much with the "
1081
"look of the game. Perhaps some new images for the explosion stages would be "
1085
#: data/templates/ubuntu-pygame/help/tutorial.xml:530(listitem)
1087
"There are no power ups! You could create power up classes the derive from "
1088
"BaseSprite to give the guy extra powers, like bigger bullets, more bullets, "
1092
#: data/templates/ubuntu-pygame/help/tutorial.xml:531(listitem)
1094
"More special enemies, for example you could use the HomingMissle class to "
1095
"create harder to kill enemies."
1098
#: data/templates/ubuntu-pygame/help/tutorial.xml:532(listitem)
1100
"The high score list is stored in desktopcouch, so it will sync with your "
1101
"other computers. But it will have to be adjusted to the size we set for the "
1102
"window, and perhaps you can also let the player choose the name that's "
1106
#: data/templates/ubuntu-pygame/help/tutorial.xml:515(para)
1108
"So now you have a working game! This tutorial introduced the following key "
1109
"concepts for using the Quickly PyGame Template. <placeholder-1/> But there "
1110
"is still a lot to do to have a propper game. For example: <placeholder-2/>"
1113
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2
1114
#: data/templates/ubuntu-pygame/help/tutorial.xml:0(None)
1115
msgid "translator-credits"
1117
"Launchpad Contributions:\n"
1118
" Daniel Dietrich https://launchpad.net/~shaddowy2"