-1

I'm creating a simple game to try to learn pygame, and I currently have a game where the user controls a car and has to dodge trucks on a highway.

The game starts off pretty slowly, but I want to add an input box for the user to set their own starting speed.

I know how to make working buttons, but I would rather have a text input that saves to a variable as an integer.

Can anyone help with this?

  • I tried some script I found on the internet, but it didn't work – Krystian Ochot Jan 25 '18 at 11:55
  • Krystian, please read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) Post the code you tried, describe, why it didn't do, what you expected and post the full traceback of error messages. Editing questions is encouraged to improve the quality on SO. – Mr. T Jan 25 '18 at 12:09

1 Answers1

1

you can use inputbox form pygame.

refer link

Then use:

inputbox.ask(screen, "question")

This will return string which can be casted to int

HariUserX
  • 1,341
  • 1
  • 9
  • 17