Hey guys. Ive been coding python for about a year now, and yesterday my older brother,who has no experience in programming at all, asked me when I was going to start programming video games. Is there some sort of test I can take to see if im ready for this type of programming? Thanks for all replies in advance.
Very simple :);
Do you know what to do?
Do you even know what you want to do?
There's a wide variety of games...
I'm sure you've heard of Pygame.. why don't you test it out.
I made a lil star-wars thing in a week..
lol pygame is fun, give it a go.. hardly industry standard top notch gaming, but you can make some very interesting games :)
Leet, what do you think is the best way to approach pygame from a game making point of view? I used pygame for an app I did not to long ago, and that was my first encounter with it. But that wasnt making a game...
Here is an interesting example I slightly modified.
import random, os, pygame from pygame.locals import * SCREEN_WIDTH = 742 SCREEN_HEIGHT = 600 def loadIageFile(name, useColorKey = False): fullname = os.path.join( "data", name ) try: image = pygame.image.load(fullname) except pygame.error, message: print "Cannot load image:", fullname raise SystemExit, message image = image.convert() if useColorKey is True: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, RLEACCEL) return image def loadSoundFile(name): class NoneSound: def play(self): pass if not pygame.mixer or not pygame.mixer.get_init(): return NoneSound() fullname = os.path.join("data", name) try: sound = pygame.mixer.Sound(fullname) except pygame.error, message: print "Cannot load sound:", fullname raise SystemExit, message return sound class XWing(pygame.sprite.Sprite): def __init__( self ): pygame.sprite.Sprite.__init__( self ) self.image = loadIageFile("xwing.bmp", True) self.rect = self.image.get_rect() self.rect.center = (SCREEN_WIDTH/2,SCREEN_HEIGHT) self.x_velocity = 0 self.y_velocity = 0 def update(self): self.rect.move_ip((self.x_velocity, self.y_velocity)) if self.rect.left < 0: self.rect.left = 0 elif self.rect.right > SCREEN_WIDTH: self.rect.right = SCREEN_WIDTH if self.rect.top <= SCREEN_HEIGHT/2: self.rect.top = SCREEN_HEIGHT/2 elif self.rect.bottom >= SCREEN_HEIGHT: self.rect.bottom = SCREEN_HEIGHT class TIEFighter( pygame.sprite.Sprite ): def __init__( self, startx ): pygame.sprite.Sprite.__init__( self ) self.image = loadIageFile("tie_fighter.bmp", True) self.rect = self.image.get_rect() self.rect.centerx = startx self.rect.centery = 120 self.x_velocity = random.randint(-7, 7) self.y_velocity = random.randint(-7, 7) def update(self): self.rect.move_ip((self.x_velocity, self.y_velocity)) if self.rect.left < 0 or self.rect.right > SCREEN_WIDTH: self.x_velocity = -(self.x_velocity) if self.rect.top < 0 or self.rect.bottom > SCREEN_HEIGHT/2: self.y_velocity = -(self.y_velocity) fire = random.randint( 1, 70 ) if fire == 1: tiefighterLaserSprites.add(TIEFighterLaser(self.rect.midbottom )) tiefighterShotFX.play() class XWingLaser(pygame.sprite.Sprite): def __init__(self, startpos): pygame.sprite.Sprite.__init__(self) self.image = loadIageFile("rebel_laser.bmp", True) self.rect = self.image.get_rect() self.rect.center = startpos def update(self): if self.rect.bottom <= 0: self.kill() else: self.rect.move_ip((0,-4)) class TIEFighterLaser(pygame.sprite.Sprite): def __init__( self, startpos ): pygame.sprite.Sprite.__init__( self ) self.image = loadIageFile("empire_laser.bmp", True) self.rect = self.image.get_rect() self.rect.midtop = startpos def update(self): if self.rect.bottom >= SCREEN_HEIGHT: self.kill() else: self.rect.move_ip( (0,4) ) def main(): random.seed() pygame.init() #screen = pygame.display.set_mode( (SCREEN_WIDTH, SCREEN_HEIGHT), FULLSCREEN ) #screen = pygame.display.set_mode( (SCREEN_WIDTH, SCREEN_HEIGHT), HWSURFACE|DOUBLEBUF ) screen = pygame.display.set_mode( (SCREEN_WIDTH, SCREEN_HEIGHT) ) pygame.display.set_caption("Star Wars") background_image = loadIageFile("background.bmp") background_rect = background_image.get_rect() screen.blit(background_image, (0,0)) #pygame.mouse.set_visible(False) explode1FX = loadSoundFile("explode1.wav") #explode2FX = loadSoundFile( "explode2.wav" ) global tiefighterShotFX tiefighterShotFX = loadSoundFile("empire_laser.wav") xwingShotFX = loadSoundFile("rebel_laser.wav") xwingSprite = pygame.sprite.RenderClear() xwing = XWing() xwingSprite.add(xwing) xwingLaserSprites = pygame.sprite.RenderClear() tiefighterSprites = pygame.sprite.RenderClear() tiefighterSprites.add(TIEFighter(150)) tiefighterSprites.add(TIEFighter(400)) tiefighterSprites.add(TIEFighter(650)) global tiefighterLaserSprites tiefighterLaserSprites = pygame.sprite.RenderClear() running = True addTieFighterCounter = 0 clock = pygame.time.Clock() while running is True: clock.tick(60) for event in pygame.event.get(): if event.type == QUIT: running = False elif event.type == KEYDOWN: if event.key == K_ESCAPE: running = False elif event.key == K_LEFT: xwing.x_velocity = -4 elif event.key == K_RIGHT: xwing.x_velocity = 4 elif event.key == K_UP: xwing.y_velocity = -4 elif event.key == K_DOWN: xwing.y_velocity = 4 elif event.key == K_SPACE: xwingLaserSprites.add( XWingLaser(xwing.rect.midtop)) xwingShotFX.play() elif event.type == KEYUP: if event.key == K_LEFT: xwing.x_velocity = 0 elif event.key == K_RIGHT: xwing.x_velocity = 0 elif event.key == K_UP: xwing.y_velocity = 0 elif event.key == K_DOWN: xwing.y_velocity = 0 addTieFighterCounter += 1 if addTieFighterCounter >= 200: tiefighterSprites.add( TIEFighter( 320 ) ) addTieFighterCounter = 0 xwingSprite.update() xwingLaserSprites.update() tiefighterSprites.update() tiefighterLaserSprites.update() for hit in pygame.sprite.groupcollide(tiefighterSprites, xwingLaserSprites, 1, 1): explode1FX.play() tiefighterLaserSprites.clear(screen, background_image) tiefighterSprites.clear(screen, background_image) xwingLaserSprites.clear(screen, background_image) xwingSprite.clear( screen, background_image) tiefighterLaserSprites.draw( screen ) xwingLaserSprites.draw(screen) tiefighterSprites.draw(screen) xwingSprite.draw(screen) pygame.display.flip() main()
Can you explain your code for me please? And if you dont have time to run through all of it can you run me through one of the class's. Like what is a rect? ALthough ive used __init__ before in some GUI builder(Tkinter I believe), I never really understood it. SO if you can run through those for me. Or you can just not run through any of it, which is fine to.
You're looking for this; http://www.codesampler.com/python.htm
I just messed with size dimensions, speed and crap to learn a bit of pygame.
The original is well commented (I tested out a script to remove all #'s from a file on it).
Its the 'simple star wars game'
Thanks again leet! If I have questions about pygame can I post em here or do I have to post them in game development... Thanks for all who replied!
np :D, I have a lot of time to spare.
I have a problem to get unique values from dateperiod-loop.
There is a tons of examples how to do it, but after hours of searching, i couldn't find suitable ...
Good man James helped me learn die roll board game programming in Java,
and I applied it on Ladders and Snakes. Made one in Java. Now I'm learning to do ...
Hello everyone hope you are doing well, i was busy these days i was having problem with the police in my country, they catch me smoking weed and now i ...