game-run 1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- game_run-1.0/PKG-INFO +18 -0
- game_run-1.0/README.md +10 -0
- game_run-1.0/game_run/__init__.py +0 -0
- game_run-1.0/game_run/snake.py +184 -0
- game_run-1.0/game_run.egg-info/PKG-INFO +18 -0
- game_run-1.0/game_run.egg-info/SOURCES.txt +9 -0
- game_run-1.0/game_run.egg-info/dependency_links.txt +1 -0
- game_run-1.0/game_run.egg-info/entry_points.txt +2 -0
- game_run-1.0/game_run.egg-info/top_level.txt +1 -0
- game_run-1.0/pyproject.toml +16 -0
- game_run-1.0/setup.cfg +4 -0
game_run-1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: game_run
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: A games playing app
|
|
5
|
+
Author-email: Private <Chonoorasli22@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
only view the source code if you want to see how the games code was generated.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
MIT licence
|
game_run-1.0/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import turtle
|
|
2
|
+
import time
|
|
3
|
+
import random
|
|
4
|
+
from tkinter import *
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# --- Snake Game Logic ---
|
|
8
|
+
def start_snake_game():
|
|
9
|
+
# Set up the screen for the game
|
|
10
|
+
game_screen = turtle.Screen()
|
|
11
|
+
game_screen.title("Snake Game")
|
|
12
|
+
game_screen.bgcolor("black")
|
|
13
|
+
game_screen.setup(width=600, height=600)
|
|
14
|
+
game_screen.tracer(0) # Turns off screen updates for smoother animation
|
|
15
|
+
|
|
16
|
+
# Snake Head
|
|
17
|
+
head = turtle.Turtle()
|
|
18
|
+
head.speed(0)
|
|
19
|
+
head.shape("square")
|
|
20
|
+
head.color("white")
|
|
21
|
+
head.penup()
|
|
22
|
+
head.goto(0, 0)
|
|
23
|
+
head.direction = "stop"
|
|
24
|
+
|
|
25
|
+
# Snake Food
|
|
26
|
+
food = turtle.Turtle()
|
|
27
|
+
food.speed(0)
|
|
28
|
+
food.shape("circle")
|
|
29
|
+
food.color("red")
|
|
30
|
+
food.penup()
|
|
31
|
+
food.goto(0, 100)
|
|
32
|
+
|
|
33
|
+
segments = []
|
|
34
|
+
|
|
35
|
+
# Score display
|
|
36
|
+
score = 0
|
|
37
|
+
high_score = 0
|
|
38
|
+
|
|
39
|
+
score_display = turtle.Turtle()
|
|
40
|
+
score_display.speed(0)
|
|
41
|
+
score_display.shape("square")
|
|
42
|
+
score_display.color("white")
|
|
43
|
+
score_display.penup()
|
|
44
|
+
score_display.hideturtle()
|
|
45
|
+
score_display.goto(0, 260)
|
|
46
|
+
score_display.write("Score: 0 High Score: 0", align="center", font=("Courier", 24, "normal"))
|
|
47
|
+
|
|
48
|
+
# Functions to move the snake
|
|
49
|
+
def go_up():
|
|
50
|
+
if head.direction != "down":
|
|
51
|
+
head.direction = "up"
|
|
52
|
+
|
|
53
|
+
def go_down():
|
|
54
|
+
if head.direction != "up":
|
|
55
|
+
head.direction = "down"
|
|
56
|
+
|
|
57
|
+
def go_left():
|
|
58
|
+
if head.direction != "right":
|
|
59
|
+
head.direction = "left"
|
|
60
|
+
|
|
61
|
+
def go_right():
|
|
62
|
+
if head.direction != "left":
|
|
63
|
+
head.direction = "right"
|
|
64
|
+
|
|
65
|
+
def move():
|
|
66
|
+
if head.direction == "up":
|
|
67
|
+
y = head.ycor()
|
|
68
|
+
head.sety(y + 20)
|
|
69
|
+
if head.direction == "down":
|
|
70
|
+
y = head.ycor()
|
|
71
|
+
head.sety(y - 20)
|
|
72
|
+
if head.direction == "left":
|
|
73
|
+
x = head.xcor()
|
|
74
|
+
head.setx(x - 20)
|
|
75
|
+
if head.direction == "right":
|
|
76
|
+
x = head.xcor()
|
|
77
|
+
head.setx(x + 20)
|
|
78
|
+
|
|
79
|
+
# Keyboard bindings for the game screen
|
|
80
|
+
game_screen.listen()
|
|
81
|
+
game_screen.onkey(go_up, "w")
|
|
82
|
+
game_screen.onkey(go_down, "s")
|
|
83
|
+
game_screen.onkey(go_left, "a")
|
|
84
|
+
game_screen.onkey(go_right, "d")
|
|
85
|
+
# You can also use arrow keys:
|
|
86
|
+
game_screen.onkey(go_up, "Up")
|
|
87
|
+
game_screen.onkey(go_down, "Down")
|
|
88
|
+
game_screen.onkey(go_left, "Left")
|
|
89
|
+
game_screen.onkey(go_right, "Right")
|
|
90
|
+
|
|
91
|
+
# Main Game Loop
|
|
92
|
+
running = True
|
|
93
|
+
while running:
|
|
94
|
+
game_screen.update()
|
|
95
|
+
|
|
96
|
+
# Check for collision with border
|
|
97
|
+
if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290:
|
|
98
|
+
time.sleep(1)
|
|
99
|
+
head.goto(0, 0)
|
|
100
|
+
head.direction = "stop"
|
|
101
|
+
|
|
102
|
+
# Hide segments
|
|
103
|
+
for segment in segments:
|
|
104
|
+
segment.goto(1000, 1000)
|
|
105
|
+
segments.clear()
|
|
106
|
+
|
|
107
|
+
# Reset score
|
|
108
|
+
score = 0
|
|
109
|
+
score_display.clear()
|
|
110
|
+
score_display.write(f"Score: {score} High Score: {high_score}", align="center",
|
|
111
|
+
font=("Courier", 24, "normal"))
|
|
112
|
+
|
|
113
|
+
# Check for collision with food
|
|
114
|
+
if head.distance(food) < 20:
|
|
115
|
+
# Move food to random spot
|
|
116
|
+
x = random.randint(-270, 270)
|
|
117
|
+
y = random.randint(-270, 270)
|
|
118
|
+
food.goto(x, y)
|
|
119
|
+
|
|
120
|
+
# Add a segment to the snake
|
|
121
|
+
new_segment = turtle.Turtle()
|
|
122
|
+
new_segment.speed(0)
|
|
123
|
+
new_segment.shape("square")
|
|
124
|
+
new_segment.color("grey")
|
|
125
|
+
new_segment.penup()
|
|
126
|
+
segments.append(new_segment)
|
|
127
|
+
|
|
128
|
+
# Increase score
|
|
129
|
+
score += 10
|
|
130
|
+
if score > high_score:
|
|
131
|
+
high_score = score
|
|
132
|
+
score_display.clear()
|
|
133
|
+
score_display.write(f"Score: {score} High Score: {high_score}", align="center",
|
|
134
|
+
font=("Courier", 24, "normal"))
|
|
135
|
+
|
|
136
|
+
# Move the end segments first in reverse order
|
|
137
|
+
for index in range(len(segments) - 1, 0, -1):
|
|
138
|
+
x = segments[index - 1].xcor()
|
|
139
|
+
y = segments[index - 1].ycor()
|
|
140
|
+
segments[index].goto(x, y)
|
|
141
|
+
|
|
142
|
+
# Move segment 0 to where the head is
|
|
143
|
+
if len(segments) > 0:
|
|
144
|
+
x = head.xcor()
|
|
145
|
+
y = head.ycor()
|
|
146
|
+
segments[0].goto(x, y)
|
|
147
|
+
|
|
148
|
+
move()
|
|
149
|
+
|
|
150
|
+
# Check for head collision with body segments
|
|
151
|
+
for segment in segments:
|
|
152
|
+
if segment.distance(head) < 20:
|
|
153
|
+
time.sleep(1)
|
|
154
|
+
head.goto(0, 0)
|
|
155
|
+
head.direction = "stop"
|
|
156
|
+
|
|
157
|
+
for seg in segments:
|
|
158
|
+
seg.goto(1000, 1000)
|
|
159
|
+
segments.clear()
|
|
160
|
+
|
|
161
|
+
score = 0
|
|
162
|
+
score_display.clear()
|
|
163
|
+
score_display.write(f"Score: {score} High Score: {high_score}", align="center",
|
|
164
|
+
font=("Courier", 24, "normal"))
|
|
165
|
+
|
|
166
|
+
time.sleep(0.1)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# --- Tkinter Main Menu Window ---
|
|
170
|
+
root = Tk()
|
|
171
|
+
root.title("Arcade Hub")
|
|
172
|
+
root.geometry("400x300")
|
|
173
|
+
root.config(bg="#222222")
|
|
174
|
+
|
|
175
|
+
# Title Label
|
|
176
|
+
title_label = Label(root, text="🐍 SNAKE ARCADE 🐍", font=("Arial", 18, "bold"), fg="white", bg="#222222")
|
|
177
|
+
title_label.pack(pady=40)
|
|
178
|
+
|
|
179
|
+
# Play Button that calls the snake game function
|
|
180
|
+
play_btn = Button(root, text="Play Snake", font=("Arial", 14), bg="green", fg="white", command=start_snake_game)
|
|
181
|
+
play_btn.pack(pady=10)
|
|
182
|
+
|
|
183
|
+
# Start the Tkinter loop
|
|
184
|
+
root.mainloop()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: game_run
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: A games playing app
|
|
5
|
+
Author-email: Private <Chonoorasli22@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
only view the source code if you want to see how the games code was generated.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
MIT licence
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
game_run
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "game_run"
|
|
7
|
+
version = "1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Private", email="Chonoorasli22@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "A games playing app"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
snake_game = "game_run.snake:start_snake_game"
|
game_run-1.0/setup.cfg
ADDED