Page 1 of 1
Moving sprites with keyboard inputs
Posted: Fri Aug 14, 2020 8:05 am
by Gonggrijp
I'm creating an RPG visual novel, and I want the main character to move when I press a certain key on my keyboard. I've been looking all over the internet and nothing that I found really helped me. The problem isn't the moving of the character, but the problem is that I don't know how to make the game check for a button press. Could somebody help me?
Re: Moving sprites with keyboard inputs
Posted: Fri Aug 14, 2020 9:10 am
by drKlauz
I did side-scroller in renpy, used custom displayable, in render method i polled keyboard and gamepad state and updated pc and camera positions.
Keyboard was polled by pygame.key.get_pressed() call -
https://www.pygame.org/docs/ref/key.htm ... et_pressed
If you don't want to dive deep and don't need real-time movement i suggest simple adding keys to screen or even left/right imagebuttons.
Re: Moving sprites with keyboard inputs
Posted: Fri Aug 14, 2020 9:56 am
by Gonggrijp
Thank you! You helped me a lot.
Just one more question: How do I import Pygame? (I’m completely new at python so I don’t know)
Re: Moving sprites with keyboard inputs
Posted: Fri Aug 14, 2020 10:51 am
by drKlauz
After this pygame will be available to every rpy file. Keep in mind tho, this pygame is not exactly real pygame
Some stuff may be missing, but for most use cases it is more than enough.
Re: Moving sprites with keyboard inputs
Posted: Fri Aug 14, 2020 11:20 am
by Gonggrijp
Thank you so much! It works now!