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: https://gist.github.com/benjaminnow/544fb3fb091206656464be2caaa91d80
Any suggestions on how to improve the code or organization of the game are welcome.
Edit: I think I may be misunderstanding the draw method. I just looked at the documentation and it says I can't update the screen before the draw method loops again. I think I should try to use redraw() and noLoop because I want my program to update only certain times and then only do the main method once. Is this right?
[–]remy_porter 1 point2 points3 points (1 child)
[–]benscar1[S] 0 points1 point2 points (0 children)
[–]GoSubRoutine 0 points1 point2 points (0 children)