Spectrum-Environment for Pygame

Show us what you're working on, (preferably with screenshots).
FFoulkes
Berk
Posts: 30
Joined: Thu Feb 07, 2019 2:42 pm

Spectrum-Environment for Pygame

Post by FFoulkes » Wed Feb 13, 2019 9:53 pm

Hi there,

a Spectrum-esque environment in Python/Pygame:

Image

Although it's amazing to program the real (or emulated) Spectrum in C, for me it's also rather exhausting.
On the other hand, I know Python quite well, and Pygame would be ok.
I've never seen a really good game in Pygame, though. Maybe it needs some limitations to give it a frame.
dfzx pointed out, that in games programming on the Spectrum, you mostly poke everything directly into the screen buffer. I though, maybe I could do that in Pygame and make it look (and feel) really Spectrum-like.
Well, that's how far I've come (in a few days yet):

- Can set border and paper,
- can plot something (256x176),
- can set coloured paper-spots (32x22),
- can write like "PRINT AT".

I'm not sure, how fast this is (fast enough for "Manic Miner"?). But hey, if a 3.5 Mhz Z80 can beat your libraries on today's Ghz-PC, the libraries wouldn't be worth it anyway.

What do you think?

By the way: Can I get in trouble, when I use the Spectrum's charset (stripped from its ROM), its look-and-feel or the words "Spectrum" and "ZX" in my code?
0 x

FFoulkes
Berk
Posts: 30
Joined: Thu Feb 07, 2019 2:42 pm

Re: Spectrum-Environment for Pygame

Post by FFoulkes » Thu Feb 14, 2019 4:54 pm

The exercise from here.

Remember: The screenshot doesn't show an emulator-screen, but a Pygame-screen.
Code-snippet is as easy as this:

Code: Select all

        self.zxenv.printAt(10, 6, "CONNECT 4")
        for i in range(11, 18, 1):
            for u in range(10, 16, 1):
                self.zxenv.printAt(i, u, chr(144), "blue", "white")
UDG-definition was much easier than expected: Just added another tuple with 8 numbers to the charset-dictionary with key "chr(144)".

Image

Cool. :)
0 x

FFoulkes
Berk
Posts: 30
Joined: Thu Feb 07, 2019 2:42 pm

Re: Spectrum-Environment for Pygame

Post by FFoulkes » Fri Feb 15, 2019 1:05 am

I just realized, in my environment, I'm not limited to the Spectrum's memory. So I can have more than just 22 UDGs. In fact, I can have as many UDGs as a Python-dictionary can hold entries. That is, about as many as I want. Thousands.
0 x

dfzx
Microbot
Posts: 170
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Spectrum-Environment for Pygame

Post by dfzx » Fri Feb 15, 2019 8:06 am

But... but... but... it's not a Spectrum, is it?

It's an environment on a modern machine which looks a bit like a Spectrum, but uses modern technology to circumvent the restrictions of the original, which in turn removes most of the challenge. And the challenge of getting the most out of the 1980s technology is what keeps us drawn to the machine.

Not that I'm knocking you for what you're doing - whatever floats your goat - but a Spectrum with thousands of UDGs isn't a Spectrum for most of us.
0 x

FFoulkes
Berk
Posts: 30
Joined: Thu Feb 07, 2019 2:42 pm

Re: Spectrum-Environment for Pygame

Post by FFoulkes » Fri Feb 15, 2019 3:03 pm

dfzx wrote:
Fri Feb 15, 2019 8:06 am
But... but... but... it's not a Spectrum, is it?
True, it's not a Spectrum ... I'm sorry.

I guess everybody has his own approach to this. You're probably quite happy with the "Spectrum Next" too.
I thought, hmm, 3.5 Mhz, do I want that today, still?
It's more the look and feel that I love. The simplicity of just one set graphics mode. The ability to populate it with text and colour easily, wherever you like. Draw lines with a single command. I always liked that.
(Wasn't that easy on other machines. Think of C64, Amiga or PC. Could you just do a "PAPER 4"? No. That kind of thing.)

And I always wanted to get into Pygame; so this project is a good motivation for me.
You're mileage may vary. That should be ok.
------

By the way: I'm also not limited to the traditional 8x8-matrix. I can draw pixel-art of whatever size, which makes those things sprites, I guess.
0 x

Ralf
Dynamite Dan
Posts: 1306
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Spectrum-Environment for Pygame

Post by Ralf » Fri Feb 15, 2019 5:14 pm

As long as you have fun, do it :)

It's not Spectrum but it has been done before - take Zx Spectrum Basic, take some features of it that you think that are cool, add some new features and program it in some modern language on a modern computer.

There was once a project called SpecBas which did a bit similar stuff:
https://sites.google.com/site/pauldunn/
0 x

hikoki
Manic Miner
Posts: 400
Joined: Thu Nov 16, 2017 10:54 am

Re: Spectrum-Environment for Pygame

Post by hikoki » Sat Feb 16, 2019 7:03 am

Interesting project. It would be cool to code Spectrum games in a subset of Python. Learn Python and see what the interpreted results would be like in a real Spectrum without compiling! Who knows if the subset could be assisted by the ide so the result was compatible with cython code which in turn would be compatible with z88dk C
0 x

User avatar
PeterJ
Site Admin
Posts: 1344
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Spectrum-Environment for Pygame

Post by PeterJ » Sat Feb 16, 2019 7:22 am

There is a full Spectrum Emulator written in Python and Pygame here;

https://www.pygame.org/project-PyZX-173-.html
0 x

hikoki
Manic Miner
Posts: 400
Joined: Thu Nov 16, 2017 10:54 am

Re: Spectrum-Environment for Pygame

Post by hikoki » Sun Feb 17, 2019 12:40 pm

Clivethon would only provide a tiny subset of the huge Python language. Clivethon programs would be able to run in Python 3 so that any knowledge gained in learning Clivethon will transfer directly to learning Python. Besides the teaching scope, there you go the sweet part of the deal, Clivethon programs could be translated into Z80 so coool machine cooode!
SpoilerShow
You decide if we are indeed Mr Pixel's offspring trying to inspire the world. :)

There you go come and go some links to inspire the world.

Translate Python into assembler
https://benhoyt.com/writings/pyast64/

DSL with Python
https://dbader.org/blog/writing-a-dsl-with-python

Python-subset interpreter
https://github.com/louisyang2015/interpreter

http://techfeast-hiranya.blogspot.com/2 ... on-on.html

Irony for NET
https://www.codeproject.com/Articles/25 ... t-Compiler
0 x

User avatar
ZXDunny
Manic Miner
Posts: 242
Joined: Tue Nov 14, 2017 3:45 pm

Re: Spectrum-Environment for Pygame

Post by ZXDunny » Sun Feb 17, 2019 11:43 pm

Ralf wrote:
Fri Feb 15, 2019 5:14 pm
As long as you have fun, do it :)

It's not Spectrum but it has been done before - take Zx Spectrum Basic, take some features of it that you think that are cool, add some new features and program it in some modern language on a modern computer.

There was once a project called SpecBas which did a bit similar stuff:
https://sites.google.com/site/pauldunn/
It's still going: https://www.youtube.com/user/ZXSpin/videos

And still under development.
0 x

Post Reply