D&D Monster Stats
I am working on a little plugin to help me display monster stat blocks from D&D 4th Edition. I really need some easy method of entering the information. The structure isn't that complicated, but its tedious.
Take a peek.
FPS Display Game Component for XNA
So I have been doing more tinkering with XNA and I thought I would share this little component I have created to display FPS and timing stats in the bottom left hand corner of the window.
All that is require to use this component is to add it to your game's components.
IncrementLibrary.FpsComponent fpsComponent; fpsComponent = new IncrementLibrary.FpsComponent(this); Components.Add(fpsComponent);
Here is the actual code for the component:
Playing with XNA Now
After starting out over a year ago playing with pygame, I also tried SDL and a small library called libtcod that builds on SDL. I have finally settled on using XNA for my messing around with game programming.
The project has gone all over the place but I think I am getting to where I want to be. I am keeping the source at Google Code if you'd like to take a peek. Threshold RL is just the nickname for it right now. TestGame is where the current XNA solution is stored.
Long Time No Post
Its been a long time since I put anything up here. The job and the kid have been keeping me very busy.
Figured I would update the blog to the latest version to keep me safe from any sort of hacking issues and get updated to a more current theme. The old one was my custom work and just didn't have support for the more recent releases of WordPress.
Using PIL to Center Text on an Image
I have to put some text on a bunch of images and I wanted the text centered on the image. Digging around I found some example of using python and PIL to draw text onto those images. I'd like to share what I ended up with.
from PIL import Image, ImageDraw, ImageFont
import ImageOps
textColor = "#555555"
fontName = "tahoma.ttf"
fontSize = 13
image = Image.open("test.gif")
imageSize = image.size
image = image.convert("RGBA")
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(fontName, fontSize)
text = "Centered Text"
textSize = font.getsize(text)
centerLocation = tuple(map(lambda x , y: (x - y) / 2, imageSize, textSize))
draw.text(centerLocation, text, font = font, fill = textColor)
image = image.convert("RGB").convert("P", palette = Image.ADAPTIVE)
image.save('button.gif')
I am most happy with the way centerLocation is calculated. That came from a conversation with a friend. Thanks Chris!
Updated Pygame Skeleton
I have added to my pygame skeleton and thought that I would update the blog as well to reflect the additions.
This one imports quite a few more packages. It has a function for loading images and a class that replaces the mouse pointer with a custom image.
I have decided to place the code in a test project at Google Code so I can keep it in a convenient place.
The code is after the break.
Very Basic Pygame Skeleton
I have decided to play around with pygame a little more and ended up with this very minimal skeleton to start with. I thought I might share it with others who may just be starting out as well.
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480))
running = 1
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = 0
else:
print event
screen.fill((120, 120, 120))
pygame.display.flip()
pygame.quit()
All you get from this is a window with a gray background that will end when you close the window.
MySQL Connector/ODBC 3.51 Unattended Install
Just recently I had to create an install that called the install for the MySQL ODBC drivers. Just so others might be able to find this easier the correct command line argument is /passive. The command line for Windows machines looks like this:
mysql-connector-odbc-3.51.23-win32.msi /passive