Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. Now, it’s up to the imagination or necessity of developer, what type of game he/she wants to develop using this toolkit.
In this article we will see how we can make design in PyGame with help of keys such that design i.e marker moves horizontally when pressing the right arrow key or left arrow key on the keyboard and it moves vertically when pressing up arrow key or down arrow key. We can do this by making a spot(marker) on the respective co-ordinates, which gets changes with the help of keys.
Change in Co-ordinates of marker for respective keys pressed : Left arrow key: Decrement in x co-ordinate Right arrow key: Increment in x co-ordinate Up arrow key: Decrement in y co-ordinate Down arrow key: Increment in y co-ordinate
Below is the implementation –
- Python | Drawing different shapes on PyGame window
- PyQt5 - Move the Label Position within the window using Arrow Keys
- Python - Extract selective keys' values Including Nested Keys
- Tic Tac Toe GUI In Python using PyGame
- Python | Display images with PyGame
- Python - Moving an object in PyGame
- Python | Display text to PyGame window
- Python | Playing audio file in Pygame
- Python | Making an object jump in PyGame
- Wand Drawing() function in Python
- Python | Creating a Simple Drawing App in kivy
- Drawing with Mouse on Images using Python-OpenCV
- Arrow module in Python
- matplotlib.pyplot.arrow() in Python
- Matplotlib.patches.Arrow Class in Python
- Introduction to pygame
- 8-bit game using pygame
- Python | Add new keys to a dictionary
- Python | Keys with Maximum value
- Python | Get dictionary keys as a list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.