0

I'm new to Pygame (and Python in general). I wanted to recreate the boot sequence of the Nostromo computer from the first Alien (1979) movie using Pygame, with all the cool retrofuturistic sounds and stuff.

The unfortunate problem is with the sequence where there are five columns of numbers which appear on the screen and quickly scroll upwards as the computer is "typing" new numbers. Here how it looks like

It's relatively easy to render static objects, but in here we have about 125 numbers and all of them are moving.

My idea was to make a list with one number (show_num_list) and a list of 25 random numbers (decrease_num_list). And then to make a timed loop: with each iteration of the loop the program grabs the last number from the decrease_num_list and puts it in show_num_list, it gets bigger, and its contents are being shown on the screen, thus making the animation. And if it works, I can turn it into a function and use the function 5 times with a different X coordinate to make 5 columns.

But it doesn't work. If specifically, it doesn't move. Maybe I still don't understand how the Rect objects work in the game, the concept of Rect is very confusing. Like I understand that text is a surface, and apparently I need to put it on the rect object in order to move it

Here's how I tried to do it:


        current_time = pg.time.get_ticks()
        if screen3:
            time_tick = pygame.time.get_ticks() / 1000
            screen.fill(settings.bg_color_4)
            position = [200, 800]
            for item in show_num_list:
                text_colour = settings.text_colour_screen3
                screen3_font = pуgame.font.Font('VT323-Regular.ttf', settings.letter_size_screen3)
                screen_text = screen3_font.render(item, True, text_colour)

                text_rect = screen_text.get_rect(center=position)
                if time_05 < time_tick and len(decrease_num_list) > 0:
                    item2 = decrease_num_list.pop(-1)
                    show_num_list.append(item2)
                    position[1] -= font_size
                    time_05 = time_05 + 0.3
            screen.blit(screen_text, text_rect)```
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Jafes
  • 1
  • 1

0 Answers0