forked from Q2-Wl/FinnBestmann_Kart
test
This commit is contained in:
-176
@@ -1,176 +0,0 @@
|
|||||||
# ---> Python
|
|
||||||
# Byte-compiled / optimized / DLL files
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
downloads/
|
|
||||||
eggs/
|
|
||||||
.eggs/
|
|
||||||
lib/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
share/python-wheels/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
|
||||||
# Usually these files are written by a python script from a template
|
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.nox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
*.py,cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
|
||||||
# .python-version
|
|
||||||
|
|
||||||
# pipenv
|
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
||||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
||||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
||||||
# install all needed dependencies.
|
|
||||||
#Pipfile.lock
|
|
||||||
|
|
||||||
# UV
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
#uv.lock
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
||||||
#poetry.lock
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
||||||
#pdm.lock
|
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
||||||
# in version control.
|
|
||||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
||||||
.pdm.toml
|
|
||||||
.pdm-python
|
|
||||||
.pdm-build/
|
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
||||||
__pypackages__/
|
|
||||||
|
|
||||||
# Celery stuff
|
|
||||||
celerybeat-schedule
|
|
||||||
celerybeat.pid
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env/
|
|
||||||
venv/
|
|
||||||
ENV/
|
|
||||||
env.bak/
|
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
|
||||||
.spyderproject
|
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
.dmypy.json
|
|
||||||
dmypy.json
|
|
||||||
|
|
||||||
# Pyre type checker
|
|
||||||
.pyre/
|
|
||||||
|
|
||||||
# pytype static type analyzer
|
|
||||||
.pytype/
|
|
||||||
|
|
||||||
# Cython debug symbols
|
|
||||||
cython_debug/
|
|
||||||
|
|
||||||
# PyCharm
|
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
||||||
#.idea/
|
|
||||||
|
|
||||||
# Ruff stuff:
|
|
||||||
.ruff_cache/
|
|
||||||
|
|
||||||
# PyPI configuration file
|
|
||||||
.pypirc
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,10 @@
|
|||||||
class Knoten():
|
class Knoten():
|
||||||
def __init__(self,data):
|
def __init__(self, daten, next):
|
||||||
self.data = data
|
self.daten = daten
|
||||||
self.nachfolger = None
|
self.next = None
|
||||||
|
|
||||||
|
def givedata(self):
|
||||||
|
return self.daten
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
return self.nachfolger
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
class Items:
|
|
||||||
def __init__(self, name, wirkung):
|
|
||||||
self.name = name
|
|
||||||
self.wirkung = wirkung
|
|
||||||
|
|
||||||
def benutzen(self, kart):
|
|
||||||
if self.name == "Turbo":
|
|
||||||
kart.geschwindigkeit = kart.geschwindigkeit + self.wirkung
|
|
||||||
|
|
||||||
if kart.geschwindigkeit > kart.v_max:
|
|
||||||
kart.geschwindigkeit = kart.v_max
|
|
||||||
|
|
||||||
elif self.name == "Bremse":
|
|
||||||
kart.geschwindigkeit = kart.geschwindigkeit - self.wirkung
|
|
||||||
|
|
||||||
if kart.geschwindigkeit < 0:
|
|
||||||
kart.geschwindigkeit = 0
|
|
||||||
|
|
||||||
def beschreibung(self):
|
|
||||||
return self.name + " verändert die geschwindigkeit um " + str(self.wirkung) + " km/h."
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
class Kart:
|
|
||||||
def __init__(self, name, farbe, v_max, geschwindigkeit, handling, position, ramm):
|
|
||||||
self.name = name
|
|
||||||
self.farbe = farbe
|
|
||||||
self.v_max = v_max
|
|
||||||
self.geschwindigkeitindigkeit = geschwindigkeit
|
|
||||||
self.handling = handling
|
|
||||||
self.driften_anzahl = 0
|
|
||||||
self.position = position
|
|
||||||
self.ramm = ramm
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def beschleunigung(self):
|
|
||||||
self.geschwindigkeit = self.geschwindigkeit + 5
|
|
||||||
|
|
||||||
if self.geschwindigkeit > self.v_max:
|
|
||||||
self.geschwindigkeit = self.v_max
|
|
||||||
|
|
||||||
|
|
||||||
def bremsen(self):
|
|
||||||
self.geschwindigkeit = self.geschwindigkeit - 10
|
|
||||||
|
|
||||||
if self.geschwindigkeit < 0:
|
|
||||||
self.geschwindigkeit = 0
|
|
||||||
|
|
||||||
|
|
||||||
def driften(self):
|
|
||||||
self.driften_anzahl = self.driften_anzahl + 1
|
|
||||||
self.geschwindigkeit = self.geschwindigkeit - 5
|
|
||||||
|
|
||||||
if self.geschwindigkeit < 0:
|
|
||||||
self.geschwindigkeit = 0
|
|
||||||
|
|
||||||
|
|
||||||
def rammen(self, gegner):
|
|
||||||
self.ramm = self.ramm + 1
|
|
||||||
@@ -1,405 +0,0 @@
|
|||||||
import pygame
|
|
||||||
import math
|
|
||||||
import random
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# PYGAME INITIALISIERUNG
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
pygame.init()
|
|
||||||
|
|
||||||
BREITE = 1200
|
|
||||||
HOEHE = 700
|
|
||||||
|
|
||||||
screen = pygame.display.set_mode((BREITE, HOEHE))
|
|
||||||
pygame.display.set_caption("Kart-Rennsimulation")
|
|
||||||
|
|
||||||
clock = pygame.time.Clock()
|
|
||||||
|
|
||||||
# Farben
|
|
||||||
WEISS = (255, 255, 255)
|
|
||||||
SCHWARZ = (20, 20, 20)
|
|
||||||
GRAU = (100, 100, 100)
|
|
||||||
DUNKELGRAU = (45, 45, 45)
|
|
||||||
GRUEN = (50, 150, 70)
|
|
||||||
ROT = (220, 50, 50)
|
|
||||||
BLAU = (50, 100, 230)
|
|
||||||
GELB = (240, 220, 50)
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# KART-KLASSE
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
class Kart:
|
|
||||||
def __init__(self, name, farbe, v_max, geschw, handling, position, rammen):
|
|
||||||
self.name = name
|
|
||||||
self.farbe = farbe
|
|
||||||
self.v_max = v_max
|
|
||||||
self.geschw = geschw
|
|
||||||
self.handling = handling
|
|
||||||
self.driften_anzahl = 0
|
|
||||||
self.position = position
|
|
||||||
self.rammen_wert = rammen
|
|
||||||
# Pygame-Werte
|
|
||||||
self.x = 0
|
|
||||||
self.y = 0
|
|
||||||
self.winkel = 0
|
|
||||||
|
|
||||||
self.beschleunigungsstaerke = 10
|
|
||||||
self.bremsstaerke = 20
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# BESCHLEUNIGEN
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def beschleunigung(self):
|
|
||||||
self.geschw += 10
|
|
||||||
|
|
||||||
if self.geschw > self.v_max:
|
|
||||||
self.geschw = self.v_max
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# BREMSEN
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def bremsen(self):
|
|
||||||
self.geschw -= 20
|
|
||||||
|
|
||||||
if self.geschw < 0:
|
|
||||||
self.geschw = 0
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# DRIFTEN
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def driften(self):
|
|
||||||
self.driften_anzahl += 1
|
|
||||||
|
|
||||||
self.geschw -= 5
|
|
||||||
|
|
||||||
if self.geschw < 0:
|
|
||||||
self.geschw = 0
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# RAMMEN
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def rammen(self):
|
|
||||||
self.rammen_wert += 1
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# KART ZEICHNEN
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def zeichnen(self, surface):
|
|
||||||
|
|
||||||
breite = 45
|
|
||||||
hoehe = 28
|
|
||||||
|
|
||||||
# Kart als Rechteck erstellen
|
|
||||||
kart_surface = pygame.Surface((breite, hoehe), pygame.SRCALPHA)
|
|
||||||
|
|
||||||
# Farbe bestimmen
|
|
||||||
if self.farbe == "rot":
|
|
||||||
farbe = ROT
|
|
||||||
elif self.farbe == "blau":
|
|
||||||
farbe = BLAU
|
|
||||||
else:
|
|
||||||
farbe = WEISS
|
|
||||||
|
|
||||||
pygame.draw.rect(
|
|
||||||
kart_surface,
|
|
||||||
farbe,
|
|
||||||
(0, 0, breite, hoehe),
|
|
||||||
border_radius=8
|
|
||||||
)
|
|
||||||
|
|
||||||
# Front des Karts
|
|
||||||
pygame.draw.rect(
|
|
||||||
kart_surface,
|
|
||||||
SCHWARZ,
|
|
||||||
(breite - 8, 5, 5, hoehe - 10)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fenster
|
|
||||||
pygame.draw.rect(
|
|
||||||
kart_surface,
|
|
||||||
(80, 180, 220),
|
|
||||||
(15, 5, 14, 18),
|
|
||||||
border_radius=3
|
|
||||||
)
|
|
||||||
|
|
||||||
# Kart drehen
|
|
||||||
gedreht = pygame.transform.rotate(
|
|
||||||
kart_surface,
|
|
||||||
self.winkel
|
|
||||||
)
|
|
||||||
|
|
||||||
rechteck = gedreht.get_rect(
|
|
||||||
center=(self.x, self.y)
|
|
||||||
)
|
|
||||||
|
|
||||||
surface.blit(gedreht, rechteck)
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# BEWEGUNG
|
|
||||||
# -----------------------------------------------------
|
|
||||||
|
|
||||||
def bewegen(self, links, rechts):
|
|
||||||
|
|
||||||
# Handling bestimmt, wie schnell das Kart lenkt
|
|
||||||
lenkgeschwindigkeit = self.handling * 0.08
|
|
||||||
|
|
||||||
if self.geschw > 0:
|
|
||||||
|
|
||||||
if links:
|
|
||||||
self.winkel += lenkgeschwindigkeit
|
|
||||||
|
|
||||||
if rechts:
|
|
||||||
self.winkel -= lenkgeschwindigkeit
|
|
||||||
|
|
||||||
# Geschwindigkeit in Pixel umrechnen
|
|
||||||
bewegung = self.geschw * 0.08
|
|
||||||
|
|
||||||
rad = math.radians(self.winkel)
|
|
||||||
|
|
||||||
self.x += math.cos(rad) * bewegung
|
|
||||||
self.y -= math.sin(rad) * bewegung
|
|
||||||
|
|
||||||
# Begrenzung des Spielfeldes
|
|
||||||
self.x = max(80, min(BREITE - 80, self.x))
|
|
||||||
self.y = max(80, min(HOEHE - 80, self.y))
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# KARTS ERSTELLEN
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
kart1 = Kart(
|
|
||||||
"Magic",
|
|
||||||
"rot",
|
|
||||||
500,
|
|
||||||
100,
|
|
||||||
8,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
)
|
|
||||||
|
|
||||||
kart2 = Kart(
|
|
||||||
"Luigi",
|
|
||||||
"blau",
|
|
||||||
400,
|
|
||||||
120,
|
|
||||||
6,
|
|
||||||
2,
|
|
||||||
1
|
|
||||||
)
|
|
||||||
|
|
||||||
# Startpositionen
|
|
||||||
kart1.x = 300
|
|
||||||
kart1.y = 350
|
|
||||||
kart1.winkel = 0
|
|
||||||
|
|
||||||
kart2.x = 300
|
|
||||||
kart2.y = 430
|
|
||||||
kart2.winkel = 0
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# SCHRIFTEN
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
font_gross = pygame.font.SysFont("Arial", 32, bold=True)
|
|
||||||
font_normal = pygame.font.SysFont("Arial", 22)
|
|
||||||
font_klein = pygame.font.SysFont("Arial", 18)
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# RENNSTRECKE
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
def strecke_zeichnen():
|
|
||||||
|
|
||||||
# Gras
|
|
||||||
screen.fill(GRUEN)
|
|
||||||
|
|
||||||
# Äußerer Straßenbereich
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
DUNKELGRAU,
|
|
||||||
(80, 80, BREITE - 160, HOEHE - 160),
|
|
||||||
border_radius=100
|
|
||||||
)
|
|
||||||
|
|
||||||
# Innerer Bereich
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
GRUEN,
|
|
||||||
(200, 180, BREITE - 400, HOEHE - 360),
|
|
||||||
border_radius=70
|
|
||||||
)
|
|
||||||
|
|
||||||
# Mittellinie
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
(230, 230, 230),
|
|
||||||
(BREITE // 2 - 5, 80, 10, 100)
|
|
||||||
)
|
|
||||||
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
(230, 230, 230),
|
|
||||||
(BREITE // 2 - 5, HOEHE - 180, 10, 100)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Start-/Ziellinie
|
|
||||||
start_x = BREITE // 2 - 5
|
|
||||||
|
|
||||||
for y in range(180, 520, 30):
|
|
||||||
|
|
||||||
if (y // 30) % 2 == 0:
|
|
||||||
farbe = WEISS
|
|
||||||
else:
|
|
||||||
farbe = SCHWARZ
|
|
||||||
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
farbe,
|
|
||||||
(start_x, y, 10, 30)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# INFO-BEREICH
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
def informationen_zeichnen():
|
|
||||||
|
|
||||||
# Hintergrund
|
|
||||||
pygame.draw.rect(
|
|
||||||
screen,
|
|
||||||
(25, 25, 25),
|
|
||||||
(0, 0, BREITE, 60)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Kart 1
|
|
||||||
text1 = font_normal.render(
|
|
||||||
f"{kart1.name}: {int(kart1.geschw)} km/h",
|
|
||||||
True,
|
|
||||||
ROT
|
|
||||||
)
|
|
||||||
|
|
||||||
screen.blit(text1, (20, 18))
|
|
||||||
|
|
||||||
# Kart 2
|
|
||||||
text2 = font_normal.render(
|
|
||||||
f"{kart2.name}: {int(kart2.geschw)} km/h",
|
|
||||||
True,
|
|
||||||
BLAU
|
|
||||||
)
|
|
||||||
|
|
||||||
screen.blit(text2, (270, 18))
|
|
||||||
|
|
||||||
# Drift
|
|
||||||
text3 = font_klein.render(
|
|
||||||
f"Drifts: {kart1.driften_anzahl}",
|
|
||||||
True,
|
|
||||||
WEISS
|
|
||||||
)
|
|
||||||
|
|
||||||
screen.blit(text3, (520, 21))
|
|
||||||
|
|
||||||
text4 = font_klein.render(
|
|
||||||
f"Drifts: {kart2.driften_anzahl}",
|
|
||||||
True,
|
|
||||||
WEISS
|
|
||||||
)
|
|
||||||
|
|
||||||
screen.blit(text4, (650, 21))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def steuerung_zeichnen():
|
|
||||||
|
|
||||||
texte = [
|
|
||||||
"MAGIC: W = Gas | S = Bremse | A/D = Lenken | Leertaste = Drift",
|
|
||||||
"LUIGI: Pfeile = Fahren | R = Drift"
|
|
||||||
]
|
|
||||||
|
|
||||||
y = HOEHE - 65
|
|
||||||
|
|
||||||
for text in texte:
|
|
||||||
|
|
||||||
bild = font_klein.render(
|
|
||||||
text,
|
|
||||||
True,
|
|
||||||
WEISS
|
|
||||||
)
|
|
||||||
|
|
||||||
screen.blit(
|
|
||||||
bild,
|
|
||||||
(20, y)
|
|
||||||
)
|
|
||||||
|
|
||||||
y += 22
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
running = True
|
|
||||||
|
|
||||||
while running:
|
|
||||||
|
|
||||||
clock.tick(60)
|
|
||||||
|
|
||||||
|
|
||||||
for event in pygame.event.get():
|
|
||||||
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
running = False
|
|
||||||
|
|
||||||
keys = pygame.key.get_pressed()
|
|
||||||
|
|
||||||
|
|
||||||
if keys[pygame.K_w]:
|
|
||||||
kart1.beschleunigung()
|
|
||||||
|
|
||||||
if keys[pygame.K_s]:
|
|
||||||
kart1.bremsen()
|
|
||||||
|
|
||||||
if keys[pygame.K_SPACE]:
|
|
||||||
kart1.driften()
|
|
||||||
|
|
||||||
kart1.bewegen(
|
|
||||||
keys[pygame.K_a],
|
|
||||||
keys[pygame.K_d]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if keys[pygame.K_UP]:
|
|
||||||
kart2.beschleunigung()
|
|
||||||
|
|
||||||
if keys[pygame.K_DOWN]:
|
|
||||||
kart2.bremsen()
|
|
||||||
|
|
||||||
if keys[pygame.K_r]:
|
|
||||||
kart2.driften()
|
|
||||||
|
|
||||||
kart2.bewegen(
|
|
||||||
keys[pygame.K_LEFT],
|
|
||||||
keys[pygame.K_RIGHT]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
strecke_zeichnen()
|
|
||||||
|
|
||||||
kart1.zeichnen(screen)
|
|
||||||
kart2.zeichnen(screen)
|
|
||||||
|
|
||||||
informationen_zeichnen()
|
|
||||||
steuerung_zeichnen()
|
|
||||||
|
|
||||||
pygame.display.flip()
|
|
||||||
|
|
||||||
|
|
||||||
pygame.quit()
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
from kart import Kart
|
|
||||||
from items import Items
|
|
||||||
|
|
||||||
kart1 = Kart("Magic", "rot", 500, 100, 8, 1, 1)
|
|
||||||
kart2 = Kart("Luigi", "blau", 400, 120, 6, 2, 1)
|
|
||||||
|
|
||||||
|
|
||||||
turbo = Items("Turbo", 50)
|
|
||||||
bremse = Items("Bremse", 30)
|
|
||||||
|
|
||||||
# Kart 1
|
|
||||||
print(kart1.name, "hat die Farbe", kart1.farbe)
|
|
||||||
|
|
||||||
kart1.beschleunigung()
|
|
||||||
print("Beschleunigen:", kart1.name, "hat jetzt", kart1.geschw, "km/h")
|
|
||||||
|
|
||||||
kart1.bremsen()
|
|
||||||
print("Bremsen:", kart1.name, "hat jetzt", kart1.geschw, "km/h")
|
|
||||||
|
|
||||||
turbo.benutzen(kart1)
|
|
||||||
print("Turbo:", kart1.name, "hat jetzt", kart1.geschw, "km/h")
|
|
||||||
|
|
||||||
# Kart 2
|
|
||||||
|
|
||||||
print(kart2.name, "hat die Farbe", kart2.farbe)
|
|
||||||
|
|
||||||
kart2.beschleunigung()
|
|
||||||
print("Beschleunigen:", kart2.name, "hat jetzt", kart2.geschw, "km/h")
|
|
||||||
|
|
||||||
kart2.bremsen()
|
|
||||||
print("Bremsen:", kart2.name, "hat jetzt", kart2.geschw, "km/h")
|
|
||||||
|
|
||||||
|
|
||||||
bremse.benutzen(kart2)
|
|
||||||
print("Bremse:", kart2.name, "hat jetzt", kart2.geschw, "km/h")
|
|
||||||
Reference in New Issue
Block a user