Added image for fruits
TODO: Optimize GameObjects class for images and sprites
This commit is contained in:
BIN
data/models/fruit1.jpeg
Normal file
BIN
data/models/fruit1.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
@@ -287,16 +287,17 @@ class Fruit(GameObject_new):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
class GOIMAGE(GameObject):
|
class GOIMAGE(GameObject):
|
||||||
def __init__(self, name: str, surface, mainscreensize: tuple, posx_init: int = 0, posy_init: int = 0, move_speed: int = 0, is_player: bool = False, is_rect: bool = True, color: tuple = (0, 0, 0), rect_size: tuple = (10, 10), image=str()) -> None:
|
def __init__(self, name: str, surface, mainscreensize: tuple, posx_init: int = 0, posy_init: int = 0, move_speed: int = 0, is_player: bool = False, is_rect: bool = True, color: tuple = (0, 0, 0), rect_size: tuple = (10, 10), image=str()) -> None:
|
||||||
super().__init__(name, surface, mainscreensize, posx_init, posy_init, move_speed, is_player, is_rect, color, rect_size, image)
|
super().__init__(name, surface, mainscreensize, posx_init, posy_init, move_speed, is_player, is_rect, color, rect_size, image)
|
||||||
|
|
||||||
self.__image = pygame.image.load(image).convert()
|
self.__image = pygame.image.load(image).convert()
|
||||||
|
self.__image = pygame.transform.scale(self.__image, (20, 20))
|
||||||
|
|
||||||
def move(self):
|
def move(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
surface = self.get_surface()
|
surface = self.get_surface()
|
||||||
surface.blit(self.__image, self.get_position())"""
|
surface.blit(self.__image, self.get_position())
|
||||||
@@ -93,6 +93,8 @@ def spawn_entities(x:int, list_of_objects:list):
|
|||||||
|
|
||||||
background = pygame.surface.Surface((640,480))
|
background = pygame.surface.Surface((640,480))
|
||||||
|
|
||||||
|
imageobj = GOIMAGE("TEST", PLAYGROUND, PLAYGROUND.get_size(), 50, 50, image="data/models/fruit1.jpeg", rect_size=(15,50))
|
||||||
|
|
||||||
x = 3600
|
x = 3600
|
||||||
invert = False
|
invert = False
|
||||||
|
|
||||||
@@ -135,6 +137,8 @@ while active == True:
|
|||||||
MAINSCREEN.blit(text_surface_score, (MAINSCREEN_SIZE[0]/2-text_surface_score.get_size()[0]/2,0)) #Paints the Scoreboard in Top/Center
|
MAINSCREEN.blit(text_surface_score, (MAINSCREEN_SIZE[0]/2-text_surface_score.get_size()[0]/2,0)) #Paints the Scoreboard in Top/Center
|
||||||
MAINSCREEN.blit(text_surface_player, (10, 0))
|
MAINSCREEN.blit(text_surface_player, (10, 0))
|
||||||
|
|
||||||
|
imageobj.draw()
|
||||||
|
|
||||||
if(spawn_fruit == True):
|
if(spawn_fruit == True):
|
||||||
fruit = Fruit("Fruit", PLAYGROUND, PLAYGROUND.get_size(), init_pos_x=rand.randint(0, PLAYGROUND.get_size()[0]-40), init_pos_y=rand.randint(0, PLAYGROUND.get_size()[1]-40), color=ROT, rect_size=40, score_points=10)
|
fruit = Fruit("Fruit", PLAYGROUND, PLAYGROUND.get_size(), init_pos_x=rand.randint(0, PLAYGROUND.get_size()[0]-40), init_pos_y=rand.randint(0, PLAYGROUND.get_size()[1]-40), color=ROT, rect_size=40, score_points=10)
|
||||||
spawn_fruit = False
|
spawn_fruit = False
|
||||||
|
|||||||
Reference in New Issue
Block a user