-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Robaczek #19
Open
lukaszbajkowski
wants to merge
12
commits into
abador:master
Choose a base branch
from
lukaszbajkowski:Robaczek
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Robaczek #19
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d38c312
Merge pull request #1 from abador/master
lukaszbajkowski 30a9343
Delete README.md
lukaszbajkowski ea89317
Add files via upload
lukaszbajkowski 228aded
Aplikacja Robaczek
5b3b514
Delete Robaczek.iml
lukaszbajkowski 7ed462a
Aplikacja Robaczek
2ba728a
Merge remote-tracking branch 'origin/Robaczek' into Robaczek
5403aae
Delete profiles_settings.xml
lukaszbajkowski 6c9537b
Delete .gitignore
lukaszbajkowski b4efcda
Delete modules.xml
lukaszbajkowski ae8d1ac
Delete vcs.xml
lukaszbajkowski 1e461a0
Create README.md
lukaszbajkowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# WD2020 | ||
Data visualisation classes zmiana 1 zmiana 222 zmiana 333 | ||
Data visualisation classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
6,2, | ||
4,9, | ||
1,5, | ||
7,6, | ||
10,3, | ||
3,7, | ||
2,8, | ||
5,5, | ||
5,2, | ||
7,3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import random | ||
|
||
class Objekt: | ||
def __init__(self, x, y): | ||
self.x = x | ||
self.y = y | ||
|
||
def Pobierz_X(self): | ||
return self.x | ||
|
||
def Pobierz_Y(self): | ||
return self.y | ||
|
||
def Ruch_X(self, x): | ||
self.x = x | ||
|
||
def Ruch_Y(self, y): | ||
self.y = y | ||
|
||
class Robaczek(Objekt): | ||
def __init__(self, x, y): | ||
super().__init__(x, y) | ||
self.predkosc = 1 | ||
self.poziom = 1 | ||
self.najedzenie = 0 | ||
|
||
def ZjedzOwoc(self, owoc, owoce): | ||
self.najedzenie += owoc.PobierzJedzenie() | ||
print('\n OOO! Zjadłeś owoc, który dał Ci - ' + str(owoc.PobierzJedzenie()) + ' EXP') | ||
owoce.remove(owoc) | ||
|
||
def SprawdzPoziom(self): | ||
if self.najedzenie >= 10: | ||
self.najedzenie -= 10 | ||
self.poziom += 1 | ||
print(' Awansowałeś na LVL ', self.poziom) | ||
|
||
class Owoc(Objekt): | ||
def __init__(self, x, y): | ||
super().__init__(x, y) | ||
self.jedzenie = random.randint(1, 5) | ||
|
||
def PobierzJedzenie(self): | ||
return self.jedzenie | ||
|
||
def PobierzOwoce(): | ||
lista = [] | ||
with open('owoce.txt', 'r') as file: | ||
linie = file.readlines() | ||
for linia in linie: | ||
aftersplit = linia.split(',') | ||
owoc_nowy = Owoc(aftersplit[0], aftersplit[1]) | ||
lista.append(owoc_nowy) | ||
return lista | ||
|
||
def WypiszOwoce(owoce): | ||
print("\n ----------------\n") | ||
for x in range(len(owoce)): | ||
print(" " + str(x + 1) + ". X: " + owoce[x].x + ' Y: ' + owoce[x].y + ' Moc: ' + str(owoce[x].jedzenie)) | ||
print("\n ----------------") | ||
|
||
def Start(): | ||
return random.randint(1, 10) | ||
|
||
def Sprawdz(robaczek, owoce): | ||
for owoc in owoce: | ||
if (int(robaczek.x) == int(owoc.x) and int(robaczek.y) == int(owoc.y)) is True: | ||
robaczek.ZjedzOwoc(owoc, owoce) | ||
robaczek.SprawdzPoziom() | ||
|
||
def move(x, y, predkosc): | ||
print(u"\nAktualna pozycja - X: " + str(x) + " Y: " + str(y)) | ||
way = ['w', 'a', 's', 'd'] | ||
direction = input(u"Podaj kierunek, w który chcesz się udać: ") | ||
if direction.lower() == way[0]: | ||
if robaczek.y + int(predkosc) > 10: | ||
print("Nie możesz iść dalej na północ, zawróć!") | ||
else: | ||
robaczek.Ruch_Y(robaczek.Pobierz_Y() + int(predkosc)) | ||
Sprawdz(robaczek, owoce) | ||
elif direction.lower() == way[1]: | ||
if robaczek.x - int(predkosc) < 1: | ||
print("Nie możesz iść dalej na zachód, zawróć!") | ||
else: | ||
robaczek.Ruch_X(robaczek.Pobierz_X() - int(predkosc)) | ||
Sprawdz(robaczek, owoce) | ||
elif direction.lower() == way[2]: | ||
if robaczek.y - int(predkosc) < 1: | ||
print("Nie możesz iść dalej na połódnie, zawróć!") | ||
else: | ||
robaczek.Ruch_Y(robaczek.Pobierz_Y() - int(predkosc)) | ||
Sprawdz(robaczek, owoce) | ||
elif direction.lower() == way[3]: | ||
if robaczek.x + int(predkosc) > 10: | ||
print("Nie możesz iść dalej na wschód, zawróć!") | ||
else: | ||
robaczek.Ruch_X(robaczek.Pobierz_X() + int(predkosc)) | ||
Sprawdz(robaczek, owoce) | ||
elif direction.lower() == 'info': | ||
print("\n ----------------") | ||
print('\n LVL: ' + str(robaczek.poziom) + '\n EXP: ' + str(robaczek.najedzenie)) | ||
print("\n ----------------") | ||
elif direction.lower() == "owoce": | ||
WypiszOwoce(owoce) | ||
|
||
print("ROBACZEK") | ||
owoce = PobierzOwoce() | ||
WypiszOwoce(owoce) | ||
robaczek = Robaczek(Start(), Start()) | ||
print(u"\n Ruszasz się WASD") | ||
predkosc = input(u"\n Domyślna i zalecana prędkość wynosi 1, jeżeli chcesz ją zmienić wpisz ją ") | ||
try: | ||
int(predkosc) | ||
robaczek.predkosc = predkosc | ||
except ValueError: | ||
print(' Podałeś coś innego, trudno. To gramy po mojemu') | ||
while len(owoce) is not 0: | ||
move(robaczek.x, robaczek.y, robaczek.predkosc) | ||
print("\n ----------------\n\n" | ||
" KONIEC GRY - WYGRAŁEŚ\n\n" | ||
" LVL - " + str(robaczek.poziom) + | ||
"\n EXP - " + str(robaczek.najedzenie) + | ||
"\n\n ----------------") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w move mozna użyć wektor wtedy będziemy mieli do czynienia tylko z przyrostem x i y(kierunek * szybkość)