I am installing pygame via macports. I followed the instructions as such,
sudo port install py26-game
Wrote the pygame code as such:
#image settings
bif = "bg.jpg"
mif = "ball.jpg"
#Basic Settings for pygame
import pygame, sys
from pygame.locals import *
pygame.init()
#Create a screen and load the images
screen = pygame.display.set_mode((640,360),0,32) #size,flag,bit
background = pygame.image.load(bif).convert()
mouse_c = pygame.image.load(mif).convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.blit(background,(0,0))
x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2
screen.blit(mouse_c,(x,y))
pygame.display.update()
I am using sublime text 2 to build the game, but I have this error:
Traceback (most recent call last):
File "PygameTutorial.py", line 6, in <module>
import pygame, sys
ImportError: No module named pygame
In my terminal, tried the same and have the same error:
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygame
How to solve this?