Ejemplo n.º 1
0
def run(img, width, height):
    global terrain
    terrain = rgine.Terrain("w", 0, 0, width, width)
    j = 0
    for i in getImages(img, width, height):
        terrain.setTexture(i, j)
        j += 1
Ejemplo n.º 2
0
def init_terrain(terrain_name, texture_name, is_display_mode_set=True):
	terrain = rgine.Terrain("r", 32, 32)
	terrain.readTerrain(terrain_name)
	terrain.readTextureFromFile(texture_name)
	if is_display_mode_set:
		terrain.convert_alpha()
	return terrain
Ejemplo n.º 3
0
def getTerrainByPos(terrain, mouseX, mouseY, shiftX, shiftY):
    a, b = terrain.getTerrainByRelativeRect(
        (mouseX - shiftX, mouseY - shiftY, 0, 0))
    return a[0], b[0]


def test(property_byte, digit):
    return rgine.byte2bool(bytes([property_byte]))[digit]


screen = pygame.display.set_mode((16 * 2 * 32, 9 * 2 * 32))
terrainFilename = os.path.join("maps", "1399326333.terrain")
textureFilename = "myTexture.texture"
textureSize = 32
terrain = rgine.Terrain("w", 0, 0, textureSize, textureSize)
terrain.readTerrain(terrainFilename)
terrain.readTextureFromSurface(
    pygame.image.load(os.path.join("maps", "1399326333.jpeg")).convert_alpha())
##terrain.readTextureFromFile(textureFilename)
textureInfo = \
 {
    "width": terrain.width,
    "height": terrain.height,
}

evt = rgine.Event()
wm = rgine.windows.WindowsManager()

wmbuttons = {}
wmacro = rgine.windows.WindowsMacros()
Ejemplo n.º 4
0
__author__ = 'Charles-Jianye Chen'
import rgine as rgine

t = input("-> Ordered? (T/F) ").lower()
width = int(input("-> Width? "))
height = int(input("-> Height? "))
terrain = rgine.Terrain("w", width, height, 32, 32)
if t == "t":
		i = 0
		for y in range(height):
				for x in range(width):
					terrain.setIdentifier(x, y, i)
					i += 1
		print(i)
		terrain.writeTerrain("%dx%d_ordered" % (width, height))
		input("Done! ")
else:
	terrain.writeTerrain("%dx%d" % (width, height))
	input("Done! ")
Ejemplo n.º 5
0
import pygame

import rgine as rgine

Tsize = 11

t = rgine.Terrain("r")

screen = pygame.display.set_mode((Tsize * 32, Tsize * 32))
surf = pygame.Surface(screen.get_size())

t.readTerrain("myTerrain.terrain")
t.setTextureFormat(32, 32)  #must call this before reading a texture file
t.readTextureFromFile("myTexture.texture")
t.render(surf)

evt = rgine.Event()

pygame.font.init()
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,
Ejemplo n.º 6
0
import cProfile

import pygame

p = cProfile.Profile()

import rgine as rgine

p.enable()

Tsize = 11

t = rgine.Terrain("w")
t.init(Tsize, Tsize, 32, 32)
surf = pygame.Surface((32, 32))

surf.fill((255, 255, 255))
t.setTexture(surf.copy(), 0)

surf.fill((0, 0, 0))
t.setTexture(surf.copy(), 1)

t.setTexture(surf, 2)

for x, y in zip(range(0, Tsize), range(0, Tsize)):
    t.modify(x, y, 1)
    t.modify(x, Tsize - 1 - y, 1)
    t.modify(Tsize // 2, y, 2)
    t.modify(x, Tsize // 2, 2)

screen = pygame.display.set_mode((Tsize * 32, Tsize * 32))
Ejemplo n.º 7
0
		a, b = terrain.getTerrainByRelativeRect((mouseX-shiftX, mouseY-shiftY, 0, 0))
		return a[0], b[0]

textureSize = 32
TsizeW, TsizeH = 15, 15
textureFileName = "outside.png.texture"
textureInfo = \
	{
	"width": 8,
	"height": 469,
	}

terrainFileName = "8x469_ordered"


tRead = rgine.Terrain("r", textureSize, textureSize)
tWrite = rgine.Terrain("w", TsizeW, TsizeH, textureSize, textureSize)

tRead.readTextureFromFile(textureFileName)
tRead.readTerrain(terrainFileName)
wRead = rgine.TerrainWorld(textureInfo["width"]*textureSize, textureInfo["height"]*textureSize)
wRead.setTextureFormat(textureSize, textureSize)
wRead.setProjectionSize(8*textureSize, 20*textureSize)
tRead.render(wRead.getSurface())


tWrite.readTextureFromFile(textureFileName)
wWrite = rgine.TerrainWorld(TsizeW*textureSize, TsizeH*textureSize)
wWrite.setTextureFormat(textureSize, textureSize)
wWrite.setProjectionSize(12*textureSize, 12*textureSize)
tWrite.render(wWrite.getSurface())