Skip to content

Commit

Permalink
Add some texture
Browse files Browse the repository at this point in the history
  • Loading branch information
suprasauce committed Aug 5, 2022
1 parent bdf9984 commit caf5935
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
RED = (255, 0, 0)
LIGHT_RED = (255, 153, 153)
DARK_PURPLE = (153, 51, 255)
LIGHT_PURPLE = (204, 153, 255)
LIGHT_PURPLE = (204, 153, 255)
BLACK = (0,0,0)
Binary file modified entities/__pycache__/bob.cpython-310.pyc
Binary file not shown.
Binary file modified entities/__pycache__/box.cpython-310.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions entities/bob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import sys

class bob():
def __init__(self, ep_x, ep_y):
def __init__(self, ep_x, ep_y, color):
self.width = constants.BOB_WIDTH
self.height = constants.BOB_HEIGHT
self.color = colors.GREEN
self.color = color
# the bob center will be endpoint_center
self.x, self.y = ep_x, ep_y
self.v_x, self.v_y = 0.0, 0.0
Expand All @@ -24,7 +24,7 @@ def reset(self, ep_x, ep_y):

def draw(self, screen):
# bob_surface = self.create_and_get_new_surface()
self.surface.fill(colors.GREEN)
self.surface.fill(self.color)
screen.blit(self.surface, (self.x - self.width/2, self.y - self.height/2))

def set_parabolic_motion_initials(self, v_x, v_y):
Expand Down
12 changes: 10 additions & 2 deletions entities/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, s_pos_x, s_pos_y, screen_height):
self.vertical_vel = random.uniform(2,4)
self.vel_dir = 1
self.center = self.get_center()
self.name_surface = py.Surface((50,12))

def get_center(self):
return [self.surface_pos[0] + 25, self.surface_pos[1] + 25]
Expand All @@ -31,8 +32,15 @@ def move(self):

def draw(self, screen):
self.move()
self.surface.fill(colors.GREEN)
self.surface.fill(colors.RED)
self.name_surface.fill(colors.WHITE)
name_rect = self.name_surface.get_rect()
py.draw.rect(self.name_surface, colors.RED, name_rect,0,2)
# py.draw.line(self.surface, colors.RED, self.rect.topleft, self.rect.bottomleft, 2)
# py.draw.line(self.surface, colors.RED, [self.rect.topright[0] - 2, self.rect.topright[1]], [self.rect.bottomright[0] - 2, self.rect.bottomright[1]], 2)
# py.draw.line(self.surface, colors.RED, [self.rect.bottomleft[0], self.rect.bottomleft[1]-2], [self.rect.bottomright[0], self.rect.bottomright[1]-2], 2)
screen.blit(self.surface, self.surface_pos)
font = py.font.Font("fav_font.ttf",8)
name = font.render("Box", True, colors.WHITE)
self.name_surface.blit(name, [name_rect.topleft[0] + 12.0, name_rect.topleft[1]])
screen.blit(self.surface, self.surface_pos)
screen.blit(self.name_surface, [self.surface_pos[0], self.surface_pos[1] - 20])
12 changes: 7 additions & 5 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def lets_play(num_bobs):
ep_x, ep_y = screen_width/4, screen_height/3 + 1.0
box = bx(5*screen_width/6, 0, screen_height)

player_bob = b(ep_x, ep_y)
player_bob = b(ep_x, ep_y, colors.DARK_PURPLE)
player_end_point = ep(ep_x, ep_y, pivot)
player_mouse_down = False

for i in range(num_bobs):
bobs.append(b(ep_x, ep_y))
bobs.append(b(ep_x, ep_y, colors.LIGHT_PURPLE))
end_points.append(ep(ep_x, ep_y, pivot))

while(loop):
Expand Down Expand Up @@ -189,10 +189,11 @@ def lets_play(num_bobs):
# This for loop manages all the drawing stuff
for bob in bobs:
if not bob.goal_reached:
bob.draw(screen)
if not bob.is_free:
# draw string
py.draw.line(screen, colors.GREEN, pivot, [end_points[bobs.index(bob)].x, end_points[bobs.index(bob)].y],1)
py.draw.line(screen, colors.BLACK, pivot, [end_points[bobs.index(bob)].x, end_points[bobs.index(bob)].y],4)
bob.draw(screen)



# This handles players_bob
Expand All @@ -216,7 +217,8 @@ def lets_play(num_bobs):

# after checking all collisions drawing of player happens
if not player_bob.is_free:
py.draw.line(screen, colors.GREEN, pivot, [player_end_point.x, player_end_point.y],1)
py.draw.line(screen, colors.BLACK, pivot, [player_end_point.x, player_end_point.y],4)

player_bob.draw(screen)

frames -= 1
Expand Down

0 comments on commit caf5935

Please sign in to comment.