Sign in to follow this  
llamaSong

Python+Graphics

Recommended Posts

I am wondering how I would go about making a tetris game in python. I have been learning python for about 3 days now, and I have probaly spent about 12 hours on python. I choose python because I heard it was an easy to learn langauge. I read two guides at python.org. If you want I can post a link. I have made a hang man style game, but with out any art. Basicly one player enters a word, and another player guesses 1 letter at a time, and if hes right it reveals that letter in the word. I have made several other programs as well. I want to make a game like tetris, since that is what one of the guides here stated I should start with. Both the guides I read on python did not explain how to make graphics of falling peices, and collision detection. From what I understand, I should either use opengl or direct. I would like to use open GL. So how I would get opengl, and use it with python? IS that possible?

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
I don't know about OpenGL, but have you been to http://www.pygame.org/



I looked at that, but it wont work for me. There is no guide anywhere on that site that explains how to even use the pygame program thing. I copied the bouncing ball guide thing exactly, and It would not work.

Share this post


Link to post
Share on other sites
Quote:
Original post by llamaSong
Quote:
Original post by Boder
I don't know about OpenGL, but have you been to http://www.pygame.org/



I looked at that, but it wont work for me. There is no guide anywhere on that site that explains how to even use the pygame program thing. I copied the bouncing ball guide thing exactly, and It would not work.


Okay so the problem is the code cant find the pygame module. I have now installed pygame 3 times. I STILL CAN NOT FIND IT ON MY COMPUTER!!!!
This is what I get when I run the Chimp program in the examples:
IMportError: No module named pygame
traceback(innermost last)
File "chimp.py", line 11, in ?
import os, pygame

Share this post


Link to post
Share on other sites

#!/usr/bin/python

import os , sys
import pygame
from pygame.locals import *

pygame.init()

size = width, height = 800 , 600
speed = [2, 2]
black = 0, 0, 0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ayumi10.jpg")
ballrect = ball.get_rect()

while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()

ballrect = ballrect.move(speed)

if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0 or ballrect.bottom > height:
speed[1] = -speed[1]

screen.fill(black)
screen.blit(ball, ballrect)
pygame.display.flip()



do you mean this code? if so, it works fine for me.

have you tried checking the module path to see if pygame exists? (I don't know where this is on windows).

Share this post


Link to post
Share on other sites
Quote:
Original post by Genjix
*** Source Snippet Removed ***

do you mean this code? if so, it works fine for me.

have you tried checking the module path to see if pygame exists? (I don't know where this is on windows).


Genjix I use a mac.
I copied that exact code you put there, and this time I get:
IndetationError: expected an indented block (<Untitled Script 1>, line 18)

Traceback (Innermost Last):
File "PyEdit.py", line 1176, in execstring
code = compile(pytext, filename, "exec").

If your on a mac, can you explain to me how to get the pygame thing working.
For example, when I run the Chimp.py in the examples area, I get ImportError: No module named pygame
tracback (innermost last)
File "chimp.py", line 11, in ?
import os, pygame
I have installed pygame 3 times.
Once because It came with my mac, along with python
once because I did not know I had it
once because I thought id did not work.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Getting pygame to work on the mac used to be very difficult. I was eventually able to do it by upgrading all python-related material using Mac Update from the apple menu and then making sure I installed all python 2.4 dependencies (Numeric, PyOpenGL, etc.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Getting pygame to work on the mac used to be very difficult. I was eventually able to do it by upgrading all python-related material using Mac Update from the apple menu and then making sure I installed all python 2.4 dependencies (Numeric, PyOpenGL, etc.)


SO is there a way I can make graphics with out pygame?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this