I dont have a website for the game, the main module is attached below. As for the frame rate, I have no real management, as I thought that it was not really necessary. Should I have some sort of frame rate control?
On 6/12/06, Rene Dudfield <[EMAIL PROTECTED]> wrote:
Do you have a link to your game? How do you manage the frame rate? On 6/13/06, talon spotter <[EMAIL PROTECTED]> wrote: > Hey everybody, > > I am writing a space invaders style game, and it works well on > windows. When I tried the game > under ubuntu linux(dapper), it was noticeably slow. After some > googling, I found this: > http://www.libsdl.org/pipermail/sdl/2006-May/074254.html > > I dont have access to any other distro of linux right now to check if > it is just a problem under ubuntu. I wasnt really able to see any > speed increase in pygame after opening up firefox, but i just casually > checked it and have not been able to do further tests as of yet. > > Has anybody heard of this? Does anybody have any ideas? > > Thanks, s. >
import pygame from pygame.locals import * from enemyship import EnemyShip from playership import PlayerShip import time import sys from bullet import Bullet import win_newlevel def play(bigidea): pygame.quit() pygame.init() boxes = pygame.sprite.Group() # using the sprite group global game_height game_height = 400 global game_width game_width = 400 if bigidea == None: sys.exit() #level = "level" num = bigidea[5] #print num #end = ".map.txt" color = [[255,0,0],[0,255,0],[0,50,205]] #location = [[10,15],[50,15],[90,15]] location = bigidea[0] #print bigidea[0] #print bigidea length = len(location) #times_to_kill = 5 times_to_kill = bigidea[2] for x in range(length): boxes.add(EnemyShip(location[x],times_to_kill)) # in sprite use .add() player = pygame.sprite.Group() player.add(PlayerShip([255,0,0], bigidea[1],3)) global screen screen = pygame.display.set_mode([game_width,game_height]) movingright = "" movingleft = "" movingup = "" movingdown = "" global enemybullets enemybullets = pygame.sprite.Group() #sprite group bullets = pygame.sprite.Group() #sprite group #player_bullet_speed = [0,-1] #speed of bullet #power = 1 #power of bullet? while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == KEYDOWN: if event.key == K_RIGHT: movingright = True elif event.key == K_LEFT: movingleft = True elif event.key == K_UP: movingup = True elif event.key == K_DOWN: movingdown = True elif event.key == K_SPACE: for players in player.sprites(): bullets.add(Bullet(color[0],players.get_pos(), 1)) bullets.update(game_height, game_width) print "guns fired" elif event.type == KEYUP: if event.key == K_RIGHT: movingright = False elif event.key == K_LEFT: movingleft = False elif event.key == K_UP: movingup = False elif event.key == K_DOWN: movingdown = False #elif event.type == KEYDOWN and event.key == K_ESCAPE: #print "guns fired!" if movingright == True: for players in player.sprites(): players.move_right() if movingleft == True: for players in player.sprites(): players.move_left() if movingup == True: for players in player.sprites(): players.move_up() if movingdown == True: for players in player.sprites(): players.move_down() screen.fill ([0,0,0]) #fill screen with black so screen is completely refreshed #salt = 30 #determines speed of enemy ship #pixels = 15 #the number of pixels in each direction salt = bigidea[3] #determines speed of enemy ship #print salt pixels = bigidea[4] #print pixels boxes.update(salt,pixels) #update method of the sprite group bullets.update(game_height, game_width) #update bullets for bullet in bullets.sprites(): screen.blit(bullet.image, bullet.rect) #show bullet enemybullets.update(game_height, game_width) #update enemy bullets for enebullets in enemybullets.sprites(): screen.blit(enebullets.image, enebullets.rect) #show bullet for b in boxes.sprites(): #b.update(salt, pixels) #salt determines speed #for salt (determine by difficulty/level number) #salt -slowest is 45 to 50, fastest possible is 1 #pixels is the amount of pixels to move in each direction #pixels can be changed according to the difficulty level screen.blit(b.image, b.rect) #show the image! #collision detection follows #if pygame.sprite.spritecollideany(b, bullets): # b.hit() # print "hit" #bullet and enemy collision detection for hits in pygame.sprite.groupcollide(boxes,bullets,0,1).keys(): hits.hit() # somehow, the hits.keys() gives the sprite object #print "enemy killed!" #print hits for hit_player in pygame.sprite.groupcollide(player, enemybullets, 0,1).keys(): hit_player.hit() #check if any enemies are left if boxes.sprites() == []: print "All enemies killed!" win_newlevel.win_newlevel(num) #print num #print num #pygame.quit() #sys.exit() if player.sprites() == []: print "You died!!" pygame.quit() sys.exit() #win_newlevel.win_newlevel(num) player.update(game_height*0.60,game_height,0,game_width) #screen.blit(player.image, player.rect) for players in player.sprites(): screen.blit(players.image, players.rect) pygame.display.update() time.sleep(0.01) #delay loop if __name__ == "__main__": play()