Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import sys, pygame
  4. from pygame.locals import *
  5.  
  6. positionX = 200
  7. positionY = 10
  8.  
  9. pygame.init()
  10.  
  11. pygame.display.set_mode((800, 600))
  12. pygame.display.set_caption("new engine dev demo - noda creator 0.1")
  13.  
  14. window = pygame.display.get_surface()
  15. window.fill((128, 128, 128))
  16.  
  17. Platform = pygame.Surface((800, 200))
  18. Platform.fill((100, 100, 100))
  19. window.blit(Platform, (1, 500))
  20.  
  21. Block = pygame.Surface((100, 100))
  22. Block.fill((50, 50, 50))
  23. pXY = Block.get_rect()
  24. pXY.x = positionX
  25. pXY.y = positionY
  26.  
  27. window.blit(Block, (positionX, positionY))
  28.  
  29. pygame.display.flip()
  30.  
  31. fps = pygame.time.Clock()
  32.  
  33.  
  34. while True:
  35. for happend in pygame.event.get():
  36. if happend.type == QUIT:
  37. sys.exit(0)
  38. if happend.type == KEYDOWN:
  39. if happend.key == K_a:
  40. pXY.x-=10
  41. window.blit(Block, pXY)
  42. pygame.display.update()
  43. window.fill((128, 128, 128))
  44. if happend.key == K_d:
  45. pXY.x += 10
  46. window.blit(Block, pXY)
  47. pygame.display.update()
  48. window.fill((128, 128, 128))
  49. pXY.y+=10
  50. window.blit(Block, pXY)
  51. pygame.display.update()
  52. window.fill((128, 128, 128))
  53. fps.tick(60)
  54.  
  55. Platform = pygame.Surface((800, 200))
  56. Platform.fill((100, 100, 100))
  57. window.blit(Platform, (1, 500))
  58.  
  59. if pXY.y == 400:
  60. break
  61.  
  62. while 1:
  63. for happend in pygame.event.get():
  64. if happend.type == QUIT:
  65. sys.exit(0)
  66. if happend.type == KEYDOWN:
  67. if happend.key == K_a:
  68. pXY.x-=10
  69. window.blit(Block, pXY)
  70. pygame.display.update()
  71. window.fill((128, 128, 128))
  72. if happend.key == K_d:
  73. pXY.x += 10
  74. window.blit(Block, pXY)
  75. pygame.display.update()
  76. window.fill((128, 128, 128))
  77.  
  78.  
  79. Platform = pygame.Surface((800, 200))
  80. Platform.fill((100, 100, 100))
  81. window.blit(Platform, (1, 500))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement