Python Forum
Tips on Converting BASIC to Pygame - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: Tips on Converting BASIC to Pygame (/thread-38374.html)



Tips on Converting BASIC to Pygame - robin73 - Oct-05-2022

I posted on Stack Overflow about wanting some feedback/advice on converting old ZX Basic games to Pygame. I'd like to get some input on it, but so far no one has answered. I'm not sure what the deal is here with cross-posting, so for now I'll just leave a link to the question on SO: https://stackoverflow.com/questions/73950834/zx81-basic-to-pygame-conversion-of-dropout-game

I'm happy to move the question over here and delete it on SO if that is preferred.


RE: Tips on Converting BASIC to Pygame - Larz60+ - Oct-05-2022

Quote:I'm happy to move the question over here and delete it on SO if that is preferred.
copy post to here, rather than just posting a link, but leave original as is.


RE: Tips on Converting BASIC to Pygame - rob101 - Oct-05-2022

ZX Basic: Wow! That takes me back. I cut my coding teeth with a ZX81

Do you really need Pygame for this? Not that I know the first thing about Pygame, but I suppose it'll be down to the type of game that you're trying to convert.


RE: Tips on Converting BASIC to Pygame - XavierPlatinum - Oct-05-2022

(Oct-05-2022, 11:59 AM)rob101 Wrote: ZX Basic: Wow! That takes me back. I cut my coding teeth with a ZX81

Do you really need Pygame for this? Not that I know the first thing about Pygame, but I suppose it'll be down to the type of game that you're trying to convert.

lol. My first coding was in Q-Basic on a 386.

As for pygame, they'll need a graphics library of some kind even if they don't use any of it's other features.


RE: Tips on Converting BASIC to Pygame - Windspar - Oct-06-2022

First. You only want one main loop. Have it waiting as loop is not good. Look at fourth tip.
Second. Pygame has many predefine colors. Just use strings. "white", "black"
import pygame

for color in list(pygame.color.THECOLORS):
    print(color)
Third. Update the code. No need keeping the old ways. Computer don't work like that any more. Use some classes and sprites.
Fourth. Pygame.clock should not be use to limit your update. They will vary. It best to match monitor refresh rate. Use pygame.time.get_ticks() or a pygame.time.set_timer to control update speed.
Fifth. You do not want to keep render text in main loop. Render it and save the surface that returns. You just using more cpu then what you need. Render text uses a lot of cpu.