Ejemplo n.º 1
0
 def __init__(self, data):
     self.pos = Vector2(data[0], data[1])
     self.v = Vector2(0, 0)
     print(data)
     self.id = data[4]
     self.name = data[2]
     self.inv = bytearray(data[3])  # bytearray(32)# 16 ids with 255 stack
     self.cash = 100
     self.update = True
Ejemplo n.º 2
0
def resizep(a, b, c, id):
    a = Vector2(a[0], a[1])
    b = Vector2(b[0], b[1])
    c = Vector2(c[0], c[1])

    a = (a / b) * c
    x1, y1 = a[0], a[1]
    x2, y2 = (a / b) * c
    t = Touch(x1, y1, x2, y2, id)
    print(x1, y1, x2, y2)
    return Touch(x1, y1, x2, y2, id)
Ejemplo n.º 3
0
    def __init__(self, game, pos, size):
        self.game = game
        self.size = size
        self.anchor_point = (0, 0)
        self.texture = MISSING_TEXTURE
        self.set_position(pos)
        game.add_child(self)

        self.pos = pos
        self.vel = Vector2(0, 0)
        self.acc = Vector2(0, 0)
        self.gravity = False

        self.tiles = []  # Used to check tiles for collision

        self.setup()
Ejemplo n.º 4
0
    def update(self):
        self.acc = Vector2(0, 0)
        self.input = False

        self.check_inputs()
        self.entity_motion()
        self.check_collisions()

        self.pos += self.vel
        self.set_position(self.pos)
Ejemplo n.º 5
0
    def move(self, to):
        if to:
            p = to - self.size / 2
            self.middle.position = (p / abs(p)) * min(abs(p), 125) + (125, 125)

            value = (to * (1 / 125, 1 / 125)) - (1, 1)
            self.value.x = max(min(value[0], 1), -1)
            self.value.y = max(min(value[1], 1), -1)
        else:
            self.value = Vector2(0, 0)
            self.middle.position = self.size / 2
Ejemplo n.º 6
0
    def resizep(self, t):
        #return t
        a = Vector2(t.location[0], t.location[1])
        b = Vector2(self.size[0], self.size[1])
        c = self.zize
        c = Vector2(c[0], c[1])

        #b = [1, 1]
        #c = [1, 1]
        b, c = c, b

        x1 = (b[0] / c[0]) * a[0]
        y1 = (b[1] / c[1]) * a[1]

        a = Vector2(t.prev_location[0], t.prev_location[1])

        x2 = (b[0] / c[0]) * a[0]
        y2 = (b[1] / c[1]) * a[1]
        #print(x1, y1, x2, y2)

        return Touch(x1, y1, x2, y2, t.touch_id)
Ejemplo n.º 7
0
    def __init__(self, *args, **kargs):
        kargs["size"] = (250, 250)
        kargs["position"] = (0, 0)
        super().__init__(Texture('resorces/dpad.PNG'), *args, **kargs)

        self.anchor_point = (0, 0)
        self.alpha = 0.95

        self.middle = SpriteNode(Texture('resorces/dstick.PNG'),
                                 position=self.size / 2,
                                 size=(50, 50),
                                 parent=self)
        self.middle.alpha = 0.9
        self.value = Vector2(0, 0)
Ejemplo n.º 8
0
    def __init__(self, *args, name='defultworld', lan=False, **kwargs):
        self.init = False
        self.setupinit = False
        self.name = name
        self.lan = lan
        super().__init__(*args, **kwargs)
        if lan:
            self.data = Lanfile(self)

        else:
            self.data = worldfile(self.name)

        self.datafiles = datafiles(debug=False)
        self.taps = taps()

        #self.pos = Vector2(0, 0)
        self.v = Vector2(0, 0)
        self.speed = 6

        self.slots = []
        self.SLOTS = []
        self.lb = []
        self.entity = []

        # nodes
        self.tiles = None
        self.bar = None

        self.texu = []

        for x in range(16):
            for y in range(16):
                self.texu.append(
                    self.datafiles.blocks.subtexture(
                        ((y / 16), 1 - ((x + 1) / 16), 1 / 16, 1 / 16)))
                self.texu[-1].filtering_mode = 1
        self.MU = self.datafiles.get_values("mu.txt")

        self.blockv = self.datafiles.get_values("values.txt")

        self.init = True
        self.zize = 0  #?
Ejemplo n.º 9
0
    def setup(self):
        print("setup")
        #self.bace = self
        self.zize = (1, 1)
        self.bace = Node(parent=self, position=(0, 0))
        self.bace.size = Vector2(1024, 768)
        self.tsize = Vector2(1024, 768)
        self.zize = Vector2(self.size[0] / 1024, self.size[1] / 768)
        self.bace.x_scale = self.size[0] / 1024
        self.bace.y_scale = self.size[1] / 768

        self.tiles = tile_shader.TileShader(parent=self.bace, data=self.data)
        self.data.player.newplayer()
        self.hotbar = inputs.HotBar(self.datafiles,
                                    self.data,
                                    self.taps,
                                    parent=self.bace,
                                    position=(300, 14))
        self.invintory = inputs.ItemMenu(self.datafiles,
                                         self.data,
                                         self.taps,
                                         num=(9, 4),
                                         parent=self.bace,
                                         position=(300, 80),
                                         offset=10)
        self.hotbar.other = self.invintory
        self.invintory.other = self.hotbar
        self.ham = SpriteNode(Texture("iow:arrow_right_b_256"),
                              parent=self.bace,
                              position=self.hotbar.bbox.origin +
                              self.hotbar.bbox.size)
        self.ham.anchor_point = (0.3, 0.75)
        self.ham.x_scale = 0.5
        self.ham.y_scale = 0.5
        self.invintory.anchor_point = (0, 0)

        self.select = SpriteNode(Texture('emj:Anger_Symbol'),
                                 position=(0, 0),
                                 size=(75, 69),
                                 parent=self.bace)
        self.select.anchor_point = (1, 0)
        self.select.alpha = 0.95

        self.directionpad = inputs.DPad(parent=self.bace)

        self.cash = LabelNode(str(self.data.player.cash),
                              position=(0, self.bace.size[1]),
                              parent=self.bace)
        self.cash.anchor_point = (0, 1)

        self.player = SpriteNode(Texture('emj:Hamster_Face'),
                                 position=self.bace.size / 2,
                                 size=(20, 20),
                                 parent=self.bace)

        self.HOTBAR = self.taps.add(self.hotbar.bbox)
        self.INV = self.taps.add(self.invintory.bbox)
        self.DPAD = self.taps.add(self.directionpad.bbox)
        self.CASH = self.taps.add(self.cash.bbox)
        self.HAM = self.taps.add(self.ham.bbox, layer=2)

        self.invintory.tapid = self.INV

        self.taps.size = self.size
        self.taps.zize = self.tsize

        if self.init:
            self.setupinit = True
        if self.lan:
            self.data.loop()
        self.invintory.hide = True
        self.tiles._refresh()
Ejemplo n.º 10
0
from scene import Vector2, get_screen_size

COLUMNS = 10
ROWS = 20

GRID_POS = Vector2(10, 150)
GRID_SIZE = 20

COLORS = {
    "bg": "#232323",
    "red": "#FF5555",
    "grey": "#646473",
    "blue": "#786CF5",
    "orange": "#FF8C32",
    "green": "#327834",
    "lime": "#92CA49",
    "purple": "#bc36ff",
    "cyan": "#a1ffff",
    "yellow": "#ffff00"
}

UI = {
    "LEFT_BTN": {
        "texture": 'typw:Left',
        "position": Vector2(50, 100)
    },
    "RIGHT_BTN": {
        "texture": 'typw:Right',
        "position": Vector2(150, 100)
    }
}