LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-18-2012, 07:19 AM   #1
Nabeel
Member
 
Registered: Nov 2009
Location: Pakistan
Distribution: Ubuntu
Posts: 294

Rep: Reputation: 17
Problem using pygame


well I'm taking a pygame course at coursehero and well the first program there is to make a window using pygame. Here's the code

Code:
# !/usr/bin/python

import sys, pygame

pygame.init()

size = width,height =800,600


screen = pygame.display.set_mode(size)
image = '/home/nabeel/Desktop/Python/Business_tux.png'
tux =pygame.image.load(image)
x=0
y=0
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:sys.exit()
    screen.fill((0,0,0))
    screen.blit(tux,[x,y])
    pygame.display.flip()
    x+=1
now this is supposed to draw an empty window and close once I click [x]. But sadly when I run this from terminal i get this error
Code:
nabeel@nabeel-Latitude-D800:~/Desktop/Python$ ./py_game.py
./py_game.py: line 7: syntax error near unexpected token `size'
./py_game.py: line 7: `size = width,height =800,600'
and when I run it from Idle, the window pops up but when I try to close itit doesnot close rather the control is given back to the shell(Window stays present Unless I close IDLE) This problem is present wth both python 2 and 3.
 
Old 12-18-2012, 09:37 AM   #2
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
Can't help you with PyGame related part, as I'm not familiar with it, but your first problem is happening because of this line:

Quote:
Originally Posted by Nabeel View Post
Code:
# !/usr/bin/python
You left the space after #, so this line is treated as an ordinary comment and your Python code is interpreted as shell script.
 
1 members found this post helpful.
Old 12-18-2012, 01:02 PM   #3
Nabeel
Member
 
Registered: Nov 2009
Location: Pakistan
Distribution: Ubuntu
Posts: 294

Original Poster
Rep: Reputation: 17
Worked Like a charm! Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Pygame 1.9.1 on Slackware64 14.0 t35t Slackware 4 12-14-2012 09:30 AM
Creating python + pygame binaries on Slackware 13.37 problem. Braqoon Slackware 3 01-12-2012 05:48 PM
Anybody used pygame before? How easy is it to use? vharishankar Programming 6 07-29-2006 08:17 AM
Help installing pygame Mike2001 Linux - Software 1 09-11-2004 06:12 PM
pygame kierwind Linux - Software 5 05-21-2003 04:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration