You are on page 1of 13

import pygame

pygame.init()
display = pygame.display.set_mode((700, 436))
pygame.display.set_caption('cells!')
background = pygame.image.load('initpage.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
pygame.font.init()
myfont = pygame.font.SysFont('Comic Sans MS', 30)
class button():
def __init__(self,size, color, x, y, width, height, text=''):
self.color = color
self.x = x
self.y = y
self.width = width
self.height = height
self.text = text
self.size = size

def draw(self, display, outline=None):


if outline:
pygame.draw.rect(display, outline, (self.x - 2, self.y - 2, self.width +
4, self.height + 4), 0)

pygame.draw.rect(display, self.color, (self.x, self.y, self.width,


self.height), 0)

if self.text != '':
font = pygame.font.SysFont('comicsans', self.size)
text = font.render(self.text, 1, (0, 0, 0))
display.blit(text, (
self.x + (self.width / 2 - text.get_width() / 2), self.y + (self.height /
2 - text.get_height() / 2)))

def isOver(self, pos):


if pos[0] > self.x and pos[0] < self.x + self.width:
if pos[1] > self.y and pos[1] < self.y + self.height:
return True

return False

def blit_text(surface, text, pos, font, color=pygame.Color('black')):


words = [word.split(' ') for word in text.splitlines()]
space = font.size(' ')[0]
max_width, max_height = surface.get_size()
x, y = pos
for line in words:
for word in line:
word_surface = font.render(word, 0, color)
word_width, word_height = word_surface.get_size()
if x + word_width >= max_width:
x = pos[0] # Reset the x.
y += word_height # Start on new row.
surface.blit(word_surface, (x, y))
x += word_width + space
x = pos[0] # Reset the x.
y += word_height # Start on new row.

pygame.mixer.music.load('backgroundscience.mp3')
pygame.mixer.music.play(-1,0.0)

animalButton=button(40,(255,0,0),100,350,150,50,'animal cell')
animalButton.draw(display, (0, 0, 0))

plantButton=button(40,(255,0,0),300,350,150,50,'plant cell')
plantButton.draw(display, (0, 0, 0))
pygame.display.update()

running = True
while (running):
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
if animalButton.isOver(pos):
e="a"
running = False
elif plantButton.isOver(pos):
e="p"
running = False
if event.type == pygame.MOUSEMOTION:
if animalButton.isOver(pos):
animalButton.color=(0,0,255)
elif plantButton.isOver(pos):
plantButton.color=(0,0,255)
else:
animalButton.color = (255, 0, 0)
plantButton.color = (255, 0, 0)

while running==False:
if e=="a":
display = pygame.display.set_mode((750, 549))
background = pygame.image.load('animaldia.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
nextButton = button(40,(255, 0, 0),550, 25, 175, 50, 'go to plant!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
animalrunning=True
#
nucleusButton = button(25,(0, 255, 0), 20, 280, 90, 20, 'function')
nucleusButton.draw(display, (0, 0, 0))
nuclearEnvelopeButton = button(25,(0, 255, 0), 30,236, 90, 20, 'function')
nuclearEnvelopeButton.draw(display, (0, 0, 0))
cytoplasmButton = button(25, (0, 255, 0), 21, 353, 90, 20, 'function')
cytoplasmButton.draw(display, (0, 0, 0))
golgiApparatusButton = button(25, (0, 255, 0), 110, 490, 90, 20, 'function')
golgiApparatusButton.draw(display, (0, 0, 0))
mitochondrionButton = button(25, (0, 255, 0), 580, 517, 90, 20, 'function')
mitochondrionButton.draw(display, (0, 0, 0))
cellMembraneButton = button(25, (0, 255, 0), 610, 433, 90, 20, 'function')
cellMembraneButton.draw(display, (0, 0, 0))
ERButton = button(25, (0, 255, 0), 610, 355, 90, 20, 'function')
ERButton.draw(display, (0, 0, 0))
lysosomeButton = button(25, (0, 255, 0), 573, 220, 90, 20, 'function')
lysosomeButton.draw(display, (0, 0, 0))
ribosomeButton = button(25, (0, 255, 0), 583, 145, 90, 20, 'function')
ribosomeButton.draw(display, (0, 0, 0))
nucleolusButton = button(25, (0, 255, 0), 185, 120, 90, 20, 'function')
nucleolusButton.draw(display, (0, 0, 0))
pygame.display.update()

while (animalrunning):
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
animalrunning = False
running =True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
animalrunning = False
elif nucleusButton.isOver(pos):
e = "nucleusButton"
animalrunning = False
elif nuclearEnvelopeButton.isOver(pos):
e = "nuclearEnvelopeButton"
animalrunning = False
elif cytoplasmButton.isOver(pos):
e = "cytoplasmButton"
animalrunning = False
elif golgiApparatusButton.isOver(pos):
e = "golgiApparatusButton"
animalrunning = False
elif mitochondrionButton.isOver(pos):
e = "mitochondrionButton"
animalrunning = False
elif cellMembraneButton.isOver(pos):
e = "cellMembraneButton"
animalrunning = False
elif ERButton.isOver(pos):
e = "ERButton"
animalrunning = False
elif lysosomeButton.isOver(pos):
e = "lysosomeButton"
animalrunning = False
elif ribosomeButton.isOver(pos):
e = "ribosomeButton"
animalrunning = False
elif nucleolusButton.isOver(pos):
e = "nucleolusButton"
animalrunning = False
if e == "nucleusButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nThe key function of the nucleus is to control cell growth and
multiplication."
font = pygame.font.SysFont('Arial', 55)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "nuclearEnvelopeButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nSeparation of DNA from cytoplasm machinery.\nRegulation of
contents that move in and out."
font = pygame.font.SysFont('Arial', 55)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "cytoplasmButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nprovide a medium for the cellular contentsto exist in"
font = pygame.font.SysFont('Arial', 55)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "golgiApparatusButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nSecretory.\nIt produces vacuoles or secretory vesicles which
contain cellular secretions"
font = pygame.font.SysFont('Arial', 55)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "mitochondrionButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nThe main function of mitochondria is the production of ATP through
cellular respiration"
font = pygame.font.SysFont('Arial', 55)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "cellMembraneButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nA cell membrane is a thin layer that acts as a barrier that
separates an individual cell or a cellular compartment from other surrounding
structures"
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "ERButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \n\nIt is mainly responsible for the transportation of proteins and
other carbohydrates to another organelle, which includes lysosomes, Golgi apparatus,
plasma membrane, etc."
font = pygame.font.SysFont('Arial', 40)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "lysosomeButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nrecycling old cells, digesting materials that are both inside and
outside of the cell, and releasing enzymes"
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "ribosomeButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nresponsible for assembling the proteins of the cell"
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
elif e == "nucleolusButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nproduction of ribosomes and synthesis of ribosomal RNA (rRNA)"
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "a"
littlerunning = False
animalrunning = True
if e=="p":
display = pygame.display.set_mode((900, 524))
background = pygame.image.load('plantd.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
backButton = button(40,(255, 0, 0),675,450, 200, 50, 'go to animal!')
backButton.draw(display, (0, 0, 0))
pygame.display.update()
chloroplastButton = button(35, (0, 255, 0), 260, 73, 110, 30, 'function')
chloroplastButton.draw(display, (0, 0, 0))
pnucleolusButton = button(35, (0, 255, 0), 280, 143, 110, 30, 'function')
pnucleolusButton.draw(display, (0, 0, 0))
pribosomeButton = button(35, (0, 255, 0), 240, 215, 110, 30, 'function')
pribosomeButton.draw(display, (0, 0, 0))
pvacuoleButton = button(35, (0, 255, 0), 227, 337, 110, 30, 'function')
pvacuoleButton.draw(display, (0, 0, 0))
pmitochondrionButton = button(35, (0, 255, 0), 315, 405, 110, 30, 'function')
pmitochondrionButton.draw(display, (0, 0, 0))
pmembraneButton = button(35, (0, 255, 0), 370, 470, 110, 30, 'function')
pmembraneButton.draw(display, (0, 0, 0))
cellwallButton = button(35, (0, 255, 0), 770, 65, 110, 30, 'function')
cellwallButton.draw(display, (0, 0, 0))

pygame.display.update()
plantrunning = True
while (plantrunning):
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
plantrunning = False
running =True
if event.type == pygame.MOUSEBUTTONDOWN:
if backButton.isOver(pos):
e = "a"
plantrunning = False
elif pnucleolusButton.isOver(pos):
e = "pnucleolusButton"
plantrunning = False
elif chloroplastButton.isOver(pos):
e = "chloroplastButton"
plantrunning = False
elif pribosomeButton.isOver(pos):
e = "pribosomeButton"
plantrunning = False
elif pvacuoleButton.isOver(pos):
e = "pvacuoleButton"
plantrunning = False
elif pmitochondrionButton.isOver(pos):
e = "pmitochondrionButton"
plantrunning = False
elif pmembraneButton.isOver(pos):
e = "pmembraneButton"
plantrunning = False
elif cellwallButton.isOver(pos):
e = "cellwallButton"
plantrunning = False
if e == "pnucleolusButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nproduction of ribosomes and synthesis of ribosomal RNA (rRNA)"
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "chloroplastButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nabsorb sunlight from sun for carrying out photosynthesis."
font = pygame.font.SysFont('Arial', 45)

nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "pribosomeButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nresponsible for assembling the proteins of the cell"
font = pygame.font.SysFont('Arial', 45)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "pvacuoleButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nprovide the plant with support or rigidity, a storage area for
nutrients and waste matter and can decompose complex molecules"
font = pygame.font.SysFont('Arial', 45)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "pribosomeButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nresponsible for assembling the proteins of the cell"
font = pygame.font.SysFont('Arial', 45)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "pmitochondrionButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nThe main function of mitochondria is the production of ATP through
cellular respiration"
font = pygame.font.SysFont('Arial', 45)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "pmembraneButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \nA cell membrane is a thin layer that acts as a barrier that
separates an individual cell or a cellular compartment from other surrounding
structures"
font = pygame.font.SysFont('Arial', 45)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True
elif e == "cellwallButton":
display = pygame.display.set_mode((600, 382))
background = pygame.image.load('backforlittle.jpg').convert()
display.blit(background, (0, 0))
pygame.display.update()
text = " \n\nThe cell wall gives cells shape, enables plant growth, prevents
bursting from water pressure, keeps out water and pathogens, stores carbohydrates and
sends signals to cells. "
font = pygame.font.SysFont('Arial', 40)
nextButton = button(30, (255, 0, 0), 20, 25, 150, 50, 'go back!')
nextButton.draw(display, (0, 0, 0))
pygame.display.update()
littlerunning = True
while (littlerunning):
blit_text(display, text, (20, 20), font)
pygame.display.update()
pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
littlerunning = False
running = True
if event.type == pygame.MOUSEBUTTONDOWN:
if nextButton.isOver(pos):
e = "p"
littlerunning = False
plantrunning = True

You might also like