from math import pi, sin, cos

from pygame.font import Font

from esp_hadouken.pgfw.GameChild import GameChild
from esp_hadouken.pgfw.Vector import Vector

class Pedal(GameChild, Vector):

    def __init__(self, parent, index):
        GameChild.__init__(self, parent)
        self.effect = 0
        self.index = index
        self.display_active = self.check_command_line(self.parent.display_flag)
        self.reset()
        self.init_display()
        self.set_coefficients()

    def reset(self):
        Vector.__init__(self)

    def init_display(self):
        if self.display_active:
            self.display_surface = self.get_screen()
            self.coordinates = 0, (self.index + 1) * 20
            self.font = Font(self.parent.parent.font_path, 14)
            self.render()

    def render(self):
        string = str(self)
        self.text = self.font.render(string, False, (0, 0, 0), (255, 255, 255))
        self.string = string

    def set_coefficients(self):
        index = self.index
        cx = sin(pi * index / 4)
        cy = -cos(pi * index / 4)
        if cx < .000000001 and cx > -.0000000001:
            cx = 0
        if cy < .000000001 and cy > -.0000000001:
            cy = 0
        self.cx, self.cy = cx, cy

    def set_slopes(self):
        min_na_dist = self.parent.min_negative_acceleration_distance
        min_na = self.parent.min_negative_acceleration
        max_v = self.parent.parent.max_velocity
        initial_thrust = self.parent.initial_thrust
        peak_distance = self.parent.peak_distance
        peak_acceleration = self.parent.peak_acceleration
        self.tail_slope = (min_na - self.parent.max_negative_acceleration) / \
                          (-min_na_dist + max_v)
        self.rest_slope = (initial_thrust - min_na) / min_na_dist
        self.motion_slope = (peak_acceleration - initial_thrust) / peak_distance
        self.head_slope = -peak_acceleration / (max_v - peak_distance)

    def update(self, active):
        self.update_effect(active)
        self.set()
        self.display()

    def update_effect(self, active):
        if active:
            self.effect += self.parent.attack
        elif not active:
            self.effect -= self.parent.release
        self.constrain()

    def constrain(self):
        effect = self.effect
        if effect < 0 or effect > 1:
            if effect < 0:
                effect = 0
            else:
                effect = 1
            self.effect = effect

    def set(self):
        if self.effect:
            vx, vy = self.parent.parent
            cx, cy = self.cx, self.cy
            self.x = self.get_component(vx, cx)
            self.y = self.get_component(vy, cy)
        else:
            self.x = 0
            self.y = 0

    def get_component(self, velocity, coefficient):
        if coefficient < 0:
            velocity = -velocity
        max_v = self.parent.parent.max_velocity
        if not coefficient or velocity >= max_v:
            return 0
        if velocity <= -max_v:
            magnitude = -self.parent.max_negative_acceleration
        elif velocity <= -self.parent.min_negative_acceleration_distance:
            magnitude = self.tail_thrust(velocity)
        elif velocity <= 0:
            magnitude = self.rest_thrust(velocity)
        elif velocity <= self.parent.peak_distance:
            magnitude = self.motion_thrust(velocity)
        else:
            magnitude = self.head_thrust(velocity)
        return coefficient * self.effect * magnitude

    def are_same_sign(self, left, right):
        return left == 0 or right == 0 or abs(left) / left == abs(right) / right

    def tail_thrust(self, velocity):
        return (self.tail_slope * \
                (velocity + self.parent.min_negative_acceleration_distance)) + \
                self.parent.min_negative_acceleration

    def rest_thrust(self, velocity):
        return (self.rest_slope * velocity) + self.parent.initial_thrust

    def motion_thrust(self, velocity):
        return (self.motion_slope * (velocity - self.parent.peak_distance)) + \
               self.parent.peak_acceleration

    def head_thrust(self, velocity):
        return self.head_slope * (velocity - self.parent.parent.max_velocity)

    def display(self):
        if self.display_active:
            if self.string != str(self):
                self.render()
            self.display_surface.blit(self.text, self.coordinates)

    def __str__(self):
        return "[{0: .2f}, {1: .2f}] {2: .2f}".format(self.x, self.y,
                                                      self.effect)
from pygame import Color

from esp_hadouken.GameChild import *

class GlyphPalette(GameChild, list):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        list.__init__(self, [])
        self.set_interval_properties()
        self.populate()

    def set_interval_properties(self):
        length = self.get_configuration()["scoreboard-palette-length"]
        interval_count = 6
        self.interval_length = length / interval_count
        self.overflow = length % interval_count

    def populate(self):
        brightness = self.get_configuration()["scoreboard-palette-brightness"]
        self.add_interval([255, brightness, brightness], [0, 1, 0])
        self.add_interval([255, 255, brightness], [-1, 0, 0])
        self.add_interval([brightness, 255, brightness], [0, 0, 1])
        self.add_interval([brightness, 255, 255], [0, -1, 0])
        self.add_interval([brightness, brightness, 255], [1, 0, 0])
        self.add_interval([255, brightness, 255], [0, 0, -1])

    def add_interval(self, components, actions):
        for ii, action in enumerate(actions):
            if action == 1:
                components[ii] = 0
            elif action == -1:
                components[ii] = 255
        length = self.interval_length + (self.overflow > 0)
        self.overflow -= 1
        step = 255 / length
        for ii in range(length):
            self.append(Color(*components))
            for ii, action in enumerate(actions):
                if action == 1:
                    components[ii] += step
                elif action == -1:
                    components[ii] -= step
from pygame import Surface, Color, Rect

from esp_hadouken.GameChild import *
from esp_hadouken.Font import *

class Heading(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.init_surface()
        self.set_rect()
        self.add_labels()
        self.render_title()

    def init_surface(self):
        parent = self.parent
        width = parent.get_width() - parent.get_padding()
        Surface.__init__(self, (width, parent.get_heading_height()))
        self.fill(Color(self.get_configuration()["scoreboard-heading-bg"]))

    def set_rect(self):
        rect = self.get_rect()
        offset = self.parent.get_padding() / 2
        rect.topleft = offset, offset
        self.rect = rect

    def add_labels(self):
        labels = []
        margin = self.get_margin()
        for ii in range(5):
            labels.append(Label(self, ii))
        self.labels = labels

    def render_title(self):
        config = self.get_configuration()
        size = config["scoreboard-heading-title-size"]
        text = config["scoreboard-heading-title"]
        color = Color(config["scoreboard-heading-title-color"])
        rend = Font(self, size).render(text, True, color)
        rect = rend.get_rect()
        offset = config["scoreboard-heading-title-offset"]
        rect.centery = self.get_rect().centery + offset
        rect.left = config["scoreboard-heading-title-indent"]
        self.blit(rend, rect)

    def get_margin(self):
        return self.get_configuration()["scoreboard-heading-margin"]

    def update(self):
        for label in self.labels:
            label.update()
        self.draw()

    def draw(self):
        self.parent.blit(self, self.rect)


class Label(GameChild, Surface):

    def __init__(self, parent, index):
        GameChild.__init__(self, parent)
        self.index = index
        self.init_surface()
        self.set_rect()

    def init_surface(self):
        parent = self.parent
        size = parent.get_height() - parent.get_margin()
        Surface.__init__(self, (size, size))
        self.paint()

    def paint(self):
        palette = self.get_palette()
        count = self.get_configuration()["scoreboard-heading-checker-count"]
        size = tuple([self.get_width() / count] * 2)
        for ii in range(count):
            for jj in range(count):
                rect = Rect((ii * size[0], jj * size[0]), size)
                self.fill(Color(palette[(ii + jj) % len(palette)]), rect)

    def get_palette(self):
        index = self.index
        if index == 0:
            level = "octo"
        elif index == 1:
            level = "horse"
        elif index == 2:
            level = "diortem"
        elif index == 3:
            level = "circulor"
        else:
            level = "tooth"
        return self.get_configuration()[level + "-level-palette"]

    def set_rect(self):
        rect = self.get_rect()
        rect.left = self.calculate_indent()
        rect.centery = self.parent.get_rect().centery
        self.rect = rect

    def calculate_indent(self):
        parent = self.parent
        width = parent.get_width()
        columns = parent.parent.get_column_widths()
        offset = (columns[3] * width - self.get_width()) / 2
        return sum(columns[:self.index + 3]) * width + offset

    def update(self):
        self.draw()

    def draw(self):
        self.parent.blit(self, self.rect)
3.143.1.71
3.143.1.71
3.143.1.71
 
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.