I am trying to create a main menu for a tower defence game. This is the code I've got so far.
Menu.py
import pygame as pg
from pygame.examples.sprite_texture import img
pg.init()
class Menu():
def __init__(self, x, y, img):
self.img = img
self.y = y
self.x = x
def draw(self, win):
"""draw image"""
win.blit(self, img)
Main.py
import pygame as pg
from Menu import Menu
pg.init()
"""Displays screen"""
winWidth = 1280
winHeight = 720
size = (winWidth, winHeight)
win = pg.display.set_mode(size)
"""Load images and puts them into the correct size"""
bg_img = pg.image.load('Pic/td-gui/PNG/menu/bg.png')
bg_img = pg.transform.scale(bg_img,(1280 ,720))
setting_img = pg.image.load('Pic/td-gui/PNG/menu/button_settings.png')
clock = pg.time.Clock()
win.blit(bg_img, (0, 0))
mainMenu = True
run = True
running = True
while run:
clock.tick(30)
pg.display.update()
for event in pg.event.get():
if event.type == pg.QUIT:
run = False
if not run:
pg.quit()
if mainMenu:
settings_button = Menu(100, 100, setting_img)
Menu.draw(setting_img)
These are not the images loaded at all! Once I exit this is then what appears:
This is the correct background image I want, however the settings button does not appear which is what I was trying to figure out before this issue came along. What could be the issue?