I've searched far and wide on the internet and can't find a suitable situation for running my two functions at once. Basically, one function contains the code for using arrow keys to move a smiley face around, and the other one makes a red circle fall from the top of the screen. Here is my code in main.py
:
import game, prepare
from multiprocessing import Process
prepare.setuppygame()
prepare.setupSM()
prepare.setupRC()
#display score for the first time
prepare.disscore()
#set starting positions for first time
game.setStartingPositions()
if __name__ == '__main__':
p1 = Process(target=game.go)
p1.start()
p2 = Process(target=game.RCfall)
p2.start()
p1.join()
p2.join()
I'm not getting one screen with a falling circle and the ability to move around a smiley; I get one screen with a smiley that you can move around and another pygame screen that has a falling circle, but not together. Why isn't multiprocessing working? I'm also open to using threads, if they would work.
Infrastructure: Geany, Python2.7, Windows 7 but programming for Raspberry Pi
I believe going through this tutorial on the pygame website
http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html
will give you an idea on how to simply accomplish what you want. It shows how to make an image move by itself on the screen while you move a control image with the cursor. Not precisely what you want but pretty damn close.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.