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

Figure 1.13. Firkraag dragon from game Baldur's Gate II: Shadows of Amn¶
1.2.1. English¶
Non-functional requirements:
Commit and push your current state of repository
In your directory create an empty directory
dragon
In
dragon
directory create an empty fileREADME.md
Add file to the version control system (should be automatic)
Commit with message: "Dragon: NAME", where
NAME
is your first namePush changes to the repository
Write a solution to the assignment in
dragon
directoryUpon completing add all files in
dragon
to repositoryCommit and push changes to the central repository (Github)
Functional requirements:
Create Dragon with:
Name
Position on the screen
Health points, default random
int
in range from 50 to 100Path to the texture file, default
img/dragon/alive.png
Dragon can:
Have position set to any place on the screen
Move in any direction by specified value
Make damage in range from 5 to 20
Take damage
Assume left-top screen corner as an initial coordinates position:
Going right add to
x
Going left subtract from
x
Going up subtract from
y
Going down add to
y
When health points drop to, or below zero:
Dragon has status
dead
Dragon has texture
img/dragon/dead.png
Display
Dragon NAME is dead
, whereNAME
is the dragon's nameDisplay how much gold dragon dropped (random integer from 1 to 100)
Display position where dragon died (should be: x=20, y=40)
Run the game:
Create dragon named "Wawelski"
Set Dragon's initial position to x=50, y=120
Set new position to x=10, y=20
Move dragon left by 10 and down by 20
Move dragon left by 10 and right by 15
Move dragon right by 15 and up by 5
Move dragon down by 5
Dragon makes damage
Make 10 points damage to the dragon
Make 5 points damage to the dragon
Make 3 points damage to the dragon
Make 2 points damage to the dragon
Make 15 points damage to the dragon
Make 25 points damage to the dragon
Make 75 points damage to the dragon
Dragon should die at the position x=20, y=40 and drop gold (1-100)
1.2.2. Polish¶
Wymagania niefunkcjonalne:
Zapisz (commit) i wypchnij (push) aktualny stan repozytorium
W swoim katalogu stwórz pusty katalog
dragon
W katalogu
dragon
stwórz pusty plikREADME.md
Dodaj plik
README.md
do systemu kontroli wersjiZapisz (commit) zmiany jako "Dragon: NAME", gdzie
NAME
to Twoje imięWypchnij (push) zmiany do repozytorium
Zapisz kod do rozwiązania zadania w katalogu
dragon
Po zakończeniu dodaj wszystkie pliki z
dragon
do repozytoriumZapisz i wypchnij zmiany do centralnego repozytorium (Github)
Wymagania funkcjonalne:
Stwórz Smoka z:
Nazwą
Pozycją na ekranie
Punktami życia, domyślnie losowy
int
z zakresu od 50 do 100Ścieżką do pliku tekstury, domyślnie
img/dragon/alive.png
Smok może:
Być ustawiony w dowolne miejsce ekranu
Być przesuwany w którymś z kierunków o zadaną wartość
Zadawać komuś losowe obrażenia z przedziału od 5 do 20
Otrzymywać obrażenia
Przyjmij górny lewy róg ekranu za punkt początkowy:
Idąc w prawo dodajesz
x
Idąc w lewo odejmujesz
x
Idąc w górę odejmujesz
y
Idąc w dół dodajesz
y
Kiedy punkty życia Smoka spadną do lub poniżej zera:
Smok ma status
dead
Smok ma teksturę
img/dragon/dead.png
Wyświetl
Dragon NAME is dead
, gdzieNAME
to nazwa smokaWyświetl ile złota smok wyrzucił (losowa liczba od 1 do 100)
Wyświetl pozycję gdzie smok zginął (powinna być: x=20, y=40)
Przeprowadź grę:
Stwórz smoka o nazwie "Wawelski"
Ustaw inicjalną pozycję smoka na x=50, y=120
Ustaw nową pozycję na x=10, y=20
Przesuń smoka w lewo o 10 i w dół o 20
Przesuń smoka w lewo o 10 i w prawo o 15
Przesuń smoka w prawo o 15 i w górę o 5
Przesuń smoka w dół o 5
Smok zadaje obrażenia (5-20)
Zadaj 10 obrażeń smokowi
Zadaj 5 obrażeń smokowi
Zadaj 3 obrażenia smokowi
Zadaj 2 obrażenia smokowi
Zadaj 15 obrażeń smokowi
Zadaj 25 obrażeń smokowi
Zadaj 75 obrażeń smokowi
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 betweena
andb
(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ę