diff --git a/hashengine.py b/hashengine.py index 3442382..75ff445 100644 --- a/hashengine.py +++ b/hashengine.py @@ -16,6 +16,7 @@ class stdrend: def coltohex(self, target): colors = [] + target = [target.r, target.g, target.b] for i in target: colors.append(("0"*(2-len(hex(i)[2:])))+hex(i)[2:]) out = "" @@ -28,6 +29,54 @@ class stdrend: self._grid[f"{x}:{y}"].config(text=text, bg=self.coltohex(bcolor), fg=self.coltohex(fcolor)) self._win.update() +class color3: + def __init__(self, r=0, g=0, b=0): + self.r = r + self.g = g + self.b = b + + def __add__(self, v): + temp = color3(self.r+v.r, self.g+v.g, self.b+v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + + def __sub__(self, v): + temp = color3(self.r-v.r, self.g-v.g, self.b-v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + + def __mul__(self, v): + temp = color3(self.r*v.r, self.g*v.g, self.b*v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + + def __iadd__(self, v): + temp = color3(self.r+v.r, self.g+v.g, self.b+v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + + def __isub__(self, v): + temp = color3(self.r-v.r, self.g-v.g, self.b-v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + + def __imul__(self, v): + temp = color3(self.r*v.r, self.g*v.g, self.b*v.b) + temp.r = temp.r%255 + temp.g = temp.g%255 + temp.b = temp.b%255 + return temp + class vector2: def __init__(self, x=0, y=0): self.x = x @@ -79,8 +128,8 @@ class obj: self.collide = True self.touch = True self.anchored = False - self.bcolor = (255, 255, 255) - self.fcolor = (0, 0, 0) + self.bcolor = color3(255, 255, 255) + self.fcolor = color3() class camera(obj): def __init__(self): @@ -129,11 +178,19 @@ class game: if __name__ == "__main__": testgame = game() - object = obj() - object.char = "#" - testgame.addobj(object) + for i in range(10): + for f in range(10): + object = obj() + object.char = "#" + object.position = vector2(i, f) + object.bcolor = color3() + testgame.addobj(object) testgame.render() print(object.ID) - input("enter to exit") + while True: + for i in testgame._objects: + testgame._objects[i].fcolor += color3(1, 11, 111) + testgame._objects[i].bcolor += color3(1, 11, 111) + testgame.render() diff --git a/icons/object.png b/icons/object.png new file mode 100644 index 0000000..a4c4c42 Binary files /dev/null and b/icons/object.png differ diff --git a/icons/script.png b/icons/script.png new file mode 100644 index 0000000..85c26f5 Binary files /dev/null and b/icons/script.png differ diff --git a/main.py b/main.py index 4a65a0e..8e49eeb 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,33 @@ lang = lang.read() LH.setlang(lang) # LH.string("") +class preview: + def __init__(self, size, container, offset): + self._size = size + self._grid = {} + self._win = container + for y in range(size[1]): + for x in range(size[0]): + temp = tk.Label(text=" ") + temp.grid(row=y+offset[1], column=x+offset[0]) + self._win.update() + self._grid[f"{x}:{y}"] = temp + + def coltohex(self, target): + colors = [] + target = [target.r, target.g, target.b] + for i in target: + colors.append(("0"*(2-len(hex(i)[2:])))+hex(i)[2:]) + out = "" + for i in colors: + out = out + i + return "#"+out + + def pix(self, x, y, text, bcolor, fcolor): + if f"{x}:{y}" in self._grid: + self._grid[f"{x}:{y}"].config(text=text, bg=self.coltohex(bcolor), fg=self.coltohex(fcolor)) + self._win.update() + def selectlang(new): lang = open("clang", 'w') lang.write(new)