Skip to content
Snippets Groups Projects
Commit 86ea3193 authored by Usman Irfan's avatar Usman Irfan
Browse files

Updated Boubdary

parent 0d923f36
No related branches found
No related tags found
No related merge requests found
#standard set up
import pygame
from random import randint
pygame.init()
#setting width and height of window
win = pygame.display.set_mode((500,500))
screen_x = 500
screen_y = 500
win = pygame.display.set_mode((screen_x,screen_y))
pygame.display.set_caption("My Game")
white = (255,255,255)
black = (0,0,0)
x = 50
y = 50
width = 40
height = 40
x = randint(40,400)
y = randint(40,400)
width = 20
height = 20
vel = 10
speed = 40
......@@ -59,6 +63,21 @@ while run:
x += vel*direction
if x < 0:
#x = 0
x = screen_x - height
if y < 0:
#y = 0
y = screen_y - width
if y > screen_y - width:
#y = 500 - width
y = 0
if x > screen_x - height:
#x = 500 - height
x = 0
win.fill(white)
#all colors are defined in RGB with Pygame
pygame.draw.rect(win,(255,0,0), (x,y,width, height))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment