Add buttons
parent
9a955a4b04
commit
dab37014f6
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -0,0 +1,117 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="210mm"
|
||||||
|
height="297mm"
|
||||||
|
viewBox="0 0 210 297"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:export-filename="/home/gdott9/button-down.png"
|
||||||
|
inkscape:export-xdpi="86.850769"
|
||||||
|
inkscape:export-ydpi="86.850769"
|
||||||
|
inkscape:version="0.92.2 5c3e80d, 2017-08-06"
|
||||||
|
sodipodi:docname="button.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient4606"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<stop
|
||||||
|
id="stop4614"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#ffffff;stop-opacity:0.99215686" />
|
||||||
|
<stop
|
||||||
|
id="stop4616"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#eff0e2;stop-opacity:1" />
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient4606"
|
||||||
|
id="radialGradient4621"
|
||||||
|
cx="92.216034"
|
||||||
|
cy="194.89232"
|
||||||
|
fx="92.216034"
|
||||||
|
fy="194.89232"
|
||||||
|
r="73.13839"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(1,0,0,0.50925674,4.7029769e-7,89.450093)" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.7"
|
||||||
|
inkscape:cx="-4.9635811"
|
||||||
|
inkscape:cy="708.90416"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:snap-bbox="true"
|
||||||
|
inkscape:bbox-paths="true"
|
||||||
|
inkscape:bbox-nodes="true"
|
||||||
|
inkscape:snap-bbox-edge-midpoints="true"
|
||||||
|
inkscape:snap-bbox-midpoints="true"
|
||||||
|
inkscape:object-paths="true"
|
||||||
|
inkscape:snap-intersection-paths="true"
|
||||||
|
inkscape:snap-smooth-nodes="true"
|
||||||
|
inkscape:snap-midpoints="true"
|
||||||
|
inkscape:snap-object-midpoints="true"
|
||||||
|
inkscape:snap-center="true"
|
||||||
|
inkscape:snap-grids="true"
|
||||||
|
inkscape:snap-to-guides="true"
|
||||||
|
inkscape:snap-page="false"
|
||||||
|
inkscape:window-width="1916"
|
||||||
|
inkscape:window-height="1041"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="18"
|
||||||
|
inkscape:window-maximized="0">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid3705" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<circle
|
||||||
|
id="path3699"
|
||||||
|
cx="93.538948"
|
||||||
|
cy="132.38187"
|
||||||
|
r="71.815475"
|
||||||
|
style="fill:url(#radialGradient4621);fill-opacity:1;stroke:#000000;stroke-width:2.64583325;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.5;paint-order:stroke fill markers"
|
||||||
|
inkscape:export-xdpi="86.850769"
|
||||||
|
inkscape:export-ydpi="86.850769" />
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:0.2;stroke:none;stroke-width:10;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.5;paint-order:stroke fill markers"
|
||||||
|
d="M 353.5332 228.91211 A 271.42857 271.42857 0 0 0 82.103516 500.3418 A 271.42857 271.42857 0 0 0 82.228516 503.85352 A 271.42857 271.42857 0 0 1 353.5332 234.91211 A 271.42857 271.42857 0 0 1 624.83594 502.82812 A 271.42857 271.42857 0 0 0 624.96094 500.3418 A 271.42857 271.42857 0 0 0 353.5332 228.91211 z "
|
||||||
|
id="circle4529"
|
||||||
|
transform="scale(0.26458333)"
|
||||||
|
inkscape:export-xdpi="86.850769"
|
||||||
|
inkscape:export-ydpi="86.850769" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.0 KiB |
|
@ -12,31 +12,50 @@ screen = pygame.display.set_mode(size)
|
||||||
|
|
||||||
screen.fill(background)
|
screen.fill(background)
|
||||||
|
|
||||||
button = pygame.Rect(200, 200, 50, 50)
|
button_size = int(screen.get_width() / 4)
|
||||||
screen.fill((0,0,0), rect=button)
|
|
||||||
|
|
||||||
button2 = pygame.Rect(400, 200, 50, 50)
|
button_up = pygame.image.load('button-up.png').convert_alpha()
|
||||||
screen.fill((0,0,0), rect=button2)
|
button_up = pygame.transform.smoothscale(button_up, (button_size, button_size))
|
||||||
|
button_down = pygame.image.load('button-down.png').convert_alpha()
|
||||||
|
button_down = pygame.transform.smoothscale(button_down, (button_size, button_size))
|
||||||
|
button_up_rect = button_up.get_rect()
|
||||||
|
button_up_rect.topleft = screen.get_width() - button_size - 20, screen.get_height() / 2 - button_size / 2
|
||||||
|
|
||||||
pygame.display.flip()
|
button2 = pygame.Rect(screen.get_width() - 70, 100, 50, 50)
|
||||||
|
|
||||||
i = 0
|
camera = pygame.Rect(20, 20, screen.get_width() - screen.get_width() / 4 - 60, screen.get_height() - 40)
|
||||||
|
|
||||||
font = pygame.font.Font(None, 80)
|
font = pygame.font.Font(None, 80)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
pressed = False
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type in (pygame.QUIT, pygame.KEYDOWN):
|
if event.type in (pygame.QUIT, pygame.KEYDOWN):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
elif event.type == pygame.MOUSEBUTTONDOWN:
|
||||||
|
if button_up_rect.collidepoint(pygame.mouse.get_pos()):
|
||||||
|
pressed = True
|
||||||
elif event.type == pygame.MOUSEBUTTONUP:
|
elif event.type == pygame.MOUSEBUTTONUP:
|
||||||
if button.collidepoint(pygame.mouse.get_pos()):
|
if button_up_rect.collidepoint(pygame.mouse.get_pos()):
|
||||||
|
pressed = False
|
||||||
i += 1
|
i += 1
|
||||||
if button2.collidepoint(pygame.mouse.get_pos()):
|
if button2.collidepoint(pygame.mouse.get_pos()):
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
screen.fill(background)
|
||||||
|
|
||||||
|
screen.fill((0,0,0), rect=button2)
|
||||||
|
screen.fill((0,0,0), rect=camera)
|
||||||
|
|
||||||
text = str(i)
|
text = str(i)
|
||||||
size = font.size(text)
|
size = font.size(text)
|
||||||
ren = font.render(text, 0, (0, 0, 0))
|
ren = font.render(text, 0, (255, 255, 0))
|
||||||
screen.fill(background, rect=((10,10),size))
|
screen.blit(ren, (40, 40))
|
||||||
screen.blit(ren, (10, 10))
|
|
||||||
pygame.display.update(((10,10),size))
|
|
||||||
|
if pressed:
|
||||||
|
screen.blit(button_down, button_up_rect)
|
||||||
|
else:
|
||||||
|
screen.blit(button_up, button_up_rect)
|
||||||
|
pygame.display.flip()
|
||||||
|
|
Loading…
Reference in New Issue