Comments on: Pygame Starfield Rain http://www.scriptedfun.com/pygame-starfield-rain/ Game Programming for Beginners: Video Tutorials, Source Code, and Articles Mon, 18 May 2009 14:34:51 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: Kamilche http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-975 Kamilche Thu, 26 Oct 2006 18:26:12 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-975 Since the forum ate my spaces, here's a link to the smaller faster rain generator: http://incarnation.danbo.com/ubbthreads/showflat.php?Cat=0&Number=10483&an=0&page=0#Post10483 [url]http://incarnation.danbo.com/ubbthreads/showflat.php?Cat=0&Number=10483&an=0&page=0#Post10483[/url] Since the forum ate my spaces, here’s a link to the smaller faster rain generator:

http://incarnation.danbo.com/ubbthreads/showflat.php?Cat=0&Number=10483&an=0&page=0#Post10483
[url]http://incarnation.danbo.com/ubbthreads/showflat.php?Cat=0&Number=10483&an=0&page=0#Post10483[/url]

]]>
By: Kamilche http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-974 Kamilche Thu, 26 Oct 2006 18:22:03 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-974 I thought your rain generator was interesting. Here's a short version, that goes 10x faster, and still uses dirty rectangles. Enjoy! import pygame import random import time SCREENSIZE = 640, 480 class Rain(object): ' Rain generator' drops = [] height = 160 speed = 1 color = (255, 255, 255, 255) chance = .05 def __init__(self, **kwargs): ' Allow programmer to change settings of rain generator' self.__dict__.update(kwargs) def Render(self, screen): ' Render the rain' dirtyrects = [] for drop in self.drops: dr = drop.Render(dirtyrects, screen) if drop.dead: self.drops.remove(drop) dirtyrects.append(dr) if random.random() self.maxy: self.dead = 1 else: screen.blit(self.pic, self.pos) return r def main(): # Initialize pygame pygame.init() screen = pygame.display.set_mode(SCREENSIZE, 0, 32) # Create rain generator rain = Rain() # Main loop nexttime = time.time() ctr = 0 quit = 0 while not quit: # Uncomment the following line to make the rain go slower #time.sleep(.01) # Track FPS if time.time() > nexttime: nexttime = time.time() + 1 print '%d fps' % ctr ctr = 0 ctr += 1 # Draw rain screen.fill((0, 0, 0, 0)) r = rain.Render(screen) # Look for user quit pygame.display.update(r) pygame.event.pump() for e in pygame.event.get(): if e.type in [pygame.QUIT, pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN]: quit = 1 break # Terminate pygame pygame.quit() if __name__ == "__main__": main() I thought your rain generator was interesting. Here’s a short version, that goes 10x faster, and still uses dirty rectangles. Enjoy!

import pygame
import random
import time

SCREENSIZE = 640, 480

class Rain(object):
‘ Rain generator’
drops = []
height = 160
speed = 1
color = (255, 255, 255, 255)
chance = .05

def __init__(self, **kwargs):
‘ Allow programmer to change settings of rain generator’
self.__dict__.update(kwargs)

def Render(self, screen):
‘ Render the rain’
dirtyrects = []
for drop in self.drops:
dr = drop.Render(dirtyrects, screen)

if drop.dead:
self.drops.remove(drop)
dirtyrects.append(dr)
if random.random() self.maxy:
self.dead = 1
else:
screen.blit(self.pic, self.pos)
return r

def main():
# Initialize pygame
pygame.init()
screen = pygame.display.set_mode(SCREENSIZE, 0, 32)

# Create rain generator
rain = Rain()

# Main loop
nexttime = time.time()
ctr = 0
quit = 0
while not quit:

# Uncomment the following line to make the rain go slower
#time.sleep(.01)

# Track FPS
if time.time() > nexttime:
nexttime = time.time() + 1
print ‘%d fps’ % ctr
ctr = 0
ctr += 1

# Draw rain
screen.fill((0, 0, 0, 0))
r = rain.Render(screen)

# Look for user quit
pygame.display.update(r)
pygame.event.pump()
for e in pygame.event.get():
if e.type in [pygame.QUIT, pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN]:
quit = 1
break

# Terminate pygame
pygame.quit()

if __name__ == “__main__”:
main()

]]>
By: VxD http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-966 VxD Tue, 24 Oct 2006 10:38:20 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-966 hehe, scriptfun may be the future community of game creators who share their codes and advices.. python/pygame is a language who permit this way. good luck Chuck ! hehe, scriptfun may be the future community of game creators who share their codes and advices.. python/pygame is a language who permit this way.

good luck Chuck !

]]>
By: Chuck http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-959 Chuck Sun, 22 Oct 2006 04:20:41 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-959 Thanks for the suggestion, Dave. I might consider putting up a forum sometime in the future, but for now, I would like to focus my efforts on adding content to this site. Thank you again! Thanks for the suggestion, Dave. I might consider putting up a forum sometime in the future, but for now, I would like to focus my efforts on adding content to this site. Thank you again!

]]>
By: Dave http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-958 Dave Sat, 21 Oct 2006 20:20:30 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-958 typing in comments like this is annoying. I think you should start a simple free forum. There is al ist of software here: http://thinkofit.com/webconf/forumsoft.htm typing in comments like this is annoying. I think you should start a simple free forum. There is al ist of software here: http://thinkofit.com/webconf/forumsoft.htm

]]>
By: Chuck http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-957 Chuck Sat, 21 Oct 2006 11:27:58 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-957 The droplet's appearance is determined by the dropimage() function. To make the drop circular, you would probably have to change the line with the fill into this: pygame.draw.circle(image, (255, 255, 255), (1, 1), 2) Here, we use pygame's draw module to draw a white circle at the center of the "droplet surface" with radius 2, which should just about fill the "droplet surface". Hope this helps. The droplet’s appearance is determined by the dropimage() function. To make the drop circular, you would probably have to change the line with the fill into this:

pygame.draw.circle(image, (255, 255, 255), (1, 1), 2)

Here, we use pygame’s draw module to draw a white circle at the center of the “droplet surface” with radius 2, which should just about fill the “droplet surface”.

Hope this helps.

]]>
By: Dave http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-956 Dave Sat, 21 Oct 2006 04:22:23 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-956 Thanks! :) I have read over the code a few times and i've figured out how it works. I have one question. When you look at the rain droplets, you see that they are square shaped. Is there a way to make them circular? Thanks! :) I have read over the code a few times and i’ve figured out how it works. I have one question. When you look at the rain droplets, you see that they are square shaped. Is there a way to make them circular?

]]>
By: Chuck http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-955 Chuck Fri, 20 Oct 2006 13:45:47 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-955 Carlo: Thank you so much for visiting the site, and I'm glad you've found the tutorials helpful. Sure, I'd like to see what you're working on :). Thanks for the link to the article. I've come across this article before, and I think it's really interesting. Hopefully, I'll be able to use the content of the article eventually to write something on game physics implementation. And yes, as you have pointed out, it should work well with a particle system. Thanks for pointing it out! Dave: Sure! Feel free to use the code as you wish. :) Carlo: Thank you so much for visiting the site, and I’m glad you’ve found the tutorials helpful. Sure, I’d like to see what you’re working on :) . Thanks for the link to the article. I’ve come across this article before, and I think it’s really interesting. Hopefully, I’ll be able to use the content of the article eventually to write something on game physics implementation. And yes, as you have pointed out, it should work well with a particle system. Thanks for pointing it out!

Dave: Sure! Feel free to use the code as you wish. :)

]]>
By: Dave http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-944 Dave Thu, 19 Oct 2006 19:59:35 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-944 this is really interesting. Can I use the code in my own game? this is really interesting. Can I use the code in my own game?

]]>
By: Carlo http://www.scriptedfun.com/pygame-starfield-rain/comment-page-1/#comment-942 Carlo Wed, 18 Oct 2006 21:03:34 +0000 http://www.scriptedfun.com/pygame-starfield-rain/#comment-942 Hey there, been following your blog for a while. I really like your tutorials, they're very helpful to me. I'm working on a pygame of my own, I'd like to get your opinion on it if you don't mind. As for a particle system, have you heard of Verlet integration? Here's the paper on it: http://www.teknikus.dk/tj/gdc2001.htm It makes for really nice animations, and is nice because you only have to store the current location and old location of a particle. Hey there, been following your blog for a while. I really like your tutorials, they’re very helpful to me. I’m working on a pygame of my own, I’d like to get your opinion on it if you don’t mind.

As for a particle system, have you heard of Verlet integration? Here’s the paper on it: http://www.teknikus.dk/tj/gdc2001.htm

It makes for really nice animations, and is nice because you only have to store the current location and old location of a particle.

]]>
1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214| no prescription antibiotics online online pharmacy no prescription astelin purchase lipitor medication eurax kaufen ohne rezept cheapest premarin without prescription purchase cheap maxalt cheap citalopram no prescription bactrim without prescription how to buy bupropion online no prescription buying actos with no prescriptionAccutane Online Doxycycline online Buy Cheap Lexapro Online No Prescription Prednisone Online Buy Accutane No Prescription