how to make a rect in pygame

Solutions on MaxInterview for how to make a rect in pygame by the best coders in the world

showing results for - "how to make a rect in pygame"
Benjamín
24 Apr 2020
1# make the x position, y position, width and the height of the rectangle
2x_pos = 20
3y_pos = 20
4width = 50
5height = 50
6
7# make the rectangle variable
8rectangle = pygame.Rect(x_pos, y_pos, width, height)
9
10# now add this to a surface, add a colour and the rectangle and make it a function
11def make_rect():
12	pygame.draw.rect(surface, (RGB colour in this tuple), rectangle)
13
14
15# after this add it to your infinite loop
16run = True
17while run:
18    for event in pygame.event.get():
19        if event.type == pygame.QUIT:
20            run = False
21            
22	make_rect()
23    pygame.display.update()
Thibaud
12 Jan 2018
1pygame.Rect(top, left, width, height) # all values are integers in pixels
Nola
25 Aug 2018
1pygame.draw.rect(SURFACE, RGB_COLOR, (X, Y, WIDTH, HEIGHT))
Mila
16 Sep 2017
1# rectangle colour
2rect_colour = (RGB VALUE)
3
4# define the x, y, width & height for the rectangle
5x_position = 30
6y_position = 30
7rect_width = 60
8rect_height = 60
9
10# draw the rectangle
11pygame.draw.rect(screen, rect_colour, pygame.Rect(rect_width, rect_height))
queries leading to this page
rectangle pygamepygame how to draw ctdraw rectangle pygamehow to draw a pygame rectpygame solid rectanglehow do i draw a rectangle in pygameoygame rectpygame rect 28 29draw a rect on a window pyagempygame rectgame draw rect syntaxdraw rectangles pygamepygame relocate rectanglehow to set a rect pygamehow to print rectangle in python using pygamepygame draw rect pygamepygame rectshow to make a rectangle in pygamecreate rectangle pygamepygame draw lienpygame code to make rectanglehow to darw a rect in pygamepygame srceen drawpygame draw rectangledrawing a rectanlge pygamehow to draw a rectangle on an image in pygamehow to draw lines with pygamepygame create rectangle objectpygame rectangle pointshow to make new rectangle pygamepygame new rectrect tutorial in pygame rect pygamebasic triangle in pygamepygame recctpygame how to draw rectdrawing rectangle in pygamedraw pygame recthwo to draw a rectangle in pygamehow to make a rectangle move in python pygame rect in pygamepygame rect 28 29pygame draw rhombuspygame triangledraw circle pygamepygame draw rectmake a rectangle pygamepygame draw rect parameterspygame rect 2825pygame rect 28 29 give strokerectange pygameadding rect pygamemake rectangle pygamepygame how to draw a pointpygame draw rect 28 29how to make rect pygamepygame ringpygame draw circle documentationpygame ellipseallpygame possible shapespygame draw a rectangle from pointspygame example draw a rectangleis it rect or rect in pygamehow to make rectangle in pygamedraw rect in pygamepygame draw objectcolor fase pygame linepygame rectanglgedraw circle in pygameadding rectangles to pygamepygame draw circlpygame draw rect rectangle examplepygame draw rect outlinespygame example drawing a rectanglerectangels in pygamepygame create rectrectangle from image pygamepygame curved lineshow to draw out a rect ion pygamehow to draw a rectangle in pygame nerd paradisepython pygame drawingpygame how to draw a circlehow to use pygame rectpygame draw circle functionpygame draw a rectangle from 4 xy pointspygame polygon to surfacedraw pygamehow can we make a rectangle through pygame rectpygame draw rect a variablehow to render a rectangle in python pygamepygame rect movepygame rectangle drawpython pygame pygame draw rect 28 29pygame draw rectangle examplepygame rect syntaxpygame rect methodspygame how to draw a rectanglepython pygame draw rectpygame empty squarepygame rect colorhow to make a black outline around white circle pyga 2cenew rect pygamedraw rects pygamerectangle in pygamepygame shapespygame draw a recthow to max a bbox for circle pygamepygame rectangkehow to make a rectangle in python pygamepygame display rectrect in pygamedraw a rectange pygamepolygon pygamepygame fill a rectanglepygame draw trianglecreating a rectangle in pygamelines in pygamesdraw triangle in pygamehow to create a rectangle in pygame with a tuple pygame drawing rectpygame make recthow to draw a square in pygamepygame how to make a circlepygame create reccan you put objects in rectangles pygamepygame draw recthow to create rectangle in pygamehow to make a rect pygamehow to create a rectangle in pygamedrawing with pygamehow to make a rectange pygamehow to link rectangles in pygamemake rectangle pygame pythonpygame how to create a rectangle with a clickpygame rotate a rectanglehow to draw a rectangle on a window in pygamedraw a rectangle in pygamedraw rectangle in pygameinstructivos draw rect pythonpygame docs rectdrawing multiple shapes in pygamehow to draw an arc in pygamepygame recvtpygame draw line examplehow to draw a rectangle pygamepygame draw squarepygame rect propertieshow to draw a line pygamepygame draw rect attributespygame rectanglerect pygame examplecoordinates pygame draw rectdrawing rectangles in pygamehow to draw rectangel pygamepygame create rectanglepygame blit rectanglemake a good rectangle in pygameget rect pygamehow to update rectangle pygamehow to draw in pygamehow to draw rectangle in pygamerectangles pygamepygame draw rect documentationdrawing a square in pygamepygame rect syntaxpygame draw on surfaceadd data to a rectangle pygamedraw gree square pygamcreate rectangle in pygamepygame rect and pygame rectpygame fill in a circlepygame draw rect rectangle tutorialwhat parameters go in pygame draw rectcreate a rect in pygamepygame drawing shapeshow to mave a rectangle in pygamemake a rect pygamehow to define rect in pygamepygame draw rectzhow to destroy rectangle in python pygamedraw a box pygamehow do you draw a rectangle in pygamepygame rectangle colordraw line in pygamehow to draw a square in python in pygamepygame rect coderectangle python pygamepygame draw rectpygame draw rect 28self game screenpygame draw alpha librarypygame draw rect circlepygame rectangle fillcant draw rectangle pygamepygame rect draw examplepygame rect 28 29how to fill pygame draw rectcreate rect pygamestroke in pygamesget botto and right of rect pygamepygame recblit a square in pygamepygame draw rect examplepygame draw rect examplepygame get rect tutorialhousehow to draw a rect at a position pygamepygame python 3 draw rectanglehow to draw a rect in pygamepygame rect examplehow to convert a rectangle into a pygamedraw a rect in pygamepygame linepygame draw rect syntaxhow to create a rect in pygamepuygame draw rectpygame draw rect colourhow to draw a line in pygame from user inputhow to make a square in pygamehow to draw rectangle pygamepygame draw linedrawing rectangle pygamehow to user pygame draw rectdef draw select box 28x 2c y 29 3a px 2c py 3d getcoord 28x 2c y 29 pg draw rect 28screen 2c color 28 27red 27 29 2c 28px 5 2c py 5 2c squaresize 2b 10 2c squaresize 2b 10 29 2c 5 29pygame rect objectdraw rect in pygame pygame rectcreate a rectangle in pygamepygame rect recthow to make rect in pygamehow to code a rectangle in pygamedraw rectangle python pygamepygame draw lindraw a circle pygamedraw a line in pygamehow to make a rect in pygamehow to make a rect python pygamepygame make rectanglepygame drawpygame draw linespygame rectdraw square pythongamehow to fill a rectangle in pygamepygame filled rectanglepygame how to draw a rectpygame add rectanglehow to draw a rectangle in pygamepygame polygonhow to draw a rectangle in python pygamehow to pygame draw a rectangledisplay drawrect pygamepygame make rectangle smallerpygame draw rect and fillstraight line pygamepygame draw rect function rect properties pygamedraw square pygamepygame render polygonhow to move a rectangle in pygamepygame rectanlgeusing draw rectpygame rect pygame draw rect classpython pygame draw rectanglewhat are rects in pygamehow to make a circle in pygamepygame draw polygondraw a rectagle in pygamepygame get rect 28pygame draw rectangle tutorialpygame rectangelsdraw a rectangle pygamepyhton pygame rectget rect 28 29 in pygamepygame rect drawcircle pygamepoints in pygamedrawing a rectangle in pygamepygame move recthow to make rects pygamedraw rect pygamedraw rectangle from two points pygamepygame rect sizepython pygame draw circle 28 29pygame draw polygon function if clickedhow to insert a rectangle in pygamehow to draw a rectoangle with pygamepygame cirlcepygame draw xdraw rectangels in pygamedraw rectangle when clicked pygamepygame display rectanglepygame dtse rectpygame deelte rectanglehow to turn a drawing into a rect in pygamehow do i drwa a line in pygamepygame rect 2b rectcreating rectangle in pygamepygame rect explainedhow to make rectangle see through in pygamepygame rect movehow to a boarder box for circle pygamepygame draw rect pythonhow to make a rectangle fall in pygamepyga 2ce draw rectpygame linesdraw a how rect pygamepygame rect rightpygame recypygame draw lines examplehow to draw rect pygamehow to display a rectangle in pygamepygame draw rectsquare pygamepython pygame rectdrawing rect in pygame 27make rectangle in pygamedraw with rectangle pygamehow to move a rectangle in pygame codepygame displaying a rectanglehow to move a rect in pygamepygame shapehow to create a pygame rectpygame how to draw redhow to get a rectangle in pygamedraw line pygamepygame rectangle grouppygame get rect 28 29pygame draw a rectanglepygame create squarehow to move rectangle in pygamepygame draw parallelogramhow to draw rect in pygamepygame draw rect 5crect draw pygamepygame drae linespygame get rectpygame rect examplepygame how to draw a rectangle at a positionpygame add rectwhy rect is use in pygamerectangle draw pygamepygame recthow to draw pygame recthow to add a rectangle in pygamepygame fill rectrectangle pygame drawpygame get 3arectdiameter of pygame draw circle 28window 2c 280 2c 0 2c 50 29 2c 2850 2c 100 29 2c 100 29pygame rectangglepython pygame recthow to make squiggles in pygamepygame retangle in pythonrects pygamewhat is rect in pygamedraw rect pygamepygame drawing rectangleshow to create a rectangle button in pygamehow to draw a rectangle outline in pygamehow to handle recv in pygamemaking non rectangles in pygamepygame rect definitionwhat is rect pygamepygame draw dotrect pygamepygame draw rect in pythondraw rectangle on pygame windowpython rect fillhow to draw a rectangle 2fplayer on surface in python pygamepygame rectangle collisionmake a black rectangle in pygamepygame how to make a rectanglepygame example rectanglepygame rect 28how to add rectangle pygameget rect 28 29 pygamepygame how to create a recthow to draw a rectangle in pygamedraw retnagle in pygamehow to make pygame rectdraw a rect pygamerect function pygamehow to make a pygame squarepygame draw rectangle behinddraw stuff with pygamedraw line with pygamerecy stroke in pygameshow to move rectangles in pygamedraw line from coordinates pygamefill rectangle in pygamepygame draw rec 28 29 give strokepygame draw circle ahow to make a rect in pygame