0

I can't and don't want to know how to use images in pygame zero. I thought of an alternative by making a spritesheet with the def function. I can't figure out how to color a pixel in a specific position though :/

I don't really know how to do it, but this would be my best guess

import pgzrun
HEIGHT = 100
WIDTH = 100
red = (255, 0, 0)
yellow = (255, 255, 0)
white = (255, 255, 255)
teal = (0, 255, 255)
blue = (0, 0, 255)
green = (0, 255, 0)
magenta = (255, 0, 255)
black = (0, 0, 0)

def draw():
    screen.clear()
    screen.fill(white)
    screen.fill((50,50)color = green)
pgzrun.go()

this program is supposed to make the center of the screen green this program doesn't work

31schral
  • 1
  • 1
  • To make your question clearer, please provide more details about the problem you're encountering, such as any error messages you're receiving or specific steps you've tried. Additionally, it would be helpful if you could provide more information about your spritesheet and the desired pixel you're trying to color. – wggn May 12 '23 at 23:46
  • this program is supposed to make the center of the screen green – 31schral May 13 '23 at 23:13

2 Answers2

0

The problem is that screen.fill fills the entire screen and you can't give a specific position to the place where it fills. Another thing that's wrong is you make a function called draw and then put in screen.fill. I personally don't recommend pg zero to do these types of things because it's really simple. Instead, try using Pygame. I hope this helped!

ankushlokhande
  • 870
  • 5
  • 20
Leafy
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – ankushlokhande Jun 03 '23 at 11:19
0

You could try using either draw.filled_circle or draw.filled_rect depending on the shape you need.

For draw.filled_circle you give the position as an argument directly, so that might be easier. But if you want to use draw.filled_rect you'll need to set things up like this:

green = (0,255,0)
box = Rect((20, 20), (100, 100)) # or wherever you need to put it

def draw():
    draw.filled_rect(box, green)

Here's the documentation as well, for extra guidance.