Re: [pygame] Capabilities of Pygame

2012-01-14 Thread ANKUR AGGARWAL
You can check put my repository for  pygame examples
https://github.com/ankur0890/Pygame-Examples-For-Learning

On Sat, Jan 14, 2012 at 4:33 AM, R. Alan Monroe wrote:

> > FORTRAN is still used in some circles because it's
> > still very fast for number crunching.
>
> A bit off topic, but I've seen this bit of folk wisdom repeated online
> for a long time and have always been skeptical. How does a C command
> that gets compiled to a CPU's MUL instruction differ in any way from a
> Fortran command that also gets compiled to that same CPU's same MUL
> instruction? Honest question.
>
> Alan
>
>


Re: [pygame] Continuous Shooting

2012-01-13 Thread ANKUR AGGARWAL
Yeah.. I applied the counter logic and it worked for me :) Thanks a lot :)

Regards
Ankur Aggarwal

On Fri, Jan 13, 2012 at 12:02 AM, Julian Marchant  wrote:

> First off, you need some sort of time management. As it is now, it'll run
> at variable speeds depending on how fast the processor is. Use
> pygame.time.Clock to limit the frame rate and/or use delta timing.
>
> As for your problem, all you need is a counter variable. Have the counter
> variable start at 0 and decrease it by 1 (or the amount of time passed if
> you're using delta timing) each time the loop happens. When the shoot key
> is pressed, create a bullet and set the counter to the amount of time you
> want to wait for the next bullet. Then, if the shoot key is held down while
> the loop variable is 0, create another bullet and reset the counter to the
> wait time.
>
> --- On *Thu, 1/12/12, ANKUR AGGARWAL * wrote:
>
>
> From: ANKUR AGGARWAL 
> Subject: [pygame] Continuous Shooting
> To: pygame-users@seul.org, tu...@python.org
> Date: Thursday, January 12, 2012, 12:39 PM
>
>
> Hey
> I was making a demo shooting game and problem is that I want
> a continuous stream of bullets. As of now on pressing the space key only
> one bullet comes out of the plane (I want this to be continuous stream). On
> pressing space key again bullet starts from its initial point. My problem
> in the code is that I am able to make a single object of Bullet only (thats
> why it is throwing single bullet) and unable to find the another logic.
> Please help me out. Attaching the files along with this mail.
>
> import pygame
> from pygame.locals import *
> import random
>
> pygame.init()
> screen=pygame.display.set_mode((640,480),0,24)
> pygame.display.set_caption("Hit The Stone")
>
> class Plane(pygame.sprite.Sprite):
> def __init__(self,bullet):
> self.bullet=bullet
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.image.load('plane.gif').convert()
> self.rect=self.image.get_rect()
> self.rect.centerx=random.randint(0,screen.get_width())
> self.distancefromcenter=30
> self.rect.centery=screen.get_height()-self.distancefromcenter
> self.dx=2
> self.dy=2
>
> def update(self):
> pressed=pygame.key.get_pressed()
> if pressed[K_DOWN]:
> self.rect.centery+=self.dy
> elif pressed[K_UP]:
> self.rect.centery-=self.dy
> elif pressed[K_LEFT]:
> self.rect.centerx-=self.dx
> elif pressed[K_RIGHT]:
> self.rect.centerx+=self.dx
>
>
> if self.rect.bottom>=screen.get_height():
> self.rect.bottom=screen.get_height()
> elif self.rect.top<=0:
> self.rect.top=0
>
> if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
> self.rect.centerx=screen.get_width()-self.distancefromcenter
> elif self.rect.centerx<=self.distancefromcenter:
> self.rect.centerx=self.distancefromcenter
>
> if pressed[K_SPACE]:
> self.bullet.x=self.rect.centerx
> self.bullet.y=self.rect.centery
>
>
>
> class Bullet(pygame.sprite.Sprite):
> def __init__(self):
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.image.load('geometrybullet.png').convert_alpha()
> self.rect=self.image.get_rect()
> self.rect.center=(-100,-100)
> self.x=-100
>  self.y=-100
> self.dy=5
>
>
> def update(self):
> self.y-=self.dy
> self.rect.center=(self.x,self.y)
> if self.rect.top<0:
> self.x=-100
> self.y=-100
>
>
> def main():
> background=pygame.Surface(screen.get_size())
> background=background.convert()
> screen.blit(background,(0,0))
> bullet=Bullet()
> plane=Plane(bullet)
> allSprites=pygame.sprite.Group(plane,bullet)
>
> while 1:
> for i in pygame.event.get():
> quitPressed=pygame.key.get_pressed()
> if i.type==QUIT or quitPressed[K_q]:
> exit()
>
> allSprites.clear(screen,background)
>  allSprites.update()
> allSprites.draw(screen)
> pygame.display.flip()
>
>
> if __name__=='__main__':
> main()
>
> Thanks in advance :)
>
> Regards
> Ankur Aggarwal
>
>
>
>


Re: [pygame] Delay Between iterations

2012-01-13 Thread ANKUR AGGARWAL
Hey Nate
I applied your solution and it worked for me :) Thanks a lot :)
Thanks to everybody else too :)

Regards
Ankur Aggarwal

On Fri, Jan 13, 2012 at 2:15 AM, Zack Baker  wrote:

> Sorry nevermind. Saw your next email
>
> On Jan 12, 2012, at 12:35 PM, ANKUR AGGARWAL wrote:
>
> In the last code provided I messed up the Bullet Class Code. Apologies for
> that. Below is my code :
>
> import pygame
> from pygame.locals import *
> import random
> import time
>
> pygame.init()
> screen=pygame.display.set_mode((640,480),0,24)
> pygame.display.set_caption("Hit The Stone")
> background=pygame.Surface(screen.get_size())
> background=background.convert()
> screen.blit(background,(0,0))
>
> class Plane(pygame.sprite.Sprite):
> def __init__(self):
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.image.load('plane.gif').convert()
> self.rect=self.image.get_rect()
> self.rect.centerx=random.randint(0,screen.get_width())
> self.distancefromcenter=30
> self.rect.centery=screen.get_height()-self.distancefromcenter
> self.dx=2
> self.dy=2
>
> def update(self):
> self.pressed=pygame.key.get_pressed()
> if self.pressed[K_DOWN]:
> self.rect.centery+=self.dy
> elif self.pressed[K_UP]:
> self.rect.centery-=self.dy
> elif self.pressed[K_LEFT]:
> self.rect.centerx-=self.dx
> elif self.pressed[K_RIGHT]:
> self.rect.centerx+=self.dx
>
>
> if self.rect.bottom>=screen.get_height():
> self.rect.bottom=screen.get_height()
> elif self.rect.top<=0:
> self.rect.top=0
>
> if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
> self.rect.centerx=screen.get_width()-self.distancefromcenter
> elif self.rect.centerx<=self.distancefromcenter:
> self.rect.centerx=self.distancefromcenter
>
>
>
>
> class Bullet(pygame.sprite.Sprite):
> def __init__(self,posx,posy,image):
> pygame.sprite.Sprite.__init__(self)
> self.image=image
> self.rect=self.image.get_rect()
> self.rect.center=(posx,posy-30)
> self.dy=5
>
>
>
> def update(self):
> self.rect.centery-=self.dy
> self.rect.center=(self.rect.centerx,self.rect.centery)
> if self.rect.top<=0:
> self.kill()
> class Blank(pygame.sprite.Sprite):
> def __init__(self,posx,posy):
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.Surface((10,20))
> self.image.fill((0,0,0))
> self.rect=self.image.get_rect()
> self.rect.center=(posx,posy-30)
> self.dy=5
>
>
> def update(self):
> self.rect.centery-=self.dy
> self.rect.center=(self.rect.centerx,self.rect.centery)
> if self.rect.top<=0:
> self.kill()
>
>
> def main():
> image=pygame.image.load('geometrybullet.png').convert()
> plane=Plane()
> allSprites=pygame.sprite.Group(plane)
> clock=pygame.time.Clock()
>
> while 1:
> pressed=pygame.key.get_pressed()
> for i in pygame.event.get():
> if i.type==QUIT or pressed[K_q]:
> exit()
> if  pressed[K_SPACE]:
> bullet=Bullet(plane.rect.centerx,plane.rect.centery,image)
> bullet.shootCount=0
> allSprites.add(bullet)
>
>
> allSprites.clear(screen,background)
> allSprites.update()
> allSprites.draw(screen)
> pygame.display.flip()
>
>
> if __name__=='__main__':
> main()
>
>
>
> On Thu, Jan 12, 2012 at 11:01 PM, ANKUR AGGARWAL 
> wrote:
>
>> import pygame
>> from pygame.locals import *
>> import random
>>
>> pygame.init()
>> screen=pygame.display.set_mode((640,480),0,24)
>> pygame.display.set_caption("Hit The Stone")
>> background=pygame.Surface(screen.get_size())
>> background=background.convert()
>> screen.blit(background,(0,0))
>>
>> class Plane(pygame.sprite.Sprite):
>> def __init__(self):
>> pygame.sprite.Sprite.__init__(self)
>> self.image=pygame.image.load('plane.gif').convert()
>> self.rect=self.image.get_rect()
>> self.rect.centerx=random.randint(0,screen.get_width())
>> self.distancefromcenter=30
>> self.rect.centery=screen.get_height()-self.distancefromcenter
>> self.dx=2
>> self.dy=2
>>
&g

[pygame] Re: Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
In the last code provided I messed up the Bullet Class Code. Apologies for
that. Below is my code :

import pygame
from pygame.locals import *
import random
import time

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))

class Plane(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
self.pressed=pygame.key.get_pressed()
if self.pressed[K_DOWN]:
self.rect.centery+=self.dy
elif self.pressed[K_UP]:
self.rect.centery-=self.dy
elif self.pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif self.pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter




class Bullet(pygame.sprite.Sprite):
def __init__(self,posx,posy,image):
pygame.sprite.Sprite.__init__(self)
self.image=image
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5



def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()
class Blank(pygame.sprite.Sprite):
def __init__(self,posx,posy):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.Surface((10,20))
self.image.fill((0,0,0))
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5


def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()


def main():
image=pygame.image.load('geometrybullet.png').convert()
plane=Plane()
allSprites=pygame.sprite.Group(plane)
clock=pygame.time.Clock()

while 1:
pressed=pygame.key.get_pressed()
for i in pygame.event.get():
if i.type==QUIT or pressed[K_q]:
exit()
if  pressed[K_SPACE]:
bullet=Bullet(plane.rect.centerx,plane.rect.centery,image)
bullet.shootCount=0
allSprites.add(bullet)


allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
main()



On Thu, Jan 12, 2012 at 11:01 PM, ANKUR AGGARWAL wrote:

> import pygame
> from pygame.locals import *
> import random
>
> pygame.init()
> screen=pygame.display.set_mode((640,480),0,24)
> pygame.display.set_caption("Hit The Stone")
> background=pygame.Surface(screen.get_size())
> background=background.convert()
> screen.blit(background,(0,0))
>
> class Plane(pygame.sprite.Sprite):
> def __init__(self):
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.image.load('plane.gif').convert()
> self.rect=self.image.get_rect()
> self.rect.centerx=random.randint(0,screen.get_width())
> self.distancefromcenter=30
> self.rect.centery=screen.get_height()-self.distancefromcenter
> self.dx=2
> self.dy=2
>
> def update(self):
> self.pressed=pygame.key.get_pressed()
> if self.pressed[K_DOWN]:
> self.rect.centery+=self.dy
> elif self.pressed[K_UP]:
> self.rect.centery-=self.dy
> elif self.pressed[K_LEFT]:
> self.rect.centerx-=self.dx
> elif self.pressed[K_RIGHT]:
> self.rect.centerx+=self.dx
>
>
> if self.rect.bottom>=screen.get_height():
> self.rect.bottom=screen.get_height()
> elif self.rect.top<=0:
> self.rect.top=0
>
> if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
> self.rect.centerx=screen.get_width()-self.distancefromcenter
> elif self.rect.centerx<=self.distancefromcenter:
> self.rect.centerx=self.distancefromcenter
>
>
>
>
&g

[pygame] Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))

class Plane(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
self.pressed=pygame.key.get_pressed()
if self.pressed[K_DOWN]:
self.rect.centery+=self.dy
elif self.pressed[K_UP]:
self.rect.centery-=self.dy
elif self.pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif self.pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter




class Bullet(pygame.sprite.Sprite):
def __init__(self,posx,posy,image):
pygame.sprite.Sprite.__init__(self)
if self.shootCount>10:
self.image=image
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5
else:
self.shootCount+=1


def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()


def main():
image=pygame.image.load('geometrybullet.png').convert()
plane=Plane()
allSprites=pygame.sprite.Group(plane)
clock=pygame.time.Clock()

while 1:
pressed=pygame.key.get_pressed()
for i in pygame.event.get():
if i.type==QUIT or pressed[K_q]:
exit()
*if  pressed[K_SPACE]:*
*bullet=Bullet(plane.rect.centerx,plane.rect.centery,image)*
*bullet.shootCount=0*
*allSprites.add(bullet)*


allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
main()


I was trying to make shooting game. whenever I press the space key bullet
object is called (bold code) . I want delay between iterations to produce
the gap between the bullets.Tried the time.wait() but its working. Any
Ideas??

Thanks In Advance

Regards
Ankur Aggarwal


[pygame] Continuous Shooting

2012-01-12 Thread ANKUR AGGARWAL
Hey
I was making a demo shooting game and problem is that I want
a continuous stream of bullets. As of now on pressing the space key only
one bullet comes out of the plane (I want this to be continuous stream). On
pressing space key again bullet starts from its initial point. My problem
in the code is that I am able to make a single object of Bullet only (thats
why it is throwing single bullet) and unable to find the another logic.
Please help me out. Attaching the files along with this mail.

import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")

class Plane(pygame.sprite.Sprite):
def __init__(self,bullet):
self.bullet=bullet
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
pressed=pygame.key.get_pressed()
if pressed[K_DOWN]:
self.rect.centery+=self.dy
elif pressed[K_UP]:
self.rect.centery-=self.dy
elif pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter

if pressed[K_SPACE]:
self.bullet.x=self.rect.centerx
self.bullet.y=self.rect.centery



class Bullet(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('geometrybullet.png').convert_alpha()
self.rect=self.image.get_rect()
self.rect.center=(-100,-100)
self.x=-100
self.y=-100
self.dy=5


def update(self):
self.y-=self.dy
self.rect.center=(self.x,self.y)
if self.rect.top<0:
self.x=-100
self.y=-100


def main():
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))
bullet=Bullet()
plane=Plane(bullet)
allSprites=pygame.sprite.Group(plane,bullet)

while 1:
for i in pygame.event.get():
quitPressed=pygame.key.get_pressed()
if i.type==QUIT or quitPressed[K_q]:
exit()

allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
    main()

Thanks in advance :)

Regards
Ankur Aggarwal
<><>import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")

class Plane(pygame.sprite.Sprite):
def __init__(self,bullet):
self.bullet=bullet
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
pressed=pygame.key.get_pressed()
if pressed[K_DOWN]:
self.rect.centery+=self.dy
elif pressed[K_UP]:
self.rect.centery-=self.dy
elif pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter

if pressed[K_SPACE]:
self.bullet.x=self.rect.centerx
self.bullet.y=self.rect.centery



class Bullet(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('geometrybullet.png').convert_alpha()
self.rect=self.image.get_rect()
self.rect.center=(-100,-100)
self.x=-100
self.y=-100

[pygame] Demo Paint Program

2011-12-28 Thread ANKUR AGGARWAL
Created A Paint Demo Using Pygame API. It's in the github pygame-example
repo. Check this out https://github.com/ankur0890/
Pygame-Examples-For-Learning/blob/master/paint.py . Got the idea from "Game
Programming By Andy Harris" . Applied my own logic over the idea though :)

Regards
Ankur Aggarwal


Re: [pygame] Github Pygame Example Repository

2011-12-19 Thread ANKUR AGGARWAL
Thanks for your support... will do that asap :)

On Tue, Dec 20, 2011 at 12:20 AM, Jeremy Sharpe <
jeremy.adamson.sha...@gmail.com> wrote:

> Good stuff.
>
> Looking around your repository, be careful not to include *~ and .pyc
> files in your repo.
>
> (To get rid of them permanently, delete them from the repo, and then
> add *~ and *.pyc to your .gitignore.)
>
> On Sun, Dec 18, 2011 at 12:32 PM, Jake b  wrote:
> > Nice.
> >
> > For the main game loop, I like to do:
> > while not done:
> > # ...events , draw...
> > if pressed[K_ESC]: done = True
> >
> > # to allow smooth exit / save game state / cleanup if needed.
> >
> > check out : pygame.Color() http://www.pygame.org/docs/ref/color.html
> >
> > You can post your code on the site, with a link to your repo.
> > http://www.pygame.org/tags/tutorial
> > --
> > Jake
>


[pygame] Github Pygame Example Repository

2011-12-17 Thread ANKUR AGGARWAL
I have created an pygame example repo on github to promote the
learning of this API. check this out
https://github.com/ankur0890/Pygame-Examples-For-Learning . I created
an blog post of the same on my linux blog :
http:.//flossstuff.wordpress.com/2011/12/17/github-repository-for-pygame-examples/
. Suggestions and feedback would be great. Looking for contribution
too :)

Regards
Ankur Aggarwal


[pygame] Difference Between pygame.draw and pygame.gfxdraw

2011-11-28 Thread ANKUR AGGARWAL
Hey
I was goofing around the web and found out the gfx draw API of the
python module. Through search and all found out that it is used to
draw shapes . pygame.draw also do the same work. So I want to know
what exactly is the difference between them??? I searched on the web a
lot but unable to find out an appropriate answers. Please help!!!
Thanks In Advance

Regards
Ankur Aggarwal


Re: [pygame] Making animation.

2011-05-28 Thread ANKUR AGGARWAL
I made a 3 level small snake game . It have used an  animated "blast" shown
during the snake collision. For that purpose I used a small sprite sheet and
subsurface concept. Download the game and figure it out. Code is available
at http://code.google.com/p/hungry-snakes/downloads/list

On Sun, May 29, 2011 at 12:41 AM, B W  wrote:

> And a couple more I bookmarked. There are possibly more on pygame.org.
>
> http://www.pygame.org/project-gradients-307-.html
> http://www.pygame.org/project-Pygame+Advance+Graphics+Library-660-.html
>
> For explosions, winking starts, muzzle flash, etc. you could search for
> spritesheets, which are cheap but usually adequate.
>
> Gumm
>
>
> On Sat, May 28, 2011 at 9:40 AM, Jake b  wrote:
>
>> Take a look at http://www.pygame.org/project-PyIgnition-1527-.html
>>
>> ( you don't need openGL. )
>>
>> --
>> Jake
>>
>
>


[pygame] Hungry Snake now on Softpedia

2011-05-14 Thread ANKUR AGGARWAL
Hey
I got a mail form softpedia today that they have added my game "Hungry
Snake"  to their site too under 100% free certificate. I am really happy
:):) I can feel the power of open source :):) Want to share this with you
people because I learned a lot from the python community .

Game Links - http://code.google.com/p/hungry-snakes/ ,
http://mac.softpedia.com/get/Games/Hungry-Snake.shtml
Certificate Link -
http://mac.softpedia.com/progClean/Hungry-Snake-Clean-98721.html

Thanks
Ankur Aggarwal


[pygame] 3 Level Snake Game Made using Pygame API

2011-05-11 Thread ANKUR AGGARWAL
Hey
Few weeks back I made out the basic of the snake game and released it on the
Web under the file name "hungry.py". Now I Upgraded It Into a 3 Level Game.
I test it on windows too and its working completely fine over there too.
Download the "Game.Zip" file to play all the three levels and "hungry.py" to
play the basic version. Releasing this under GPLv3 :):) Try it out and
feedback would be gr8. Here's the download link
http://code.google.com/p/hungry-snakes/downloads/list
Thanks
Ankur Aggarwal


Re: [pygame] Mouse Focus

2011-05-09 Thread ANKUR AGGARWAL
It worked :D:D
Thanks a lot :):)
Ankur Aggarwal

On Mon, May 9, 2011 at 1:49 PM, Scribble Master wrote:

> Use the rect of each text surface. Then you can get the mouse position with
> pygame.mouse.getpos()
> http://www.pygame.org/docs/ref/mouse.html#pygame.mouse.get_pos
>
> and check if the mouse's position is in that rect using
> Rect.collidepoint():
> http://www.pygame.org/docs/ref/rect.html#Rect.collidepoint
>
> If it is, execute the function for that level.
>
> Good luck!
>
>
> On Mon, May 9, 2011 at 2:43 AM, ANKUR AGGARWAL wrote:
>
>> I am getting some trouble with the mouse focus too.
>> I have render the text on the screen like-
>> level1
>> level2
>> level3
>>
>> I want an  algo that when i click on level1 , it executes the level1 . I
>> am unable to focus on the text too . Please give me an algo for it
>> Thanks in Advance
>> Ankur Aggarwal
>>
>
>


[pygame] Mouse Focus

2011-05-08 Thread ANKUR AGGARWAL
I am getting some trouble with the mouse focus too.
I have render the text on the screen like-
level1
level2
level3

I want an  algo that when i click on level1 , it executes the level1 . I am
unable to focus on the text too . Please give me an algo for it
Thanks in Advance
Ankur Aggarwal


Re: [pygame] Underline Text on Focus

2011-05-08 Thread ANKUR AGGARWAL
I tried it and google it on the web too. It's not working :(

On Mon, May 9, 2011 at 3:40 AM, Greg Ewing wrote:

> ANKUR AGGARWAL wrote:
>
>> Hey I want to underline the text as soon as mouse gets focussed on it.
>>
>
> Haven't used it myself, but Fonts have a set_underline()
> method that looks like it will do what you want.
>
> --
> Greg
>


[pygame] Underline Text on Focus

2011-05-08 Thread ANKUR AGGARWAL
Hey I want to underline the text as soon as mouse gets focussed on it. Can
you please tell me the algo for that
Thanks In Advance
Ankur Aggarwal


[pygame] Pygame on facebook

2011-05-04 Thread ANKUR AGGARWAL
Hey
I made a game using pygame API. i want to put the same on the
facebook. Is there's any way to do this. I search around the
developers.facebook.com and so far unable to seek something for
python. Can you please help in this matter. Thanks in Advance :):)
Ankur Aggarwal


[pygame] Rotation About A Point

2011-04-23 Thread ANKUR AGGARWAL
Hey I want to rotate the image about a point (100,100) but by using
the pygame.tranform.rotate image moves itself from the point along
with the rotation . Below is the code


import pygame
from pygame.locals import *
from sys import exit

pygame.init()
screen=pygame.display.set_mode((640,480),0,0)
pygame.display.set_caption("Rotation using transform module")

image=pygame.image.load("fugu.png").convert_alpha()
a=0
clock=pygame.time.Clock()
b=(100,100)
while True:
 for i in pygame.event.get():
  if i.type==QUIT:
   exit()
 screen.fill((0,0,0))
 a=a+10
 image=pygame.transform.rotate(image,a)
 screen.blit(image,(100,100))
 pygame.display.update()
 clock.tick(1)

Whats my mistake and whats the solution???
Thanks
Ankur Aggarwal


[pygame] First Game Attempt

2011-04-18 Thread ANKUR AGGARWAL
Hey
I was reading Pygame API for a month and made out a very basic ,small game
named as "Hungry Snake" as practice. Want to share out the code with uou
guys. Here's the link
http://code.google.com/p/hungry-snakes/downloads/list
Thanks
Ankur Aggarwal


Re: [pygame] Making the sprite sheet background transparent

2011-04-14 Thread ANKUR AGGARWAL
Yup,infact already did that. But I want to do it in python style :O:O

On Fri, Apr 15, 2011 at 1:03 AM, Eamonn McHugh-Roohr
wrote:

> It's easy enough to open it up in Photoshop or gimp and actually make the
> image's background transparent, then you just call .convert_alpha() on it
> after you load the image.
>
>
> On Thu, Apr 14, 2011 at 3:26 PM, ANKUR AGGARWAL 
> wrote:
>
>> Hey
>> I want to make the  sprite sheet background as  transparent. How I can do
>> that???
>> Code and the images is attached with the mail. Thanks in advance.
>>
>> Ankur Aggarwal
>>
>
>


[pygame] Making the sprite sheet background transparent

2011-04-14 Thread ANKUR AGGARWAL
Hey
I want to make the  sprite sheet background as  transparent. How I can do
that???
Code and the images is attached with the mail. Thanks in advance.

Ankur Aggarwal
import pygame
from pygame.locals import *
from sys import exit

counter=0

def update():
 global counter
 counter=(counter+1)%5

screen=pygame.display.set_mode((200,200),0,24)
pygame.display.set_caption("Sprite Try")
clock=pygame.time.Clock()
a=[]

image=pygame.image.load("frog.gif").convert()
width,height=image.get_size()


for i in xrange(int(width/44.2)):
  a.append(image.subsurface(i*44.2,0,44.2,41))

while True:
 for i in pygame.event.get():
  if i.type==QUIT:
   exit()


 screen.blit(a[counter],(100,100))
 

 update()
 pygame.display.update()
 clock.tick(5)
<>

[pygame] blit a list containing surfaces

2011-04-12 Thread ANKUR AGGARWAL
I created a list which contains the subsurfaces of the sprite image. Now i
want to blit it on the screen so that it seems to be like a animation. I
tried but unable to do so. So kindly help me in the algo of  how to blit
this list (Images=[, ,
, , ,
, , ]).
Thanks in advance
Ankur Aggarwal


[pygame] Sprite examples with images

2011-04-11 Thread ANKUR AGGARWAL
Hey
I am reading pygame and made out simple snake game as a practice. Now want
to get started with the world of sprites. I looked for the examples but most
of the examples are without the real images so unable to run them and know
their functionality. Can anybody send me the links of good examples of
sprites where images are also available so that i can get a better
understanding. Thanks in Advance :):)
Ankur Aggarwal


[pygame] Recommendations required

2011-04-04 Thread ANKUR AGGARWAL
Hey
I am reading pygame module and experimenting with it in small codes too . I
want your help. I want you to  recommend the games ,beginner of this module
should try to develop as a practice or so.
Thanks
Ankur Aggarwal