from math import tan, radians

from pygame import Surface
from pygame.draw import line

from lib.pgfw.pgfw.GameChild import GameChild

class Mask(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.load_configuration()
        self.init_surface()
        self.set_background()
        self.reset()

    def load_configuration(self):
        config = self.get_configuration("land")
        self.height = config["height"]
        self.spacing_factor = config["spacing-factor"]
        self.gradient = config["gradient"]
        self.x_step = config["x-step"]
        self.velocity_ratio = config["velocity-ratio"]

    def init_surface(self):
        Surface.__init__(self, (self.get_display_surface().get_width(),
                                self.height))

    def set_background(self):
        background = Surface(self.get_size())
        background.fill((0, 0, 0))
        self.background = background

    def reset(self):
        self.x_offset = 0

    def update(self):
        self.clear()
        self.draw_y()
        self.draw_x()

    def clear(self):
        self.blit(self.background, (0, 0))

    def draw_y(self):
        yy = 0
        ii = 0
        rect = self.get_rect()
        while yy < rect.bottom:
            line(self, (255, 255, 255), (0, yy), (rect.right, yy))
            yy += int(self.spacing_factor ** ii)
            ii += 1

    def draw_x(self):
        gradient = self.gradient
        step = self.x_step
        rect = self.get_rect()
        edge = rect.right
        xx = int(self.x_offset) + step
        adjacent = rect.h
        while xx < edge:
            angle = (edge - float(xx)) / edge * 2 * gradient + (90 - gradient)
            opposite = int(tan(radians(90 - angle)) * adjacent)
            line(self, (255, 255, 255), (xx, 0),
                 (xx + opposite, adjacent))
            xx += step
        self.decrement_x_offset()

    def decrement_x_offset(self):
        self.x_offset -= self.parent.parent.velocity[0] * self.velocity_ratio
        if self.x_offset <= -self.x_step:
            self.x_offset += self.x_step
from random import randrange, randint
from os.path import join

from pygame import PixelArray

from lib.pgfw.pgfw.Sprite import Sprite
from food_spring.level.planet.moon.Moons import Moons

class Planet(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_configuration()
        self.load_image()
        self.place()
        self.register(self.scramble, interval=self.interval)
        self.play(self.scramble)
        self.moons = Moons(self)

    def load_configuration(self):
        config = self.get_configuration("planet")
        self.root = config["path"]
        self.interval = config["interval"]
        self.shifts = config["shifts"]
        self.offset = config["offset"]
        self.extension = config["extension"]

    def load_image(self):
        path = self.get_resource(join(self.root, "%i.%s" % (self.parent.index,
                                                            self.extension)))
        self.load_from_path(path, True)

    def place(self):
        self.rect.center = self.display_surface.get_width() / 2, \
                           self.parent.land.top - self.offset

    def scramble(self):
        surface = self.get_current_frame()
        pixels = PixelArray(surface)
        width, height = self.location.size
        x = randrange(0, width)
        y = randrange(0, height)
        components = surface.unmap_rgb(pixels[x][y])
        if components[3] == 255:
            for _ in xrange(self.shifts):
                dx, dy = randint(-1, 1), randint(-1, 1)
                nx, ny = x + dx, y + dy
                if nx < 0 or ny < 0 or nx >= width or ny >= height:
                    break
                if surface.unmap_rgb(pixels[nx][ny])[3] == 255:
                    pixels[nx][ny] = components
                    x = nx
                    y = ny
        del pixels

    def update(self):
        Sprite.update(self)
        self.moons.update()
from random import randint

from lib.pgfw.pgfw.GameChild import GameChild
from food_spring.level.planet.moon.Moon import Moon

class Moons(GameChild, list):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        for _ in xrange(randint(*self.get_configuration("moon", "count"))):
            self.append(Moon(self))

    def update(self):
        for moon in self:
            moon.update()
from random import randint, randrange
from glob import glob
from os.path import join

from pygame import Color, PixelArray

from lib.pgfw.pgfw.Sprite import Sprite

class Moon(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_configuration()
        self.set_frames()
        self.tint()
        self.place()
        self.set_framerate(randint(*self.interval))
        self.frame_index = randrange(0, len(self.frames))

    def load_configuration(self):
        config = self.get_configuration("moon")
        self.tint_level = config["tint-level"]
        self.interval = config["interval"]
        self.margin = config["margin"]
        self.path = self.get_resource(config["path"])

    def set_frames(self):
        for path in glob(join(self.path, "*.png")):
            self.load_from_path(path, True, True)

    def tint(self):
        color = Color(0, 0, 0)
        color.hsla = randint(0, 360), 100, 50
        level = self.tint_level
        transparent_color = self.get_current_frame().get_colorkey()
        for frame in self.frames:
            pixels = PixelArray(frame)
            for x in xrange(len(pixels)):
                for y in xrange(len(pixels[x])):
                    if pixels[x][y] != transparent_color:
                        r, g, b, a = frame.unmap_rgb(pixels[x][y])
                        r = self.tint_component(r, color.r)
                        g = self.tint_component(g, color.g)
                        b = self.tint_component(b, color.b)
                        pixels[x][y] = r, g, b, a

    def tint_component(self, component, tint):
        return self.tint_level * (tint - component) + component

    def place(self):
        margin = self.margin
        box = self.parent.parent.location.inflate([margin] * 2)
        moons = [moon.location.inflate([margin] * 2) for moon in self.parent]
        self.set_center()
        location = self.location
        while location.colliderect(box) or location.collidelist(moons) != -1:
            self.set_center()

    def set_center(self):
        display = self.display_surface.get_rect()
        margin = self.margin
        x = randrange(margin, display.w - margin)
        y = randrange(margin, self.parent.parent.parent.land.top - margin)
        self.location.center = x, y
216.73.216.51
216.73.216.51
216.73.216.51
 
July 18, 2022


A new era ‼

Our infrastructure has recently upgraded ‼

Nugget Communications Bureau 👍

You've never emailed like this before ‼

Roundcube

Webmail software for reading and sending email from @nugget.fun and @shampoo.ooo addresses.

Mailman3

Email discussion lists, modernized with likes and emojis. It can be used for announcements and newsletters in addition to discussions. See lists for Picture Processing or Scrapeboard. Nowadays, people use Discord, but you really don't have to!

FreshRSS

With this hidden in plain sight, old technology, even regular people like you and me can start our own newspaper or social media feed.

Nugget Streaming Media 👍

The content you crave ‼

HLS

A live streaming, video format based on M3U playlists that can be played with HTML5.

RTMP

A plugin for Nginx can receive streaming video from ffmpeg or OBS and forward it as an RTMP stream to sites like Youtube and Twitch or directly to VLC.


Professional ‼

Nugget Productivity Suite 👍

Unleash your potential ‼

Kanboard

Virtual index cards you can use to gamify your daily grind.

Gitea

Grab whatever game code you want, share your edits, and report bugs.

Nugget Security 👍

The real Turing test ‼

Fail2ban

Banning is even more fun when it's automated.

Spamassassin

The documentation explains, "an email which mentions rolex watches, Viagra, porn, and debt all in one" will probably be considered spam.

GoAccess

Display HTTP requests in real time, so you can watch bots try to break into WordPress.

Nugget Entertainment Software 👍

The best in gaming entertainment ‼

Emoticon vs. Rainbow

With everything upgraded to the bleeding edge, this HTML4 game is running better than ever.


Zoom ‼

The game engine I've been working on, SPACE BOX, is now able to export to web, so I'm planning on turning nugget.fun into a games portal by releasing my games on it and adding an accounts system. The upgraded server and software will make it easier to create and maintain. I'm also thinking of using advertising and subscriptions to support the portal, so some of these services, like webmail or the RSS reader, may be offered to accounts that upgrade to a paid subscription.