Pygame plasma effect won’t display

I’m porting this ancient code to Python 3. I’ve applied the varied palette to the surfaces and the plasma_buffer matrix changes, but pygame.display.flip() keeps showing a black screen. What’d I miss?

"""Plasma.py -- Korruptor Jan 2001, test code for Seal Basher (v1.0)

This little doobry is based on the fast flame example by Pete Shinners
and is another novel neat hack on the surfarray module. 

The plasma algo itself is pretty simple, just a sum of four cosine values
from a pre-calculated look-up table inserted into a surf buff. It's all 
pretty easy really. The comments explain my thinking... 

This is my first hack, and not really optimised apart from what I've learnt
from Pete's example and whilst lurking on #Pygame. If you've got suggestions
for speed increases let me know..."""

from math import cos

from numpy import array, mod, zeros, uint8
from pygame import Surface, display
import pygame.transform
from pygame.surfarray import blit_array

# pylint: disable=no-name-in-module
from pygame.locals import KEYDOWN, MOUSEBUTTONDOWN, QUIT


RES = array((320, 256))

small_x = int(RES[0] // 8)
small_y = int(RES[1] // 8)

PI = 3.14159

# Linear array of cosine values to be indexed and summed, initialised to zero prior to pre-calc...
cos_tab = [0] * 256

# Array of indexes to be used on our cos_tab. Could be variables I suppose. Just easier to cut_n_paste! ;-)
pnt_tab = array((0, 0, 0, 0))


def main():
    "Inisalises display, precalculates the cosine values, and controls the update loop"
    display.init()
    # Turn SDL_PIXELFORMAT_RGB888 to SDL_PIXELFORMAT_INDEX8
    screen_surface: Surface = display.set_mode(RES, 0, 8).convert(8)
    info = display.Info()
    print(info)

    # Numeric array (working) for the display. Do all our fun stuff here...
    plasma_buffer: list = [[0] * small_y] * small_x

    # Pygame Surface object which will take the surfarray data and be translated into a screen blit...
    plasma_surface = Surface((small_x, small_y), 0, 8).convert(8)

    set_palette(screen_surface)
    plasma_surface.set_palette(screen_surface.get_palette())
    screen_surface.fill(100)

    make_cosine()

    # Fruity loops...
    while 1:

        for e in pygame.event.get():
            if e.type in (QUIT, KEYDOWN, MOUSEBUTTONDOWN):
                return

        add_cosine(plasma_buffer)
        # print(plasma_buffer[0])
        blit_scaled_surface(screen_surface, plasma_buffer, plasma_surface)
        pygame.display.flip()


def add_cosine(plasma_buffer):
    "An Y by X loop of screen co-ords, summing the values of four cosine values to produce a color value that'll map to the previously set surface palette."

    # Use working indices for the cosine table, save the real ones for later...
    t1 = pnt_tab[0]
    t2 = pnt_tab[1]
    for y in range(0, small_y):
        # Save the horizontal indices for later use...
        t3 = pnt_tab[2]
        t4 = pnt_tab[3]
        for x in range(0, small_x):
            # Our color value will equal the sum of four cos_table offsets.
            # The preset surface palette comes in handy here! We just need to output the value...
            # We mod by 256 to prevent our index going out of range. (C would rely on 8bit byte ints and with no mod?)
            color = (
                cos_tab[mod(t1, 256)]
                + cos_tab[mod(t2, 256)]
                + cos_tab[mod(t3, 256)]
                + cos_tab[mod(t4, 256)]
            )

            # Arbitrary values, changing these will allow for zooming etc...
            t3 += 3
            t4 += 2

            # Insert the calculated color value into our working surfarray...
            plasma_buffer[x][y] = color

        # Arbitrary values again...
        t1 += 2
        t2 += 1

    # Arbitrary values to move along the cos_tab. Play around for something nice...
    # Don't think I need these boundary checkings, but just in case someone decides to run this code for a couple of weeks non-stop...
    #
    if pnt_tab[0] < 256:
        pnt_tab[0] += 1
    else:
        pnt_tab[0] = 1

    if pnt_tab[1] < 256:
        pnt_tab[1] += 2
    else:
        pnt_tab[1] = 2

    if pnt_tab[2] < 256:
        pnt_tab[2] += 3
    else:
        pnt_tab[2] = 3

    if pnt_tab[3] < 256:
        pnt_tab[3] += 4
    else:
        pnt_tab[3] = 4


def make_cosine():
    "Knock up a little pre-calculated cosine lookup table..."
    i = 0
    for i in range(0, 256):
        # Play with the values here for interesting results... I just made them up! :-)
        cos_tab[i] = 60 * (cos(i * PI / 32))


def set_palette(screen_surface):
    "Create something trippy... Based on Pete's cmap creator, and without doubt the thing that took the longest... Aaaargh! Decent palettes are hard to find..."
    colors = zeros((256, 3), uint8)

    i = 0
    for i in range(0, 64):
        colors[i][0] = 255
        colors[i][1] = i * 4
        colors[i][2] = 255 - (i * 4)

        colors[i + 64][0] = 255 - (i * 4)
        colors[i + 64][1] = 255
        colors[i + 64][2] = i * 4

        colors[i + 128][0] = 0
        colors[i + 128][1] = 255 - (i * 4)
        colors[i + 128][2] = 255

        colors[i + 192][0] = i * 4
        colors[i + 192][1] = 0
        colors[i + 192][2] = 255

    screen_surface.set_palette(colors)


def blit_scaled_surface(screen, flame, miniflame):
    "double the size of the data, and blit to screen -- Nicked from Shread's Fast Flame"
    f = array(flame, uint8)
    print(f[0])
    blit_array(miniflame, f)
    s2 = pygame.transform.scale(miniflame, screen.get_size())
    screen.blit(s2, (0, 0))


if __name__ == "__main__":
    main()

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật