Hello Guys and Welcome to my Channel.
In this video I have made a simple moving mechanism, if you see this video very carefully then I am sure that you would be able to understand this mechanism. Watch till end to be perfect at moving in python spyder IDE.
You may see my more videos in my channel. This video would be very helpful to you if you are interested in creating Games. This is the source code you may copy it from here
import pygame
pygame.init()
window = pygame.display.set_mode((1000,1000))
BoxX = 500
BoxY = 500
PlayerVel = 2
Grey = (128,128,128)
def drawGame():
window.fill((255,0,0))
pygame.draw.rect(window, Grey, (BoxX, BoxY, 50,50))
pygame.display.update()
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_RIGHT]:
BoxX += PlayerVel
if keys[pygame.K_LEFT]:
BoxX -= PlayerVel
if keys[pygame.K_UP]:
BoxY -= PlayerVel
if keys[pygame.K_DOWN]:
BoxY += PlayerVel
drawGame()
pygame.display.update()
pygame.quit()
I would be soon uploading many interesting videos so please subscribe , like ,comment and share.
That's it for today, Byeeeee...
Stay Tuned