import pygame

class Animation:

    def __init__(self, frame_duration):
        self.reset_ticks()
        self.updates_this_cycle = 1
        self.overflow = 0
        self.update_count = 1
        self.actual_frame_duration = 0
        self.target_frame_duration = frame_duration
        self.stopping = False

    def reset_ticks(self):
        self.last_ticks = self.get_ticks()

    def play(self):
        while not self.stopping:
            self.advance_frame()
            self.update_frame_duration()
            self.update_overflow()
        self.stopping = False

    def advance_frame(self):
        while self.update_count > 0:
            self.sequence()
            self.update_count -= 1

    def update_frame_duration(self):
        last_ticks = self.last_ticks
        actual_frame_duration = self.get_ticks() - last_ticks
        last_ticks = self.get_ticks()
        wait_duration = self.get_configuration()["display-wait-duration"]
        while actual_frame_duration < self.target_frame_duration:
            pygame.time.wait(wait_duration)
            actual_frame_duration += self.get_ticks() - last_ticks
            last_ticks = self.get_ticks()
        self.actual_frame_duration = actual_frame_duration
        self.last_ticks = last_ticks

    def get_ticks(self):
        return pygame.time.get_ticks()

    def update_overflow(self):
        self.update_count = 1
        target_frame_duration = self.target_frame_duration
        overflow = self.overflow
        overflow += self.actual_frame_duration - target_frame_duration
        while overflow > target_frame_duration:
            self.update_count += 1
            overflow -= target_frame_duration
        overflow = self.overflow

    def stop(self):
        self.stopping = True

    def clear_queue(self):
        self.update_count = 1
from pygame import event
from pygame.locals import *

from GameChild import *

class EventDelegate(GameChild):

    command_event = USEREVENT
    state_change_event = USEREVENT + 1

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribers = dict()
        self.disable()

    def enable(self):
        self.enabled = True

    def disable(self):
        self.enabled = False

    def dispatch_events(self):
        if self.enabled:
            subscribers = self.subscribers
            for evt in event.get():
                kind = evt.type
                if kind in subscribers:
                    for subscriber in subscribers[kind]:
                        subscriber(evt)
        else:
            event.pump()

    def add_subscriber(self, kind, callback):
        subscribers = self.subscribers
        if kind not in subscribers:
            subscribers[kind] = list()
        subscribers[kind].append(callback)

    @classmethod
    def post_event(self, id, **kw):
        event.post(event.Event(id, **kw))
import sys

import pygame
from pygame.locals import *

from GameChild import *
from Animation import *
from Audio import *
from Display import *
from configuration.Configuration import *
from EventDelegate import *
from Input import *
from ScreenGrabber import *
from introduction.Introduction import *
from world.World import *

class Game(GameChild, Animation):
    
    def __init__(self):
        GameChild.__init__(self)
        self.configuration = Configuration()
        Animation.__init__(self, self.configuration["display-frame-duration"])
        pygame.init()
        self.add_children()
        self.subscribe_to_events()
        self.clear_queue()
        self.delegate.enable()
        self.introduction.activate()

    def add_children(self):
        self.audio = Audio(self)
        self.display = Display(self)
        self.delegate = EventDelegate(self)
        self.input = Input(self)
        self.screen_grabber = ScreenGrabber(self)
        self.introduction = Introduction(self)
        self.world = World(self)

    def subscribe_to_events(self):
        self.subscribe_to(QUIT, self.end)
        self.subscribe_to(Input.command_event, self.end)

    def get_configuration(self):
        return self.configuration

    def get_input(self):
        return self.input

    def sequence(self):
        self.delegate.dispatch_events()
        self.world.update()
        pygame.display.update()

    def end(self, evt):
        if evt.type == QUIT or evt.command == "quit":
            sys.exit()
from pygame.mixer import Channel, Sound, music

from GameChild import *

class Audio(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.set_channels()

    def set_channels(self):
        config = self.get_configuration()
        self.bg_channel = Channel(config["audio-bg-channel"])

    def play_bgm(self, path, stream=False):
        if stream:
            self.bg_channel.stop()
            music.load(path)
            music.play(-1)
        else:
            music.stop()
            self.bg_channel.play(Sound(path), -1)
from transistors.GameChild import *
from slides.Slides import *

from transistors.EventDelegate import *

class Introduction(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.slides = Slides(self)
        self.subscribe_to_events()

    def subscribe_to_events(self):
        self.subscribe_to(EventDelegate.command_event, self.advance)

    def reset(self):
        self.slides.reset()

    def activate(self):
        self.active = True
        self.set_music()
        self.draw()

    def deactivate(self):
        self.active = False

    def set_music(self):
        self.get_audio().play_bgm(self.get_resource("introduction-music-path"))

    def advance(self, evt):
        if self.active and evt.command == "release":
            if self.slides.advance():
                self.draw()
            else:
                self.deactivate()
                EventDelegate.post_event(EventDelegate.state_change_event,
                                         state="introduction-finished")

    def draw(self):
        self.slides.draw()
216.73.216.195
216.73.216.195
216.73.216.195
 
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.