Skip to content

Commit

Permalink
mosueover inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
mooreInteractive committed Oct 6, 2014
1 parent 5984166 commit 41b49d3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
37 changes: 36 additions & 1 deletion Menu.py
Expand Up @@ -12,13 +12,22 @@ class mainMenu:
dragging = False
draggedItem = []

moText = ''
moShow = False

playText = 'Press \'S\' to play.'
titleText = 'Pygame_Space'
inventoryText = 'Inventory'
configText = 'Ship Configuration'
largefont = pygame.font.SysFont(None, 28)
basicfont = pygame.font.SysFont(None, 22)
smallfont = pygame.font.SysFont(None, 18)

moLabel = basicfont.render(moText, True, (255, 255, 255), (0, 0, 0))
moRect = moLabel.get_rect()
moRect.x = mousePos[0]+10
moRect.y = mousePos[1]

playLabel = basicfont.render(playText, True, (255, 255, 255), (0, 0, 0))
playRect = playLabel.get_rect()
playRect.x = 515
Expand Down Expand Up @@ -61,6 +70,18 @@ def __init__(self, player):

self.playerInv = newinv

for inv in self.playerInv:
if inv[0] == 'hull':
if inv[1] == 18 and inv[2] == 18:
inv.append('Energy Capacity + 10')
if inv[1] == 8 and inv[2] == 18:
inv.append('E Recharge Rate + .6/s')
if inv[1] == 18 and inv[2] == 8:
inv.append('Ship HP + 10')
if inv[1] == 8 and inv[2] == 8:
inv.append('Nothing. Takes a hit.')
if inv[0] == 'gun':
inv.append('Shoots when you press SPACEBAR')
def arrangeEquipped(self, newEqp):
#Make sure no pieces of euipment are overlapping each other.
#use newEqp[4].x, newEqp[4].y, newEqp[1], newEqp[2] as Rect
Expand Down Expand Up @@ -112,6 +133,14 @@ def getUserInput(self, initGame, done, events):

if event.type == pygame.MOUSEMOTION:
self.mousePos = pygame.mouse.get_pos()
self.moShow = False
for i in self.playerInv:
if i[4].collidepoint(self.mousePos) and self.dragging == False:
self.moShow = True
self.moText = i[5]
self.moLabel = self.basicfont.render(self.moText, True, (255, 255, 255), (0, 0, 0))
self.moRect = self.moLabel.get_rect()
#print 'mouse Over \''+i[5]+'\''
if event.type == pygame.MOUSEBUTTONUP:
if self.dragging:
if self.gridRect.collidepoint(self.mousePos):
Expand Down Expand Up @@ -158,6 +187,8 @@ def updateMenuScreen(self, block):
block.y = 206
else:
self.startGame = False
self.moRect.x = self.mousePos[0] - 30
self.moRect.y = self.mousePos[1] + 15

def drawMenuScreen(self, bg, screen, block):
screen.fill((0, 0, 0))
Expand Down Expand Up @@ -216,4 +247,8 @@ def drawMenuScreen(self, bg, screen, block):
if hull[0] == 'gun':
start = (hull[4].x + (hull[1]/2), hull[4].y + (hull[2]/2))
end = (hull[4].x + (hull[1]*1.5), hull[4].y + (hull[2]/2))
pygame.draw.line(screen, (255,50,50), start,end)
pygame.draw.line(screen, (255,50,50), start,end)

if self.moShow == True:
screen.blit(self.moLabel, self.moRect)
#print 'drew mo, '+str(self.moRect)+', '+str(self.moLabel)
1 change: 1 addition & 0 deletions Ship.py
Expand Up @@ -72,6 +72,7 @@ def updateThis(self):
h.updateThis(self.x, self.y)
if h.deadtimer == 0:
self.hull.remove(h)
self.updateStats()
newRed = int(255 - ((self.hp/float(100)) * 255))
newBlue = int((self.hp/float(100)) * 255)
self.color = (newRed, 30, newBlue)
Expand Down
5 changes: 2 additions & 3 deletions space.py
Expand Up @@ -145,7 +145,6 @@ def detectCollisions():
bullets.remove(b)
h.isAttached = False
pbrokeHull = True
block.updateStats()
#removeFromPlayerInventory(h)
break
if pbrokeHull == True:
Expand Down Expand Up @@ -204,11 +203,11 @@ def getUserInput():
if pressed[pygame.K_UP]:
if block.energy > 0:
block.y -= block.speed
block.energy -= block.speed/5
block.energy -= (block.speed - 2)/2
if pressed[pygame.K_DOWN]:
if block.energy > 0:
block.y += block.speed
block.energy -= block.speed/5
block.energy -= (block.speed - 2)/2
if pressed[pygame.K_SPACE]:
block.fire()
else:
Expand Down

0 comments on commit 41b49d3

Please sign in to comment.