Compare commits
No commits in common. "main" and "master" have entirely different histories.
3 changed files with 283 additions and 165 deletions
162
.gitignore
vendored
162
.gitignore
vendored
|
@ -1,162 +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
|
||||
|
||||
# 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/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# 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/
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# pinpong
|
||||
|
||||
репозиторий для зачета
|
283
solo_S.py
Normal file
283
solo_S.py
Normal file
|
@ -0,0 +1,283 @@
|
|||
from tkinter import *
|
||||
import time
|
||||
import random
|
||||
|
||||
'''
|
||||
class Meteor():
|
||||
|
||||
def __init__(self, canvas, platform, color ):
|
||||
self.score = score
|
||||
self.canvas = canvas
|
||||
self.platform = platform
|
||||
|
||||
self.oval = canvas.create_rectangle(360, 600, 530, 620, fill=color)
|
||||
self.dir = [-6,-5,-4,-3, -2, -1, 1, 2, 3,4]
|
||||
self.x = random.choice(self.dir)
|
||||
self.y = -1
|
||||
'''
|
||||
class Ball():
|
||||
|
||||
def __init__(self, canvas, platform,platform2, color, score):
|
||||
self.score = score
|
||||
self.canvas = canvas
|
||||
self.platform = platform
|
||||
self.platform2 = platform2
|
||||
self.oval = canvas.create_oval(500, 300, 515, 315, fill=color)
|
||||
self.dir = [-6,-5,-4,-3, -2, -1, 1, 2, 3,4]
|
||||
self.x = random.choice(self.dir)
|
||||
self.y = random.choice(self.dir)
|
||||
self.touch_bottom = False
|
||||
|
||||
def touch_platform(self, ball_pos):
|
||||
platform_pos = self.canvas.coords(self.platform2.rect2)
|
||||
platform_pos2 = self.canvas.coords(self.platform.rect)
|
||||
if ball_pos[2] >= platform_pos[0] and ball_pos[0] <= platform_pos[2] or ball_pos[2] >= platform_pos2[0] and ball_pos[0] <= platform_pos2[2]:
|
||||
if ball_pos[3] >= platform_pos[1] and ball_pos[3] <= platform_pos[3] or ball_pos[3] >= platform_pos2[1] and ball_pos[3] <= platform_pos2[3]:
|
||||
self.score.hit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def draw(self):
|
||||
self.canvas.move(self.oval, self.x, self.y)
|
||||
pos = self.canvas.coords(self.oval)
|
||||
if pos[1] <= 0:
|
||||
self.y = 5
|
||||
if pos[3] >= 800:
|
||||
self.touch_bottom = True
|
||||
if self.touch_platform(pos) == True:
|
||||
self.y = -5
|
||||
if pos[0] <= 0:
|
||||
self.x = 5
|
||||
if pos[2] >= 1089:
|
||||
self.x = -5
|
||||
class Platform2():
|
||||
def __init__(self,canvas,color,window):
|
||||
self. window = window
|
||||
self.canvas = canvas
|
||||
self.rect2 = canvas.create_rectangle(0, 0, 0, 0, fill=color)
|
||||
self.x = 0
|
||||
|
||||
self.canvas.bind_all('<d>', self.right)
|
||||
self.canvas.bind_all('<a>', self.down)
|
||||
self.canvas.bind_all('<D>', self.right)
|
||||
self.canvas.bind_all('<A>', self.down)
|
||||
self.canvas.bind_all('<s>', self.stop)
|
||||
self.canvas.bind_all('<S>', self.stop)
|
||||
def down(self, event):
|
||||
self.x = -10
|
||||
def right(self, event):
|
||||
self.x = 10
|
||||
def stop(self, event):
|
||||
self.x = 0
|
||||
def draw(self):
|
||||
self.canvas.move(self.rect2, self.x, 0)
|
||||
pos=self.canvas.coords(self.rect2)
|
||||
if pos[0] <= 0:
|
||||
self.x = 0 #19
|
||||
if pos[2] >= 1089:
|
||||
|
||||
self.x = 0 #-19
|
||||
|
||||
class Platform():
|
||||
|
||||
def __init__(self, canvas, color,window):
|
||||
|
||||
self.window= window
|
||||
self.canvas = canvas
|
||||
self.rect = canvas.create_rectangle(460, 600, 630, 620, fill=color)
|
||||
self.x = 0
|
||||
self.new_canvas= Canvas(master=self.window, width=1089, height=800, bg='black')
|
||||
self.canvas.bind_all('<KeyPress-Left>', self.left)
|
||||
self.canvas.bind_all('<KeyPress-Right>', self.right)
|
||||
self.canvas.bind_all('<KeyPress-Down>', self.down)
|
||||
def down(self, event):
|
||||
self.x = 0
|
||||
def left(self, event):
|
||||
self.x = -10
|
||||
|
||||
def right(self, event):
|
||||
self.x = 10
|
||||
|
||||
def draw(self):
|
||||
self.canvas.move(self.rect, self.x, 0)
|
||||
pos=self.canvas.coords(self.rect)
|
||||
if pos[0] <= 0:
|
||||
self.x = 0 #19
|
||||
if pos[2] >= 1089:
|
||||
|
||||
self.x = 0 #-19
|
||||
|
||||
def game_over(self):
|
||||
#self.timer_stop=True
|
||||
self.canvas.destroy()
|
||||
self.new_canvas.create_text((220,230), font=('consolas',50),text='GAME OVER',fill='red',tag='gameover')
|
||||
self.new_canvas.pack()
|
||||
self.ok_button= Button(self.new_canvas,text='restart',width=10, font=('Tahoma', 30),command= self.show_start_frame)
|
||||
self.ok_button.pack(pady=75, padx=100,anchor='nw')
|
||||
self.exit_button= Button(self.new_canvas,text='exit',width=10, font=('Tahoma', 30),command= self.exit_game)
|
||||
self.exit_button.pack(pady=75, padx=100,anchor='nw')
|
||||
def exit_game(self):
|
||||
window.destroy()
|
||||
|
||||
|
||||
def show_start_frame(self):
|
||||
|
||||
self.new_canvas.destroy()
|
||||
self.ok_button.destroy()
|
||||
self.exit_button.destroy()
|
||||
|
||||
canvas = Canvas(window, width=1089, height=800, bg='#E8EDE7')
|
||||
canvas.pack()
|
||||
|
||||
|
||||
|
||||
k1 = block(canvas, '#81BECE', window, 0,33)
|
||||
k4 = block(canvas, '#81BECE', window, 99,132)
|
||||
k4 = block(canvas, '#81BECE', window, 198,231)
|
||||
k7 = block(canvas, '#81BECE', window, 330,363)
|
||||
k7 = block(canvas, '#81BECE', window, 363,396)
|
||||
k7 = block(canvas, '#81BECE', window, 462,495)
|
||||
score = Score(canvas,'green')
|
||||
platform = Platform(canvas, '#244343',window)
|
||||
platform2 = Platform2(canvas, 'royalblue',window)
|
||||
ball = Ball(canvas, platform, platform2,'#434444',score)
|
||||
|
||||
k2 = block(canvas, '#036280', window, 33,66)
|
||||
k3 = block(canvas, '#2A3759', window, 66,99)
|
||||
k5 = block(canvas, '#2A3759', window, 132,165)
|
||||
k6 = block(canvas, '#036280', window, 165,198)
|
||||
|
||||
k8 = block(canvas, '#012E4A', window, 231,264)
|
||||
k8 = block(canvas, '#012E4A', window, 264,297)
|
||||
k8 = block(canvas, '#012E4A', window, 297,330)
|
||||
k7 = block(canvas, '#2A3759', window, 396,429)
|
||||
k7 = block(canvas, '#2A3759', window, 429,462)
|
||||
k7 = block(canvas, '#036280', window, 495,528)
|
||||
|
||||
|
||||
|
||||
|
||||
while True:
|
||||
if ball.touch_bottom == False :
|
||||
ball.draw()
|
||||
|
||||
platform.draw()
|
||||
platform2.draw()
|
||||
|
||||
else:
|
||||
|
||||
platform.game_over()
|
||||
print('hi')
|
||||
break
|
||||
|
||||
window.update()
|
||||
time.sleep(0.00000000000000000000000000000000000000000000000000551)
|
||||
|
||||
window.mainloop()
|
||||
|
||||
|
||||
class Score():
|
||||
def __init__(self, canvas, color):
|
||||
self.score = 0
|
||||
self.canvas = canvas
|
||||
self.id = canvas.create_text(1000, 700, text=self.score, font=('Tahoma', 35), fill=color)
|
||||
def hit(self):
|
||||
self.score += 1
|
||||
self.canvas.itemconfig(self.id, text=self.score)
|
||||
|
||||
'''
|
||||
class Information():
|
||||
def __init__(self,Platform):
|
||||
self.Platform = Platform
|
||||
self.game_time = 0
|
||||
def update_info(game_time):
|
||||
text_info = ('вы выживали:'+str(game_time))
|
||||
print(text_info)
|
||||
|
||||
|
||||
'''
|
||||
class bonus():
|
||||
pass
|
||||
class block():
|
||||
def __init__(self, canvas, color,platform,y1,y2):
|
||||
x1n = 0
|
||||
|
||||
x2n = 33
|
||||
|
||||
self.platform = platform
|
||||
self.canvas = canvas
|
||||
m= []
|
||||
k=33
|
||||
|
||||
for i in range(k):
|
||||
x1 = x1n+33*i
|
||||
x2 = x2n+33*i
|
||||
self.rect = canvas.create_rectangle(x1,y1,x2,y2, fill=color)
|
||||
|
||||
def newblocks(self):
|
||||
pass
|
||||
|
||||
|
||||
def creates():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
window = Tk()
|
||||
window.title("Аркада")
|
||||
window.resizable(0, 0)
|
||||
window.wm_attributes("-topmost", 1)
|
||||
|
||||
|
||||
|
||||
canvas = Canvas(window, width=1089, height=800, bg='#E8EDE7')
|
||||
canvas.pack()
|
||||
|
||||
k1 = block(canvas, '#81BECE', window, 0,33)
|
||||
k4 = block(canvas, '#81BECE', window, 99,132)
|
||||
k4 = block(canvas, '#81BECE', window, 198,231)
|
||||
k7 = block(canvas, '#81BECE', window, 330,363)
|
||||
k7 = block(canvas, '#81BECE', window, 363,396)
|
||||
k7 = block(canvas, '#81BECE', window, 462,495)
|
||||
score = Score(canvas,'green')
|
||||
platform = Platform(canvas, '#244343',window)
|
||||
platform2 = Platform2(canvas, 'royalblue',window)
|
||||
ball = Ball(canvas, platform, platform2,'#434444',score)
|
||||
|
||||
k2 = block(canvas, '#036280', window, 33,66)
|
||||
k3 = block(canvas, '#2A3759', window, 66,99)
|
||||
k5 = block(canvas, '#2A3759', window, 132,165)
|
||||
k6 = block(canvas, '#036280', window, 165,198)
|
||||
|
||||
k8 = block(canvas, '#012E4A', window, 231,264)
|
||||
k8 = block(canvas, '#012E4A', window, 264,297)
|
||||
k8 = block(canvas, '#012E4A', window, 297,330)
|
||||
k7 = block(canvas, '#2A3759', window, 396,429)
|
||||
k7 = block(canvas, '#2A3759', window, 429,462)
|
||||
k7 = block(canvas, '#036280', window, 495,528)
|
||||
#meteor = Meteor(canvas, platform, 'red')
|
||||
while True:
|
||||
if ball.touch_bottom == False:
|
||||
|
||||
ball.draw()
|
||||
|
||||
platform.draw()
|
||||
platform2.draw()
|
||||
|
||||
|
||||
else:
|
||||
|
||||
platform.game_over()
|
||||
print('hi')
|
||||
break
|
||||
|
||||
window.update()
|
||||
time.sleep(0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001)
|
||||
|
||||
window.mainloop()
|
Loading…
Reference in a new issue