1.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 233 min live coding with instructor

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

../../_images/dragon.gif

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

1.2.1. English

Non-functional requirements:

  1. Commit and push your current state of repository

  2. In your directory create an empty directory dragon

  3. In dragon directory create an empty file README.md

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

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

  6. Push changes to the repository

  7. Write a solution to the assignment in dragon directory

  8. Upon completing add all files in dragon to repository

  9. Commit and push changes to the central repository (Github)

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. Dragon has texture img/dragon/dead.png

    3. Display Dragon 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 (should be: x=20, y=40)

  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)

1.2.2. Polish

Wymagania niefunkcjonalne:

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

  2. W swoim katalogu stwórz pusty katalog dragon

  3. W katalogu dragon stwórz pusty plik README.md

  4. Dodaj plik README.md do systemu kontroli wersji

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

  6. Wypchnij (push) zmiany do repozytorium

  7. Zapisz kod do rozwiązania zadania w katalogu dragon

  8. Po zakończeniu dodaj wszystkie pliki z dragon do repozytorium

  9. Zapisz i wypchnij zmiany do centralnego repozytorium (Github)

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. Smok ma teksturę img/dragon/dead.png

    3. Wyświetl Dragon 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ął (powinna być: x=20, y=40)

  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)

1.2.3. Hints

  • Shortest solution has 24 lines of code

  • It is not a mistake: 'left by 10 and right by 15'

  • There are no errors in the assignment (testes on more than 300 trainings)

  • from random import randint

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

1.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