-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpygameplus.py
More file actions
102 lines (77 loc) · 2.29 KB
/
pygameplus.py
File metadata and controls
102 lines (77 loc) · 2.29 KB
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
import os
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "PYGAME_HIDE_SUPPORT_PROMPT"
import pygame
import sys
class none_Node:
def __init__(self):
self.pre = None
self.next = None
class Node(none_Node):
def __init__(self, surface):
self.surface = surface
super().__init__()
class line(Node):
def __init__(self, surf, color, start, end, width=1):
self.color = color
self.start = start
self.end = end
self.width = width
super().__init__(surf)
def show(self):
pygame.draw.line(self.surface, self.color, self.start, self.end, self.width)
class rect(Node):
def __init__(self, surf, color, rect):
self.rect = rect
self.color = color
super().__init__(surf)
def show(self):
pygame.draw.rect(self.surface, self.color, self.rect)
class circle(Node):
def __init__(self, surf, color, center, radius):
self.color = color
self.center = center
self.radius = radius
super().__init__(surf)
def show(self):
pygame.draw.circle(self.surface, self.color, self.center, self.radius)
def connect(a: none_Node, b: none_Node):
a.next = b
b.pre = a
class linklist:
def __init__(self, surface):
self.head = none_Node()
self.end = none_Node()
self.head.next = self.end
self.end.pre = self.head
self.surface = surface
def isempty(self):
return self.head.next is self.end
# 尾插
def append(self, node):
connect(self.end.pre, node)
connect(node, self.end)
def pop(self):
if not self.isempty():
n1 = self.end.pre
connect(self.end.pre.pre, self.end)
del n1
def clear(self):
connect(self.head, self.end)
def print(self):
if self.isempty():
print("empty!!!")
else:
node = self.head
while node.next.next != self.end:
node = node.next
print(node.rect, end='->')
print(node.next.rect)
def show(self):
if self.isempty():
# print("empty!!!")
pass
else:
node = self.head
while node.next != self.end:
node = node.next
node.show()