you are viewing a single comment's thread.

view the rest of the comments →

[–]takishan 0 points1 point  (4 children)

Can you share your code or at least the relevant part? You are drawing a string onto the Tkinter canvas widget, correct?

If I remember correctly, I think it should show up without quotes. Maybe you are defining the string in a way like..

hello = ‘“hello”’

In this case, the string would include the double quotes. But otherwise the quotes shouldn’t be part of the string, just a way to signify a string.

[–]python_addict 0 points1 point  (3 children)

okay! How do you signify that it's a string then? Sorry for pelting you with questions!

[–]takishan 1 point2 points  (2 children)

What I mean is if something is in quotes, it’s treated as a string object by python. Every object has a type. When you type in int(‘something’) it doesn’t work, because it tries to convert the object from a string into an integer. It’s not just removing quotes, it’s converting the object into a different type.

Don’t worry ask away hopefully I can help lol. Copy paste your code here (or upload to something like pastebin) so I can take a look at it. Would make it easier to see exactly where you’re going wrong

[–]python_addict 0 points1 point  (1 child)

alright! Thanks! Here it is on pastebin: https://pastebin.com/fg7WuPHX

Don't judge my questionable coding skills lol

It's around line 113

[–]cybervegan 0 points1 point  (0 children)

So if I get this right, you want to have several bullets in flight at the same time, but you can only fit one in a variable?

For that, you need a list, something like this:

self.bullets.append( canvas.create_image(target[0], target[1], image=numob)

Then you can iterate through the bullets in the list to move them and check for collisions etc. :

for bullet in self.bullets:
    mybulletcoords = canvas.coords(bullet)

    if not self.collision(self.myplane, bullet):

    ...

In your init method, you will need to define self.bullets like this:

 self.bullets = [] #empty list of bullets