06
Mar
09

can has learn pygame ?



Lately, I’ve been reading a bit about pygame. My game development skills are inexistent, so I guess that a high level framework will provide a quick boost into game writing. I’m still reading about it, but I would like to share a bit of code I found was fun to code :



import pygame
from pygame.locals import *

pygame.init()
message 	= "Long time ago, on a blog, not that far away..."
screen  	= pygame.display.set_mode((640,480))
font    	= pygame.font.SysFont("arial",30)
text_srf	= font.render(message,True,(0,0,255))
background	= pygame.image.load("path_to_image").convert()

x = 0
y = screen.get_height()
defy = screen.get_height()

while True:
	for event in pygame.event.get():
		if event.type == QUIT:
			exit()
	if y < -30:
		y = defy
	screen.blit(background,(0,0))
	screen.blit(text_srf,(x,y))
	y -= 0.5
	pygame.display.update()

Make sure you set a valid image path as parameter to load. A picture of a galaxy, so that the effect will be nicer 🙂
I will post something more instructive as soon as I become more knowledgeable in pygame.

Advertisements

0 Responses to “can has learn pygame ?”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 223,857 hits

%d bloggers like this: