Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Moving with objects simultaneously

I'm currently working on my project and stucked at this point:

I want to create a canvas, where different objects will move (a lot of game NPCs). But whilst they are moving, I want to be able to do a different things in canvas, like buying items for a game and so on. And the point I got stuck in makes me feel that the way how do I want to let canvas do different things simultaneously is quiet wrong.

class Class1:

    def __init__(self):
        self.canvas = tkinter.Canvas(width=500, height=500, bg="white")
        number = x

    def create_npc(self):
        for i in range(number):
            self.npc = NPC(self)


class NPC:

    def __init__(self, class1):
        self.main = class1

    def place_npc(self):
        self.object_npc = self.main.canvas.create_image(some_x, some_y,['self.car_image_1']) #there is a dict with all car images

    def move_npc(self):
        while True:
            self.main.canvas.move(self.object, 10, 0)
So I want to let this object move, after it is created in 'def create_npc' as one of 'number' NPCs. But instead, it creates just one NPC, and actually my tkinter canvas never opens, because while True is still running. Can you help me please? Is there any way how could I say "don´t care this method is running, just continue with executing next lines of program"?
use multi-threading
Age Doesn't Matter, Your Passion Does
- Shreya Jain

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Spyder/Anaconda can't import objects from Vpython module AntonRuscov 0 29 7 hours ago
Last Post: AntonRuscov
  An Object of Objects? cebb 4 210 Jul-28-2019, 03:29 PM
Last Post: cebb
  rotating and resizing objects jenya56 3 169 Jul-26-2019, 12:06 AM
Last Post: scidam
  Moving to the next character 357mag 2 148 Jul-05-2019, 10:26 AM
Last Post: snippsat
  Does XLRD have a method to extract embedded objects (pdf) from an excel sheet? matthewme 1 199 Jun-13-2019, 10:00 PM
Last Post: Larz60+
  Creating Dynamic Objects MacFie 4 331 Jun-13-2019, 02:48 PM
Last Post: MacFie
  Control 2 stepper motor simultaneously jihene 2 257 May-08-2019, 05:27 PM
Last Post: DeaD_EyE
  Generating number of objects for a game kom2 3 265 Apr-18-2019, 02:04 PM
Last Post: dan789
  Why is this pointing to the objects hshivaraj 6 283 Apr-09-2019, 10:55 PM
Last Post: hshivaraj
  How to redefine object so that all user- objects have the necessary capabilities? AlekseyPython 5 367 Mar-03-2019, 04:25 AM
Last Post: AlekseyPython

Forum Jump:

Users browsing this thread: 1 Guest(s)