I was thinking about game design today, and I think it wouldn’t be fun to play a game you coded. I mean, you’d know everything the game “hides”, you would know every secret.
Archive for the 'game' Category
22
Jul
09
game thoughts
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.