I have wrecked my mental health going over and over and over this code. I have created two classes that are nearly identical yet my images from the second class are not rendering on the screen even though my first class's images are rendering perfectly fine. I've went over and over them to see if I can spot the difference between them that could be causing this but so far nothing. I've also tried swapping class one's image for class two's image and it renders the image perfectly fine from class one, so not an issue with the image itself. I'm lost. Any help from the good people here on stack would be beyond greatly appreciated. I'm sure its something stupidly simple that I'm overlooking but if I look over this code anymore I will go permanently cross-eyed. Here is the snippet. TIA.
class one:
def __init__(self, num_value, bool, x, y):
self.num_value = num_value
self.bool = bool
self.x = x
self.y = y
self.one_image = pygame.image.load(os.path.join('Program_Assets', 'one.png'))
self.image_size = (250, 350)
self.one_image = pygame.transform.scale(self.one_image, self.image_size)
if bool == False:
self.one_image = pygame.transform.rotate(self.one_image, 90)
_VARS['surf'].blit(self.one_image, (self.x, self.y))
if (self.num_value == "1k"):
self.num_value = 1000
elif (self.num_value == "2k"):
self.num_value = 2000
elif (self.num_value == "10k"):
self.num_value = 10000
def setxy(self, x, y):
self.x, self.y = x, y
_VARS['surf'].blit(self.one_image, (self.x, self.y))
def getxy(self):
return self.x, self.y
class two:
def __init__(self, bool, x, y):
self.bool = bool
self.x = x
self.y = y
self.two_image = pygame.image.load(os.path.join('Program_Assets', 'two.png'))
self.image_size = (265, 175)
self.two_image = pygame.transform.scale(self.two_image, self.image_size)
if bool == True:
self.two_image = pygame.image.load(os.path.join('Program_Assets', 'two_alt.png'))
self.two_image = pygame.transform.scale(self.two_image, self.image_size)
_VARS['surf'].blit(self.two_image, (self.x, self.y))
def setxy(self, x, y):
self.x, self.y = x, y
_VARS['surf'].blit(self.two_image, (self.x, self.y))
def getxy(self):
return self.x, self.y
# GLOBAL VAR, Using a Dictionary.
_VARS = {'surf': False}
# This is the main loop, it constantly runs until you press the Q KEY
# or close the window.
# CAUTION: This will run as fast as your computer allows,
# if you need to set a specific FPS look at tick methods.
def main():
pygame.init() # Initial Setup
_VARS['surf'] = pygame.display.set_mode(SCREENSIZE)
is_running = True
# The loop proper, things inside this loop will
# be called over and over until you exit the window
clock = pygame.time.Clock()
t1 = two(True, 250, 350)
o1 = resistor("10k", True, 10, 10)
o2 = resistor("10k", False, 10, 200)
o1_selected = False
o2_selected = False
t1_activated = False
while is_running:
_VARS['surf'].fill(WHITE)
drawGrid(8)
o1_x, o1_y = o1.getxy()
o2_x, o2_y = o2.getxy()
t1_x, t1_y = t1.getxy()
clock.tick(30)
pygame.display.update()
pygame.quit()
if __name__ == '__main__':
main()