Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A learner game
#1
I am fairly new to Python and am writing a very basic game. Essentially all we are doing is copying and understanding snippets of code
but for some reason, this script for "gravity" won't work as well as the whole movement system despite it being completely accurate:
user_input = pygame.key.get_pressed()

    if user_input[pygame.K_UP]:
        player.move(0,-2)
    elif player.rect.y < (height -60):
        player.move(0,5)

    if user_input[pygame.K_DOWN]:
        player.move(0,2)

    if user_input[pygame.K_LEFT]:
        player.move(-2,0)
        if player.rect.x < 0:
            player.rect.x= width -1

    if user_input[pygame.K_RIGHT]:
        player.move(2,0)
        if player.rect.x > width:
            player.rect.x= -59

Any help would be much appreciated!
Wall
Reply


Messages In This Thread
A learner game - by Mentlegenn - Oct-17-2018, 08:16 PM
RE: A learner game - by Windspar - Oct-17-2018, 08:30 PM
RE: A learner game - by Mentlegenn - Oct-17-2018, 08:47 PM
RE: A learner game - by Windspar - Oct-17-2018, 09:48 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020