I’m making a programming game for kids to learn to program using processing and python. It involves a wombat which picks up leaves in tiles and there may be some obstacles like rocks. This might be familiar to you if you did something in Greenfoot. I am making it in python though, and have little experience with Processing.
The wombatgame file runs the game. The leaves, rocks, world, and wombat are objects. A world is created with a wombat and some leaves. I then have a player class which is where the kids will program the wombat to do certain tasks. In the code(main method in player class) included I have a wombat which makes 4 steps in the direction it is facing.
The problem is that the wombat will move(x and y variables are changing for it) but it won’t display every movement until the end. It teleports instead of showing the user every step graphically. I commented out the world.play() user code in the draw() function because that is not where I want to put it. It teleports because it can only update the screen though world.display() when the world.play() method has finished. I call redraw in the wombat class after a movement which should run the world.display() method but it doesn’t do the code in the draw() function(which has world.display()) until world.play() is finished. I need to figure out how to redraw while running world.play()
Here is the code:
Any suggestions on how to improve the code or organization of the game are welcome.
I know that time.sleep() is a blocking command but I want it to block because then the animation will be slower right? If I didn’t have time.sleep() it would pretty much teleport because it wouldn’t have to wait in between walk commands.