How to Make 2D Minecraft in Python - Part One: Moving the Character Around
Making 2D Minecraft With Python: Part One
In this we will be doing the basic movements of the turtle. So first we will do all the imports and starting up stuff like Screen, Turtle, shape, and other stuff. So start by putting this into your code:
Now we’re going to check if the Up button is pushed (using the onkey function so we don’t have to push enter!). So type this in to your code:
Now we can do backwards left and right!
At the end of all the code it should look like a square on a white screen that you can move around with the arrow keys
Hi, I am getting this error after writing down code:
Traceback (most recent call last):
File "main.py", line 3, in <module>
mover = turtle.Turtle()
File "/usr/local/lib/python3.8/turtle.py", line 3812, in init
Turtle._screen = Screen()
File "/usr/local/lib/python3.8/turtle.py", line 3662, in Screen
Turtle._screen = _Screen()
File "/usr/local/lib/python3.8/turtle.py", line 3678, in init
_Screen._root = self._root = _Root()
File "/usr/local/lib/python3.8/turtle.py", line 434, in init
File "/usr/local/lib/python3.8/tkinter/init.py", line 2261, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Can anyone please help me with this? Sorry, I am a newbie
turtle is a package, and on repl.it, you need to get the proper repl for the package. If you were running on Linux or something, once you have installed python (sudo apt install python3 I think), you would just
import turtle, and it would open a new window.
I was scared that I posted my tutorial without knowledge of this, Phew turns out they are different, nice tutorial anyway!
This code works for me
Edit: I ran this on Python Turtle, not Python 3.8 or 2.7 .
This is an error on pygame! This code is wrong since it is so obvious that the code is so short
Thanks! It's a really cool program. I learned a lot of Python Turtle, which I find interesting.
Also, when will the second part come out? I'm really hyped now!