Python Game Programming Tutorial: SpaceWar 1
Вставка
- Опубліковано 16 жов 2024
- This is a relatively beginner-friendly tutorial on how to create a classic space shoot'em up using Python, the turtle module, and basic classes. Enjoy!
NEED HELP?
🆘 Watch this first and then let me know in the comments below: • Help Me Help You
❤️❤️ SHOW SOME LOVE AND SUPPORT THE CHANNEL ❤️❤️
Click Join and Become a Channel Member Today!
Channel members can get preferential comment replies, early access to new content, members only live streams, and access to my private Discord.
❤️ / @tokyoedtech
Amazon Affiliate Links
💻 My Laptop (Asus Zenbook 13): amzn.to/2H3DLbF
🎙My New Microphone (Blue Yeti Pro): amzn.to/2HmjOgN
🎙My Old Microphone (Blue Snowball): amzn.to/3j8magh
🎶My USB Interface (Focusrite Scarlett Solo): amzn.to/3kqyo5m
Other Affiliate Links
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. www.kite.com/g...
LINKS
🗄️ GITHUB: github.com/wyn...
💬 Follow me on Twitter: / tokyoedtech
📜 Subscribe to my Newsletter: eepurl.com/dKgM8k
📝 Check out my Blog: christianthomp...
⬇️ Download Geany Editor: www.geany.org
LEARN MORE PYTHON
➡️Space Invaders: • Python Game Programmin...
➡️Snake Game: • Python Game Programmin...
➡️Pong: • Python Game Programmin...
➡️Space War: • Python Game Programmin...
➡️Intro to Python (for Java Coders): • Intro to Python for Ja...
➡️Space Arena - The Ultimate Python Turtle Graphics Game Tutorial: • Ultimate Python Turtle...
LEARN MORE JAVA
➡️Basic Java for Beginners: • Basic Java 1&2: Commen...
➡️Intro to AP Computer Science A: • AP Computer Science Un...
#Python #Tutorial #Beginner
"There's actually a little turtle that starts up but because it's black we don't see it." lol
just came across this and your channel, very interested! will review again on final space invaders tutorial once i get that far!
Great tutorial to getting acquainted with turtle! Thanks for explaining each step of the process in creating the game. Easy to follow. It helped me in creating a Tron light cycle game with similar mechanics.
I have watched your coding falling skies playlist and space invaders playlist and went from absolute beginner to "non-beginner" in python! But I have no knowledge about classes and objects in Python. So should I start this series(coding space war) if don't know anything about classes and objects? Looking for your reply :)
Sorry I missed this. It's worth giving it a shot. I also have a tutorial on OOP on Python - it's probably a good starting point.
Me: Makes SpaceWar and is very happy
My friends: Why don't you make a game like PUBG
Christian Thompson this is also way different. That’s using a game engine and we are coding just using python
@@jackrinderer6790 But those guys don't understand that
Honestly, you make the best tutorials on python.
Do you also make tutorial on pygame?
Christian Thompson thanks,
For anyone having issues with Python 3 (or the "4 but 5 listed" __init__ "..error), please try the following code. By the way, the "__int__ " NEEDS DOUBLE underscores!! Before AND After!! As it took lots of searching in the comments to find out. Thank you so much to TokyoEd for his amazing tutorials by the way. The best programming teacher out there. P.S...Don't forget to paste or copy the" turtle.done() " at the end. I left too big a gap I know.
# SpaceWar by @TokyoEd
# Part 1: Don't forget double "__" before AND after __init__
import os
import random
import turtle
wn = turtle.Screen
turtle.forward(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)\
class Sprite(turtle.Turtle):
def __init__(self, spriteshape, color, startx, starty):
turtle.Turtle.__init__(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed = 1
# Create my Sprites
player = Sprite("triangle", "white", 0, 0)
turtle.done()
Yes - double underscores have a different meaning to single underscores!
Hello! I am at 2:47 and when I run my program, the black window with the title "Python Turtle Graphics" and then the rainbow loading thing starts and I have to force stop Python. I am using PyCharm on my mac. In the past I have followed your Pong tutorial and it works perfectly fine but I wonder what is wrong here. Thanks in advance and thanks for these videos.
Please make this on Pygame I’m using python 3.7 and turtle doesn’t work in it
This is very complicated. Specially from line 17 I dont know about anything you are doing. Can you like post a video about OOP in python from begineer to advanced? Also what is the use of the word self?
Hello. This is from 2016, but is this code still up to date? In other tutorials, it says tracer(0) but in this one it says tracer(1) and it doesn't use Screen().
Hi, so I am having troubles with my code and it says that "The name Sprite isn't defined" so I was wondering if you could help me.
import random
#Import the Turtle module
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def __init__(self, spriteshape, color, startx, starty):
turtle.turtle.__init__(self, shape = spriteshape)
self.speed(0)
self.penup()
slef.color(color)
sef.fd(0)
slef.goto(startx, starty)
self.speed = 1
#Create my sprites
player = Sprite("triangle", "white" , 0, 0)
delay = raw_input("Press enter to finish. > ")
The player = Sprite... Part should NOT be indented.
Thank you, I figured out that there was a lot of wrong things, like for example the way I spelled “self”. Thank you you are the best programming teacher!
@@UsTube. Glad to hear it - keep on codin'!
hey i need your help the triangle is showing in the turtle
#import the turtle module
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class sprite(turtle. turtle):
def _init_(self, spriteshape, color, startx, starty):
turtle.turtle._init_(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed = 1
#create my sprites
player = sprite("triangle", "white", 0, 0)
delay = raw_input("press enter to finish. > ")
on the other tutorials you created the screen with this:
window = turtle.Screen()
window.bgcolor("black")
window.title("Maze")
window.setup(700, 700)
here you do
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht() #hide turtle
turtle.setundobuffer(1)
turtle.tracer(1)
what's the difference?
the former is better.
Hi I know that I'm late but I'd like to understand why the program can't read the sprite. Does anyone of you know if in the 3.8 version there is something different? Anyway I'm sorry for my bad English
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given .
I am getting this error how can I resolve it?
I'm having issues within the first 2 minutes on python 3. The first time you attempt running the code, I do as well. I have also changed raw_input() into just input(). But when I run it, the Turtle Crashes and freezes. All of my code is written exactly the same, minus changes needed for python 3. So what gives?
Believe I may have found a solution. I changed delay = input() to turtle.exitonclick() and it no longer crashes, though obviously clicking anywhere now closes the program
Invalid decimal literal is showing , Brother how to solve this problem.
Can you share the code and error message?
Hi, everytime that the game open it keeps loading until it says that the game stop working, it seems to happen everytime i put the delay = input("Press enter to finish. >"), what can i do?
heres the hole code:
import os
import random
import turtle
turtle.speed(0)
turtle.bgcolor("black")
turtle.hideturtle()
turtle.setundobuffer(1)
turtle.tracer(0)
class Sprite(turtle.Turtle):
def __init__(self, spriteshape, color,startx,starty):
turtle.Turtle.__init__(self,shape = spriteshape)
self.speed(0)
self.penup()
self.fd(0)
self.color(color)
self.goto(startx,starty)
self.speed = 0
#Create the sprites
player = Sprite("triangle","white",0,0)
#delay
delay = input("Press enter to quit. >")
it worked, thanks xD
Great video but i struggle to get it working. Could you do it on the newest version of Python please?
I doubt I'll revisit this - check out Space Arena - it uses many of the same concepts. That said, this should work in Python 3 - what problem are you having?
Super tutorial again (did space invaders first). But turtle.fd -> needed for Mac OSX or else it would show -> You didn't do that for the space invaders and it also worked. What's the difference?
Check -> learning along with you ;)
2 minutes in and it already doesn't work, python doesn't like that raw_input, not defined. Does turtle come preinstalled or do we have to install it first?
@@sebastianmackay5657 Change raw_input to input
@@TokyoEdTech thanks
@@sebastianmackay5657 Sure thing. Keep on codin' and please subscribe!
Doesn't the turtle.bgcolor mean wn.color?
Sir what additional apps should we install
can u help me
it keeps saying raw_input is not defined and i dont know what to do. here is my code:
import os
import random
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
delay = raw_input("Press enter to finish. > ")
Sure. Change it to input. That was a change between Python 2 and Python 3.
????
Change raw_input to input
@@TokyoEdTech thank you so much! your videos are awesome!!1
@@YarekTech Thanks! Keep on codin'...and please subscribe!
Hello Sir, It is coming that "Type error : __init__() takes from 1 to 4 positional arguments but 5 were given
Can you please help me??
🙏
Hi. Everytime you have a problem, remember this: I’m happy to help, but I need to see the actual code. Please share your code via pastebin.com link so I can download and test it. To learn how, please watch this video and then get back to me: ua-cam.com/video/L6AwVuu6O3Y/v-deo.html Keep on codin’!
Hi Christian sir ,is this code suitable for Python 3.8and also need to to now how to get pycharm to our laptop . my laptop is very old version will it work with my system .need your help
I think it will mostly work in Python 3 - might need a few changes. I wouldn't use Pycharm if you have an old laptop - try Geany instead.
@@TokyoEdTech ok sir tq so much
@@TokyoEdTech sir can you give me a code for chess please
@@anish8373 I haven't really done chess - I started a version of it, but haven't had a chance to finish it yet. You should be learning how to do things on your own, not just copying from others.
i m getting "raw_input is undefined"..please help..
Try input instead.
@@TokyoEdTech okay i will try and reply..
@@TokyoEdTech tyy so much it workedd....tyyy
Traceback (most recent call last):
File "C:\Users\Vince Swu\Desktop\Projects\Space War.pyw", line 26, in
player = Sprite("triangle", "white", 0,0)
TypeError: __init__() takes at most 4 positional arguments (5 given)
>>>
There is a link in the description labeled “NEED HELP?” Check that out and get back to me. Keep on codin’!
I'm writing this in 2022 and in python 3.10 IDLE. Is there possibly a different way that would still work to write this code and is more efficient? Thank you.
Hiya. I'm not sure about making it more efficient; however, I would probably not make the Sprite class a child of the Turtle class. If you check out my Space arena tutorial, I only created one turtle and used that to render all the game objects. This simplifies things a bit, and would you allow you to more easily port the game, for example, to Pygame.
Hi!
When i run the script it says:
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
Here is the script i've written:
import os
import random
# the turtle
import turtle
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def _init_(self, spriteshape, color, startx, starty):
turtle.Turtle._init_(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed = 1
#Create the sprites
player = Sprite("triangle" , "white" , 0, 0)
delay = input ("Press enter to finish. > ")
please help me with this, otherwise a great tutorial.
No...
No, i´m not.
Fixed it! Thanks for a quick response. =)
'py' is not recognized as an internal or external command,
operable program or batch file.
hey, how do i solve this problem?
Can you share your code and the full error message? Copy and paste them here.
Do you think you can make a video that makes the level and the lives of the player
Hello i want to tell you that I am a great fan but I have got something to tell you :
All your tutorials worked on my computer but this one, not at all! I am on windows and on python 3.9. I wrote exactly like you but I don't know why it didn't work :(. Please move on python 3 and make more tutorials! Glad to speak with you! Have a nice day!
Hi Christian! Thank you so much for this tutorial. I'm currently using Python 3.8.5 with Psycharm and I'm having a bit of problem. Every time I try to run my code, the window keeps freezing and saying "Not responding". Do you know if there's anything I can do to fix this?
I’m happy to help, but I need to see the actual code. Please share your code via pastebin.com link so I can download and test it. To learn how, please watch this video and then get back to me: ua-cam.com/video/L6AwVuu6O3Y/v-deo.html Keep on codin’!
The Reason This Happens, Is If You Are Running Python 3, and Trying To Convert The Code, turtle.setundobuffer(1), combined with turtle.tracer(1), don't really like to work well together. If I were you, I would just switch to python 2.7, and then go back to 3.
Is there a way to make the spaceship not use 8 directional movement but rather have it rotate around smoothly?
Yep. Just like you do with dx and dy, you can do the same thing with da (change in angle).
how to do the code for winning the game and losing the game like the first vid?
sir there is the not responding problem how can i fix that ??
@@TokyoEdTech thankyou sir
here is the link
pastebin.com/UXgiYyUd
I'm having a problem in it, i am doing everything as shown but my turtle wont appear. The error says that _int_ only accepts 1 to 4 positional arguments and i am giving it 5. But it worked just fine for you. Can you help me out? Here is the code -
#Importing everything
import os
import random
import turtle
#Starting
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("sky blue")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def _init_(self, spriteshape, color, startx, starty):
turtle.Turtle._init_(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed = 1
#Creating the sprites
player = Sprite("triangle", "green", 0, 0)
And here is the error -
Traceback (most recent call last):
File "C:/Users/admin/Desktop/Python/Project/Sky Strike.py", line 26, in
player = Sprite("triangle", "white", 0, 0)
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
I am currently working on Python 3.7.0
Christian Thompson Hey got it again, another silly mistake, I didn't type two underscores before and after init, so that was causing the error. I really do make a lot of mistakes in coding, gotta watch out for it from now on.
@@TokyoEdTech hi Christian can you help ill send you the link
@@TokyoEdTech pastebin.com/fbnstHE2
Thanks so much I can now finally make the game best UA-camr out there
@@TokyoEdTech it's still happening
Hey!
I just want to ask, whether this is possible on Python 3.8.5 because I'm currently stuck at 2:17. I tried using the same steps and it doesn't seem to work...
Here is my code, if you want:
import os
import random
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
delay=input("Press enter to finish.")
Please let me know the problem in the code (if there is any).
Thanks!
Hi Jonathan! For the most part it should work fine. What isn't working?
TokyoEdTech It shows that the turtle part is undefined, because it doesn’t recognise the variable...
@@JP22_007 Are you using Pycharm? If so, you can ignore those warnings.
@@TokyoEdTech I am not using Pycharm. I am using Visual Studio Code. Anyways, it works but it still shows these errors.
Thanks for helping!
Those are not errors - they are warnings. There were changes in the turtle module from Python 2 to 3 so that is why that happens.
You are the best teacher!
hii i have created levels in the game but i want to increase the speed of enemys in every level plz help i tried creating a speed increasing function but it didn't helped plz help
Hiya - can you share your code (copy and paste here is fine) and I'll take a look?
@@TokyoEdTech
class Enemy(Sprite):
def __init__(self, spriteshape, color, startx, starty, initial_speed):
Sprite.__init__(self, spriteshape,color, startx, starty)
self.speed = initial_speed
self.setheading(random.randint(0, 360))
def move(self):
self.fd(self.speed)
# Border checking and changing direction if necessary
if self.xcor() > 290 or self.xcor() < -290 or \
self.ycor() > 290 or self.ycor() < -290:
self.rt(180) # Turn around if hitting the border
def update_speed(self, new_speed):
self.speed = new_speed
def show_status(self):
self.pen.clear()
self.pen.undo()
self.pen.penup()
self.pen.goto(-300, 310)
self.pen.write("Level: {} Score: {}".format(self.level, self.score), font=("Arial", 16, "normal"))
if self.score >= 300 * self.level:
self.level += 1
#self.score -= 100 * (self.level - 1) # Adjust score for next level
#self.enemies.append(Enemy("circle", "red", -100, 0))
self.pen.goto(0, 0)
self.pen.write("Level Up! You've reached Level {}".format(self.level), align="center",
font=("Arial", 24, "normal"))
time.sleep(1)
self.update_colors()
self.update_enemy_speed()
def update_enemy_speed(self):
new_speed = self.initial_enemy_speed + (self.level - 1) * self.enemy_speed_increment
for enemy in self.enemies:
enemy.update_speed(new_speed)
print("Enemy speed updated to:", new_speed)
plz take a look and give some solution
@@hemantdhakers3014 Did you copy and paste your code?
@@TokyoEdTech
class Enemy(Sprite):
def __init__(self, spriteshape, color, startx, starty, initial_speed):
Sprite.__init__(self, spriteshape,color, startx, starty)
self.speed = initial_speed
self.setheading(random.randint(0, 360))
def move(self):
self.fd(self.speed)
# Border checking and changing direction if necessary
if self.xcor() > 290 or self.xcor() < -290 or \
self.ycor() > 290 or self.ycor() < -290:
self.rt(180) # Turn around if hitting the border
def update_speed(self, new_speed):
self.speed = new_speed
def show_status(self):
self.pen.clear()
self.pen.undo()
self.pen.penup()
self.pen.goto(-300, 310)
self.pen.write("Level: {} Score: {}".format(self.level, self.score), font=("Arial", 16, "normal"))
if self.score >= 300 * self.level:
self.level += 1
#self.score -= 100 * (self.level - 1) # Adjust score for next level
#self.enemies.append(Enemy("circle", "red", -100, 0))
self.pen.goto(0, 0)
self.pen.write("Level Up! You've reached Level {}".format(self.level), align="center",
font=("Arial", 24, "normal"))
time.sleep(1)
self.update_colors()
self.update_enemy_speed()
print("Level increased to:", self.level)
def update_enemy_speed(self):
new_speed = self.initial_enemy_speed + (self.level - 1) * self.enemy_speed_increment
for enemy in self.enemies:
enemy.update_speed(new_speed)
print("Enemy speed updated to:", new_speed)
hi, it says
ModuleNotFoundError: No module named 'tkMessageBox'
Oh hi again its working now 😊.
I have a question why does it lag everytime i shoot? Is it because of my laptop?
The code player = Sprite("triangle", "white", 0, 0) is not working pls tell me why.
and here is the error message : Traceback (most recent call last):
File "C:/Users/admin/Desktop/Space war.py", line 23, in
player = Sprite("triangle", "white", 0, 0)
TypeError: __init__() takes at most 4 arguments (5 given)
Where's the code?
@@TokyoEdTech import os
import random
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def _init_(self, spriteshape, color, starx, starty):
turtle.Turtle._init_(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(starx, starty)
self.speed = 1
player = Sprite("triangle", "white", 0, 0)
delay = raw_input("Press enter to finish. > ")
Do you have TWO underscores before and after init?
@@TokyoEdTech Yeah one before init and one after init
You need 2 before and 2 after (4 total).
i am not able to run sound in windows 11 can you plz help it's urgent.plz share code of sound in windows
Howdy. Check out this video: ua-cam.com/video/1FyqFqAN9UM/v-deo.htmlsi=DjHbgi7kbbcHgP98
Can you convert to Python 3. New here
Sir, when will you add the full part including lives and game over screen.
@@TokyoEdTech sir please update with more parts also.
@@TokyoEdTech yes sir
@@TokyoEdTech yes sir I have completed them all.
@@TokyoEdTech a game over and play again screen when the score become zero
@@TokyoEdTech the score is going to negative and nothing happens
Which software have you used
You’re in luck - I’ve made a video about this exact topic. Enjoy! ua-cam.com/video/4bL-lCP2tec/v-deo.html
@@TokyoEdTech thank you sir
which IDE are you using?
That is a good question
can you make one for python 3?
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
please help me
import os
import random
#Import the Turtle module
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def _init_ (self, spriteshape, color, startx, starty):
turtle.Turtle._init_(self, shape = spriteshape)
self.speed(0)
self/penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed = 1
#Create my sprites
player = Sprite("triangle","white",0, 0)
delay = input("Press enter to finish. > ")
same thing what do u do to fix it!?
AttributeError: 'Sprite' object has no attribute '_shown'
pls help
I already fixed it.Don't reply.
I really wanted to create the game, but I can't the code doesn't really all work well in python 3 : (
@@TokyoEdTechThe first error message I got is the raw_input one. Isn't that working in python3?
@@TokyoEdTech But, I guess I'll make it in python2 I'll try to make it first again :). By the way, thanks for your attention and help!
@@TokyoEdTech ooh, thanks
I'm getting an error and all turtle._____ turtle has no fd or speed member.
Here is the error message: Python37-32\lib\turtle.py", line 2488, in __init__
self._setshape(shapeIndex)
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\turtle.py", line 2502, in _setshape
self._type = screen._shapes[shapeIndex]._type
KeyError: 'tringle
'
here is the program: pastebin.com/fvkcrJp0
Vrenium I have the same problem I think
Thank you so much 😊
hii plz help me sir
how to end this game using enter
Hiya,
If you follow the tutorial, you should be able to get most of the way there.
We already have:
turtle.onkey(bullet.fire, "space")
So, you can try this:
turtle.onkey(exit, "return")
If you get a keysym error, try:
turtle.onkey(exit, "Return")
@@TokyoEdTech on pressing enter program is stopped but
It is showing not responding when I want to cross the program
Can you give me the link for downloading the python turtle module?
Christian Thompson ok thx
It's already built-in to python
which code editor r u using bro!!
I think he using visual studio code.
Traceback (most recent call last):
File "C:/Users/Shara jane diaz/AppData/Local/Programs/Python/Python36-32/SpaceWar.py", line 26, in
player = Sprite("triangle", "white", 0,0)
TypeError: __init__() takes at most 4 arguments (5 given)
>>>
I have the same problem, did you solve it yet?
Yes
same
how did you solve it?
sorry but can what python is that
Where you got the image from?
Check out openclipart.org
when I type in “input random” it is gray
It should be "import random".
Also, save your file first.
it says "'raw_input' is not defined"
Try input instead.
What program are you using?
Python
ah, thank you for replying so quickly lol, in the time since I posted that comment, I learned Python, C++, Java, Javascript, PHP, HTML, CSS, C# and am in a college course for software engineering@@UsTube.
@@ScorpionCA 6 years ago😂
Time flies!
can get the link
Check here: christianthompson.com/node/47
NameError: name 'raw_input' is not defined
Hi. Change raw_input to input
if the raw_input doesnt work for normal python try using pycharm it works for me
raw_input is for Python 2.x. Change it to input for Python 3.x.
@@TokyoEdTech ok but now i have another problem when i type raw input it works but now since weve written while true it doesnt show up
@@TokyoEdTech also remember coding and gaming the guy u subbed to well this is my other account coding and gamings my main account
@@nehavipul Hard to keep up! I need to see the actual code. Please share your code via pastebin.com link so I can download and test it. To learn how, please watch this video and then get back to me: ua-cam.com/video/L6AwVuu6O3Y/v-deo.html Keep on codin’!
@@TokyoEdTech ok
We you got the image from
Usually I use openclipart.org
cant seem to use it... i have mac osx though
Weird - I'd have to see the code and the error message to be able to help.
sprite color is not working
Isn’t this asteroids ? I’m preparing the same project with JavaScript - cheers from Poland
Basically!
wonderful
Thanks!
Name error '__init__' is not defined please help.
Hmmm...can you share all the code here?
Have you written "def" infront of __init__? You define the constructor, dont call it.
can you please please write the whole code of the game
You're in luck - here it is! github.com/wynand1004/Projects/tree/master/SpaceWar
@@TokyoEdTech GOAT
@@inzaneaztec LOL - thanks!
What text editor is that? Nice video, btw.
Pycharm I think
@@TokyoEdTech is it good?, I tried but it's not the same
where an i download this phyton coding program??
These days I'm using Geany: www.geany.org/
Can you run this on python idle
Sure!
does this only work on Mac? because I use windows to do python code
Mostly everything except the sound code is cross platform.
They say raw_input is not defined 😟
@Susamogus557 yeah bro I did that, that was like more than 3 years ago, and it is with the new python
I sent you and I'm working on python 3.8.2
i guess i have to do input instead of raw input
I am doing this on phone
It says this error
File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 8
turtle.bgcolor(''black'')
^
SyntaxError: invalid syntax
Can you share the code?
Can u do a GODOT game in future ❤️
Maybe someday - definitely want to play around with it!
@@TokyoEdTech yeah it would be great❤️
id love to watch this but the white background is burning my retinas. if you ever decide to make a video in dark mode, let me know!
@@charliebrown1947 #firstworldproblems
@TokyoEdTech 50 inch oled HDR 4k screens are a hell of a drug
Python turtle graphics is not responding. Help
I'll respond to your other post on the same subject.
@@TokyoEdTech He said you need a Mac OS to run the program lol
@@subtheman2136 It will work on Mac, Windows, and Linux.
python2 or python3 just started to watch
This one is Python 2.
Can you please make this game in python 3
For the most part, it will work in Python 3. Give it a shot and see what happens.
@@TokyoEdTech Okay, but I don't know the syntax for python 2 😕
@@vj4007 Just watch the video and try it.
@@TokyoEdTech Alright, let's see what happens.😁
@@vj4007 Good luck!
Please make this game with python 3.8, please it's my request
@@TokyoEdTech I'm confused that is there any syntax change in python 2.7 and 3.8
@@TokyoEdTech like in other games we have used
wn = turtle.Screen()
And other functions
@@TokyoEdTech Actually I'm trying this from a week, and also I have to submit a python game for my project based on python 3.8 and I am getting error while trying the new one, that is why I think that you are the only one who can help me.
@@TokyoEdTech Can you please make a new one video just changing the syntax or please provide me the code, I have tried very much but not able to get the write one
your great !
I'm getting the following error, which 2 others have posted. Per your instructions, here is my code -
pastebin.com/37ct3nf5
Using 3.8.6 if that helps.
Traceback (most recent call last):
File "C:/Users/Eli/Documents/coding/python/space fight.py", line 26, in
player = Sprite("triangle", "white", 0, 0)
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
For def __init__ you need TWO underscores before AND after the init
@@TokyoEdTech thank you
@@havenanimates1979 You're welcome.
nothing name raw_input
Change raw_input to input
THe Brazilian Laught you man - plz send me code!
me seeing christian doesnt use wn = turtle.Screen() for the window setup
*cursed*
It's an outlier!
I hate python Because python have so much errors
A) It's not the language, it's the programmer.
B) This tutorial is not beginner friendly - I'd try something easier and then come back to this.
me too
My code keeps saying:TypeError: Turtle.__init__() takes from 1 to 4 positional arguments but 5 were given here is my code
import os
import random
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)
class Sprite(turtle.Turtle):
def _init_(self, spriteshape, color, startx, starty):
turtle.Turtle._init_(self, shape = spriteshape)
self.speed(0)
self.penup()
self.color(color)
self.fd(0)
self.goto(startx, starty)
self.speed= 1
player=Sprite("triangle", "white", 0, 0)
Hi there.
Do you have two underscores before and after init?
No @@TokyoEdTech
Never mind, thank you
@@anthonyzhu7464 You're welcome.
Help me resolve the issue
Traceback (most recent call last):
File"C:\Users\M.Waleed Mustafa\PycharmProjects\pythonProject\main.py", line 18,in
Player = Sprite("triangle", "white", 0,0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Turtle.__init__() takes from 1 to 4 positional arguments but 5 were given
Process finished with exit code 1
Can you share all of the code so I can take a look?
@@TokyoEdTechI'm having this issue to is there a way to send you screenshots of it please
I'm stuck on it and can't move further
@@NutcasePodcast77 You can copy and paste the code and error message here.
@@TokyoEdTech will do thanks sir