Question

I found Pong Game made in Kivy and trying to develop it further just for my own learning purpose. But it is difficult to find any information about Kivy which could help me. For example, at this moment I am trying to make the game stop after one of the players reaches max defined points. I have no code for this, since I have no idea about how to do this. Can somebody point me to the right direction? Is there any source which explains in simple language how the Kivy stuff works. I find the official Kivy tutorials too "professional".

Was it helpful?

Solution

As this is for learning purpose, i won't give a solution, more like directions.

You want to have something happen when the score reach some number of points, kivy have the concepts of properties, and you can see scores are stored into NumericProperties, properties have the nice advantage that you can bind to them, that is, have actions happen when they change. (see http://kivy.org/docs/guide/events.html#introduction-to-properties). Or you can simply check the score after it's changed (each time a point is taken).

Once you got your event, you can change the game state, either quit it (any way to crash the program would do, but it's always better to quit nicely), or you can reset the scores to 0 (by simply changing the properties values), you can even try to add a widget (maybe a Popup?) that asks for the player to start a new game, and only start serving balls again when the user validated, you can add conditions to the serving of balls, and change the game inner working to achieve such things, just experiment.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top