Exemplo n.º 1
0
            if t is None: continue
            if test(t, CurrentDigit):
                screen.blit(_ok, (px, py))
            else:
                screen.blit(_cross, (px, py))

    if evt.isMouseHit(evt.MOUSE_LEFT):
        if wRect.collidepoint(evt.getMousePos()):
            wsx, wsy = world.getShift()
            x, y = getTerrainByPos(
                *[terrain] +
                [evt.getMousePos()[0] +
                 wsx, evt.getMousePos()[1] + wsy] + list(wOffset))
            t = terrain.getProperty_s(x, y)
            if t is not None:
                li = rgine.int2bool(t)
                li[CurrentDigit] = not li[CurrentDigit]
                terrain.setProperty(x, y, rgine.bool2int(li))

    if evt.isMouseHit(evt.MOUSE_SCROLL_UP) and evt.isKeyDown(pygame.K_LSHIFT):
        if wRect.collidepoint(evt.getMousePos()):
            world.shiftH(-textureSize)

    elif evt.isMouseHit(evt.MOUSE_SCROLL_UP):
        if wRect.collidepoint(evt.getMousePos()):
            world.shiftV(-textureSize)

    if evt.isMouseHit(evt.MOUSE_SCROLL_DOWN) and evt.isKeyDown(
            pygame.K_LSHIFT):
        if wRect.collidepoint(evt.getMousePos()):
            world.shiftH(textureSize)
Exemplo n.º 2
0
wm = rgine.windows.WindowsManager()
winm = rgine.windows.WindowsMacros()
hButton0 = wm.CreateWindow(winm.WC_BUTTON, ((158, 59), rgine.windows._button, "Button 0",
												  pygame.font.SysFont('Times New Romen', 16),
												  True, (255, 255, 255)), True)
hButton1 = wm.CreateWindow(winm.WC_BUTTON, ((158, 59), rgine.windows._button, "Button 1",
												  pygame.font.SysFont('Times New Romen', 16),
												  True, (255, 255, 255)), True)
wm.MoveWindow(hButton1, 158//2, 59//2)
hButton2 = wm.CreateWindow(winm.WC_BUTTON, ((158, 59), rgine.windows._button, "Button 2",
												  pygame.font.SysFont('Times New Romen', 16),
												  True, (255, 255, 255)), True)
wm.MoveWindow(hButton2, 158, 59)

img = t.getTexture(2)
print(rgine.int2bool(t.getProperty(0, 0)))
while True:
	evt.update()
	if evt.type == pygame.QUIT:
		break
	if evt.isKeyHit(pygame.K_ESCAPE):    # escape
		break
	if evt.isKeyDown("t"):
		t.setTexture(pygame.Surface((32, 32)), 2)
	else:
		t.setTexture(img, 2)
	t.render(surf)
	screen.blit(surf, (0, 0))
	for hWnd, msg, surface, pos in wm.DispatchMessage(evt):
		screen.blit(surface, pos)
		if hWnd == hButton0 and msg == winm.HIT:
			px -= world.getShift()[0]
			py -= world.getShift()[1]
			t = terrain.getProperty_s(x, y)
			if t is None: continue
			if test(t, CurrentDigit):
				screen.blit(_ok, (px, py))
			else:
				screen.blit(_cross, (px, py))

	if evt.isMouseHit(evt.MOUSE_LEFT):
		if wRect.collidepoint(evt.getMousePos()):
			wsx, wsy = world.getShift()
			x, y = getTerrainByPos(*[terrain]+[evt.getMousePos()[0]+wsx, evt.getMousePos()[1]+wsy]+list(wOffset))
			t = terrain.getProperty_s(x, y)
			if t is not None:
				li = rgine.int2bool(t)
				li[CurrentDigit] = not li[CurrentDigit]
				terrain.setProperty(x, y, rgine.bool2int(li))



	if evt.isMouseHit(evt.MOUSE_SCROLL_UP) and evt.isKeyDown(pygame.K_LSHIFT):
		if wRect.collidepoint(evt.getMousePos()):
			world.shiftH(-textureSize)

	elif evt.isMouseHit(evt.MOUSE_SCROLL_UP):
		if wRect.collidepoint(evt.getMousePos()):
			world.shiftV(-textureSize)

	if evt.isMouseHit(evt.MOUSE_SCROLL_DOWN) and evt.isKeyDown(pygame.K_LSHIFT):
		if wRect.collidepoint(evt.getMousePos()):
Exemplo n.º 4
0
                           ((158, 59), rgine.windows._button, "Button 0",
                            pygame.font.SysFont('Times New Romen', 16), True,
                            (255, 255, 255)), True)
hButton1 = wm.CreateWindow(winm.WC_BUTTON,
                           ((158, 59), rgine.windows._button, "Button 1",
                            pygame.font.SysFont('Times New Romen', 16), True,
                            (255, 255, 255)), True)
wm.MoveWindow(hButton1, 158 // 2, 59 // 2)
hButton2 = wm.CreateWindow(winm.WC_BUTTON,
                           ((158, 59), rgine.windows._button, "Button 2",
                            pygame.font.SysFont('Times New Romen', 16), True,
                            (255, 255, 255)), True)
wm.MoveWindow(hButton2, 158, 59)

img = t.getTexture(2)
print(rgine.int2bool(t.getProperty(0, 0)))
while True:
    evt.update()
    if evt.type == pygame.QUIT:
        break
    if evt.isKeyHit(pygame.K_ESCAPE):  # escape
        break
    if evt.isKeyDown("t"):
        t.setTexture(pygame.Surface((32, 32)), 2)
    else:
        t.setTexture(img, 2)
    t.render(surf)
    screen.blit(surf, (0, 0))
    for hWnd, msg, surface, pos in wm.DispatchMessage(evt):
        screen.blit(surface, pos)
        if hWnd == hButton0 and msg == winm.HIT: