0

I have this code:

import pygame as pg

from pygame.locals import QUIT

pg.init()

pg.display.set_caption("Cookie clicker")

DISPLAY = pg.display.set_mode((500, 300))

c = pg.image.load("cookie.png")

cookie = pg.transform.scale(c, (150,150))

mid = 250,150

mid = cookie.get_rect(center=(mid))

#other imgs here


cpc = 1

money = 0

cps = 0

cookies = 0

class draw(main,sidebar_popup):

    def upd():

        pg.display.update()

      

    def draw(main):

        pg.blit(cookie,mid)

    def draw(sidebar_popup):
        #show a sidebar 

        

  

run = True

while run:

    draw(main)

  

    for event in pg.event.get():

        if event.type == QUIT:

            run = False

I want to be able to use draw(#image) to show images when I need but I don't know how to use class function.

I am trying to make a cookie clicker on pygame and learning as I go along.

Ps. I am new to pygame and haven't fully learnt python so dont really understand class yet.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Fiftyy
  • 1
  • 2
  • 2
    If you want to use Pygame, read [How can I add objects to a "pygame.sprite.Group()"?](https://stackoverflow.com/questions/73924256/how-can-i-add-objects-to-a-pygame-sprite-group) – Rabbid76 Jan 14 '23 at 17:02
  • You need to read about [sprites](https://www.pygame.org/docs/ref/sprite.html) and how to use them, it will make things easier for you in the long run. [This answer](https://stackoverflow.com/a/74014894/2280890) generates cookie sprites with unique images that you might find helpful. – import random Jan 15 '23 at 04:00

0 Answers0