コード例 #1
0
ファイル: poly.py プロジェクト: 602p/spacegame
#!/usr/bin/env python
from sys import path
import os.path
thisrep = os.path.dirname(os.path.abspath(__file__))
path.append(os.path.dirname(thisrep))
from random import randint
from pygame import *
from pygame import gfxdraw
from EasyGame import pathgetter, confirm

controls = """hold the left mouse button to draw

d = undo
s = save"""
scr = display.set_mode((800, 800))
confirm(controls, fontsize=14, mode=1)
a = []
c = []
color = [randint(0, 255) for i in (1, 2, 3)] + [50]

while 1:
    ev = event.wait()
    if ev.type == MOUSEBUTTONDOWN and ev.button == 1:
        a.append([ev.pos])
        c.append(color)
    if ev.type == MOUSEMOTION and ev.buttons[0]:
        a[-1].append(ev.pos)
        if len(a[-1]) >= 2:
            draw.aaline(scr, color, a[-1][-1], a[-1][-2], 1)
            display.flip()
    if ev.type == MOUSEBUTTONUP and ev.button == 1:
コード例 #2
0
ファイル: confirm.py プロジェクト: 602p/spacegame
# -*- coding: utf-8 -*-
#!/usr/bin/env python
from sys import path
import os.path
thisrep = os.path.dirname(os.path.abspath(__file__))
path.append(os.path.dirname(thisrep))




from EasyGame import confirm

label = """<centered <+b>this <+u>is<-b> <+i>a test<-u> with <-i>mode =%i >"""

r = confirm(label%1,fontsize=16,width=660,mode=1,fgcolor=(200,100,10),bgcolor=(20,20,20))
r = confirm(label%2+'\nyou have clicked '+{True:'valid',False:'cancel',None:'back'}[r],'Confirm Example',fontsize=16,width=360,mode=2)
r = confirm(label%3+'\nyou have clicked '+{True:'valid',False:'cancel',None:'back'}[r],'Confirm Example',fontsize=16,width=360,mode=3)
confirm('you have clicked '+{True:'valid',False:'cancel',None:'back'}[r]+'\nnow quit','Confirm Example',fontsize=16,width=360,mode=1)
コード例 #3
0
ファイル: poly.py プロジェクト: jsnlm/Python_Ball_Game_Suite
from sys import path
import os.path

thisrep = os.path.dirname(os.path.abspath(__file__))
path.append(os.path.dirname(thisrep))
from random import randint
from pygame import *
from pygame import gfxdraw
from EasyGame import pathgetter, confirm

controls = """hold the left mouse button to draw

d = undo
s = save"""
scr = display.set_mode((800, 800))
confirm(controls, fontsize=14, mode=1)
a = []
c = []
color = [randint(0, 255) for i in (1, 2, 3)] + [50]

while 1:
    ev = event.wait()
    if ev.type == MOUSEBUTTONDOWN and ev.button == 1:
        a.append([ev.pos])
        c.append(color)
    if ev.type == MOUSEMOTION and ev.buttons[0]:
        a[-1].append(ev.pos)
        if len(a[-1]) >= 2:
            draw.aaline(scr, color, a[-1][-1], a[-1][-2], 1)
            display.flip()
    if ev.type == MOUSEBUTTONUP and ev.button == 1: