Simple Minecraft Clone in 580 lines of Python
81–90 of 113 posts
Re: Simple Minecraft Clone in 580 lines of Python
#82Jump speed is too fast... if you slow it it works better and is more like minecraft IMHO elif symbol == key.SPACE: if self.dy == 0: self.dy = 0.500 # jump speed
self.dy = 0.050 # jump speed
Jump higher for more fun...
Re: Simple Minecraft Clone in 580 lines of Python
#83These seemingly "big" games written in a handful of lines of code always make me feel very, very stupid. I know if I made this, I could easily imagine writing 50,000 lines. How do people do this? How do their minds work?
That is, I would write something in the first, most-obvious way that occurred to me. Then, recognizing patterns, I would refactor it down to something smaller. Usually this repeated a few times, until the 100ish lines of code I wrote turned into 10 or 20.
Python gives a programmer a lot of help in reducing redundant code. It makes C#/Java/etc. feel really tedious with all of the boilerplate code you end up writing.
tl;dr: DRY
Re: Simple Minecraft Clone in 580 lines of Python
#84Just grab Pyglet trunk and install it, and run main.py with pypy instead of with CPython.
Re: Simple Minecraft Clone in 580 lines of Python
#85Re: Simple Minecraft Clone in 580 lines of Python
#86Pyglet is vastly more pythonic than pygame for writing games. I have found it much easier to teach pyglet for newcomers and the code is easier to read too. Since it uses ctypes, it is very easy to port pyglet to a platform that supports OpenGL. Unfortunately there is very little momentum in the project. Last year an alpha version was released after a gap of two years. I truly hope that pyglet gets the popularity it d…
PyOpenGL is by far the most pythonic of them all, though this comes at the cost of being around 4x slower than pyglet. Pyglet is a good compromise between the two.
Re: Simple Minecraft Clone in 580 lines of Python
#87Earlier quoted context omitted.
Simple Dwarf Fortress Clone in 58000 lines of Python
Lispers that preach of concision mere mortals cannot possibly dream of, this is your call to arms.
I started with python. I've had lots of problems with it, but I'm far stronger in python than anything else, so have been in a sense stuck on it despite separate attempts over the last twelve months to get to momentum in C, C++ and racket.
During the recent 7-day roguelike challenge I found myself still stuck on my old python codebase, now creating DSLs in order to define entities and relationship opportunities between them (e.g. water -> planted_seed = sapling). I found I was able to significantly reduce code size, it's cleaner, and it's far sturdier. That was the point where I realised I needed to drop everything and make the jump to scheme, which I've been doing since.
This derailed my 7-day roguelike effort a couple of weeks ago, but it's progress.
OT, but another benefit I've found is that it's trivial to write zero-dependency, multiplatform code in racket. "raco exe main.rkt".
Whereas getting that done with with python is fiddly. With the previous game I released, I spent more time trying to get exes for the major platforms than I did on everything else combined.
Re: Simple Minecraft Clone in 580 lines of Python
#88Earlier quoted context omitted.
Take a look at the code, it's not THAT hard when you have the right tools (language, libraries, knowledge...) though it's quite awesome nonetheless. IMHO the game actually shows how powerful Python + Pyglet (OpenGL actually) are. Wanna get your mind blown even harder? Check some 4kb demos[1]... and that's binary size! No JVM/Python runtime supporting it. [1] http://www.youtube.com/results?search_query=4kb+demo&pag...
While demoscene stuff is seriously impressive most are using a shit load of DirectX to do what they do in such a small size. They are not bare metal demos.
(DirectX + 4kb) vs. (OpenGL + Python + Pyglet + 500LOC)
=
4kb vs. (Python + Pyglet + 500LOC)
Long are gone the days when you could manage the framebuffer yourself :) Specially if you want to run the demo in modern OSes.Re: Simple Minecraft Clone in 580 lines of Python
#89Re: Simple Minecraft Clone in 580 lines of Python
#90Earlier quoted context omitted.
Take a look at the code, it's not THAT hard when you have the right tools (language, libraries, knowledge...) though it's quite awesome nonetheless. IMHO the game actually shows how powerful Python + Pyglet (OpenGL actually) are. Wanna get your mind blown even harder? Check some 4kb demos[1]... and that's binary size! No JVM/Python runtime supporting it. [1] http://www.youtube.com/results?search_query=4kb+demo&pag...
I still remember how I was blown away when seeing .kkrieger[1][2] for the first time, introducing me to the potential of procedural assets in games. [1] http://en.wikipedia.org/wiki/.kkrieger [2] http://www.youtube.com/watch?v=2NBG-sKFaB0
It's in Farbrausch's GitHub with many more demos/demotools https://github.com/farbrausch/fr_public