GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Source-Code-from-Tutorials/Pygame/90_PythonGameDevelopment.py at master · ToJen/Source-Code-from-Tutorials

Expand file tree

/

90_PythonGameDevelopment.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
169 lines (107 loc) · 4.01 KB
/

90_PythonGameDevelopment.py

Copy path

File metadata and controls

169 lines (107 loc) · 4.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import pygame
import time
import random
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('3d')
white = (255,255,255)
black = (0,0,0)
red = (200,0,0)
light_red = (255,0,0)
yellow = (200,200,0)
light_yellow = (255,255,0)
green = (34,177,76)
light_green = (0,255,0)
clock = pygame.time.Clock()
smallfont = pygame.font.SysFont("comicsansms", 25)
medfont = pygame.font.SysFont("comicsansms", 50)
largefont = pygame.font.SysFont("comicsansms", 85)
FPS = 30
def cube(startPoint, fullSize):
node_1 = [startPoint[0], startPoint[1]]
node_2 = [startPoint[0]+fullSize, startPoint[1]]
node_3 = [startPoint[0], startPoint[1]+fullSize]
node_4 = [startPoint[0]+fullSize, startPoint[1]+fullSize]
offset = int(fullSize / 2)
x_mid = int(display_width / 2)
x_offset = -1* int(startPoint[0]-x_mid)
y_mid = int(display_height / 2)
y_offset = int(startPoint[1] - y_mid)
if x_offset < -100:
x_offset = -100
elif x_offset > 100:
x_offset = 100
node_5 = [node_1[0]+x_offset, node_1[1]-y_offset]
node_6 = [node_2[0]+x_offset, node_2[1]-y_offset]
node_7 = [node_3[0]+x_offset, node_3[1]-y_offset]
node_8 = [node_4[0]+x_offset, node_4[1]-y_offset]
# top line #
pygame.draw.line(gameDisplay, white, (node_1),(node_2))
# bottom line #
pygame.draw.line(gameDisplay, white, (node_3),(node_4))
# left line #
pygame.draw.line(gameDisplay, white, (node_1),(node_3))
# right line #
pygame.draw.line(gameDisplay, white, (node_2),(node_4))
# top line #
pygame.draw.line(gameDisplay, white, (node_5),(node_6))
# bottom line #
pygame.draw.line(gameDisplay, white, (node_7),(node_8))
# left line #
pygame.draw.line(gameDisplay, white, (node_5),(node_7))
# right line #
pygame.draw.line(gameDisplay, white, (node_6),(node_8))
pygame.draw.circle(gameDisplay, light_green, node_1, 5)
pygame.draw.circle(gameDisplay, light_green, node_2, 5)
pygame.draw.circle(gameDisplay, light_green, node_3, 5)
pygame.draw.circle(gameDisplay, light_green, node_4, 5)
pygame.draw.circle(gameDisplay, light_green, node_5, 5)
pygame.draw.circle(gameDisplay, light_green, node_6, 5)
pygame.draw.circle(gameDisplay, light_green, node_7, 5)
pygame.draw.circle(gameDisplay, light_green, node_8, 5)
pygame.draw.line(gameDisplay, white, (node_1),(node_5))
pygame.draw.line(gameDisplay, white, (node_2),(node_6))
pygame.draw.line(gameDisplay, white, (node_3),(node_7))
pygame.draw.line(gameDisplay, white, (node_4),(node_8))
def gameLoop():
location = [300,200]
size = 100
current_move = 0
z_move = 0
z_location = 50
y_move = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
current_move = -5
elif event.key == pygame.K_RIGHT:
current_move = 5
elif event.key == pygame.K_UP:
y_move = -5
elif event.key == pygame.K_DOWN:
y_move = 5
elif event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
current_move = 0
if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
y_move = 0
#current_move = 0
gameDisplay.fill(black)
if z_location > 200:
z_move = 0
z_location += z_move
current_size = size
location[0] += current_move
location[1] += y_move
cube(location, current_size)
pygame.display.update()
clock.tick(FPS)
pygame.quit()
quit()
gameLoop()
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.