Add files via upload
This commit is contained in:
parent
deb4fcc069
commit
a7808f6aac
28 changed files with 1571 additions and 3 deletions
42
examples/game.py
Normal file
42
examples/game.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from random import randint
|
||||
import pygwin as pgw
|
||||
|
||||
win = pgw.create('Game Example', (500,500))
|
||||
|
||||
player = [250,250]
|
||||
apple = pgw.rect(randint(0,490),randint(0,490),20,20)
|
||||
count = 0
|
||||
|
||||
run = True
|
||||
while run:
|
||||
for event in pgw.getEvents():
|
||||
if event.type == pgw.QUIT:
|
||||
run = False
|
||||
win.fill((255,255,255))
|
||||
playerRect = pgw.rect(player[0]-10,player[1]-10,20,20)
|
||||
win.draw.rect((0,0,0),playerRect)
|
||||
win.draw.rect((200,50,50),apple)
|
||||
win.blit(count,(0,0))
|
||||
if pgw.keyboard.isPressed('w'):
|
||||
player[1] -= 5
|
||||
if pgw.keyboard.isPressed('s'):
|
||||
player[1] += 5
|
||||
if pgw.keyboard.isPressed('d'):
|
||||
player[0] += 5
|
||||
if pgw.keyboard.isPressed('a'):
|
||||
player[0] -= 5
|
||||
|
||||
if player[0] <= -10:
|
||||
player[0] = 510
|
||||
if player[1] <= -10:
|
||||
player[1] = 510
|
||||
if player[0] > 510:
|
||||
player[0] = -10
|
||||
if player[1] > 510:
|
||||
player[1] = -10
|
||||
|
||||
if playerRect.collide(apple):
|
||||
apple = pgw.rect(randint(0,490),randint(0,490),20,20)
|
||||
count += 1
|
||||
win.update(60)
|
||||
pgw.close()
|
38
examples/ui.py
Normal file
38
examples/ui.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import pygwin
|
||||
|
||||
win = pygwin.create('UI Example',(270,350))
|
||||
base = pygwin.ui.base(win)
|
||||
|
||||
lbl = pygwin.ui.label('Label')
|
||||
base.put(lbl,(130-(lbl.surface.size[0]/2),10))
|
||||
base.put(pygwin.ui.button('Button',width=250),(10,50))
|
||||
base.put(pygwin.ui.entry('Entry',width=123),(10,100))
|
||||
base.put(pygwin.ui.keySelect('Key',width=122),(138,100))
|
||||
loadbar = pygwin.ui.loadingBar(250,25)
|
||||
base.put(loadbar,(10,150))
|
||||
slider = pygwin.ui.slider(250)
|
||||
base.put(slider,(10,170))
|
||||
cb = pygwin.ui.checkBox(25,borderWidth=2)
|
||||
base.put(cb,(10,220))
|
||||
base.put(pygwin.ui.label('Checkbox',20),(45,225))
|
||||
ta = pygwin.ui.textarea('Textarea',width=250,maxSymbols=20)
|
||||
ta.text += '0123456789\n0123456789'
|
||||
ta.focus = True
|
||||
ta._generate()
|
||||
ta.focus = False
|
||||
base.put(ta,(10,255))
|
||||
|
||||
run = True
|
||||
while run:
|
||||
for event in pygwin.getEvents():
|
||||
if event.type == pygwin.QUIT:
|
||||
run = False
|
||||
base.draw()
|
||||
if cb.get():
|
||||
loadbar.set(slider.get())
|
||||
else:
|
||||
loadbar.step()
|
||||
if loadbar.get() == loadbar.length:
|
||||
loadbar.set(0)
|
||||
win.update(30)
|
||||
pygwin.close()
|
Loading…
Add table
Add a link
Reference in a new issue