2. Dragon v1.0

  • Assignment: Dragon v1.0

  • Complexity: medium

  • Lines of code: on average 100 lines, shortest solution is 24 lines

  • Time: 89 min, then 144 min live coding with instructor

  • Warning: Don't delete code, assignment will be continued

../_images/dragon.gif

Figure 2.55. Firkraag dragon from game Baldur's Gate II: Shadows of Amn

2.1. English

Non-functional requirements:

  1. Commit and push your current state of repository

  2. In your directory create an empty file dragon_v1.py

  3. Add file to the version control system (should be automatic)

  4. Commit with message: "Dragon: NAME", where NAME is your first name

  5. Push changes to the repository

  6. In this file write a solution to the assignment

  7. Upon completing assignment commit and push changes to the repository

Functional requirements:

  1. Create Dragon with:

    1. name

    2. position on the screen

    3. health points, default random int in range from 50 to 100

    4. path to the texture file, default img/dragon/alive.png

  2. Dragon can:

    1. have position set to any place on the screen

    2. move in any direction by specified value

    3. make damage in range from 5 to 20

    4. take damage

  3. Assume left-top screen corner as an initial coordinates position:

    1. going right add to x

    2. going left subtract from x

    3. going up subtract from y

    4. going down add to y

  4. When health points drop to, or below zero:

    1. Dragon has status dead

    2. Change texture file name to img/dragon/dead.png

    3. Display NAME is dead, where NAME is the dragon's name

    4. Display how much gold dragon dropped (random integer from 1 to 100)

    5. Display position where dragon died

  5. Run the game:

    1. Create dragon named "Wawelski"

    2. Set Dragon's initial position to x=50, y=120

    3. Set new position to x=10, y=20

    4. Move dragon left by 10 and down by 20

    5. Move dragon left by 10 and right by 15

    6. Move dragon right by 15 and up by 5

    7. Move dragon down by 5

    8. Dragon makes damage

    9. Make 10 points damage to the dragon

    10. Make 5 points damage to the dragon

    11. Make 3 points damage to the dragon

    12. Make 2 points damage to the dragon

    13. Make 15 points damage to the dragon

    14. Make 25 points damage to the dragon

    15. Make 75 points damage to the dragon

    16. Dragon should die at the position x=20, y=40 and drop gold (1-100)

2.2. Polish

Wymagania niefunkcjonalne:

  1. Zapisz (commit) i wypchnij (push) aktualny stan repozytorium

  2. W swoim katalogu stwórz pusty plik dragon_v1.py

  3. Dodaj plik do systemu kontroli wersji

  4. Zapisz (commit) zmiany jako "Dragon: NAME", gdzie NAME to Twoje imię

  5. Wypchnij (push) zmiany do repozytorium

  6. W pliku zapisz kod do rozwiązania zadania

  7. Po skończeniu zadania zapisz i wypchnij zmiany do repozytorium

Wymagania funkcjonalne:

  1. Stwórz Smoka z:

    1. nazwą

    2. pozycją na ekranie

    3. punktami życia, domyślnie losowy int z zakresu od 50 do 100

    4. ścieżką do pliku tekstury, domyślnie img/dragon/alive.png

  2. Smok może:

    1. być ustawiony w dowolne miejsce ekranu

    2. być przesuwany w którymś z kierunków o zadaną wartość

    3. zadawać komuś losowe obrażenia z przedziału od 5 do 20

    4. otrzymywać obrażenia

  3. Przyjmij górny lewy róg ekranu za punkt początkowy:

    1. idąc w prawo dodajesz x

    2. idąc w lewo odejmujesz x

    3. idąc w górę odejmujesz y

    4. idąc w dół dodajesz y

  4. Kiedy punkty życia Smoka spadną do lub poniżej zera:

    1. smok ma status dead

    2. zmień nazwę pliku tekstury na img/dragon/dead.png

    3. wyświetl NAME is dead, gdzie NAME to nazwa smoka

    4. wyświetl ile złota smok wyrzucił (losowa liczba od 1 do 100)

    5. wyświetl pozycję gdzie smok zginął

  5. Przeprowadź grę:

    1. Stwórz smoka o nazwie "Wawelski"

    2. Ustaw inicjalną pozycję smoka na x=50, y=120

    3. Ustaw nową pozycję na x=10, y=20

    4. Przesuń smoka w lewo o 10 i w dół o 20

    5. Przesuń smoka w lewo o 10 i w prawo o 15

    6. Przesuń smoka w prawo o 15 i w górę o 5

    7. Przesuń smoka w dół o 5

    8. Smok zadaje obrażenia (5-20)

    9. Zadaj 10 obrażeń smokowi

    10. Zadaj 5 obrażeń smokowi

    11. Zadaj 3 obrażenia smokowi

    12. Zadaj 2 obrażenia smokowi

    13. Zadaj 15 obrażeń smokowi

    14. Zadaj 25 obrażeń smokowi

    15. Zadaj 75 obrażeń smokowi

    16. Smok powinien zginąć na pozycji: x=20, y=40 i zostawić złoto (1-100)

2.3. Hints

  • Shortest solution has 24 lines of code

  • from random import randint

  • randint(a, b) - random integer between a and b (inclusive!)

2.4. Solution

  • EN: Note, that this will spoil your fun and learning

  • PL: Zwróć uwagę, że to zepsuje Twoją zabawę i naukę

  • Basic

  • Intermediate

  • Advanced