Tuesday, April 14, 2009

Playing Around With ActionScript 3

Recently inspired by a series of tutorials in AS Gamer, I spent about 3 days to put together my first flash game in action script 3. Here's the end result:



The game is quite short, but it is a complete game. It's my first time to code something in action script 3, so there were many problems that I encountered. I like to put down some notes here to serve as a future reference for myself:
  • Frame-based animation vs Time-based animation: In Flash, there are primarily two types of animation: first is the frame-based, which has a smoother result when run on different frame rates. However, its playback speed will vary depends on the frame rate. Second is the time-based animation, which has constant playback speed regardless the frame rate, but sometime it causes loss of frames if the machine cannot run on the specified frame rate.

    Usually, time-based animation will be preferred due to its unified performance. However, I couldn't fine-tune my game objects to have desired movement in a time-based manner while keeping the keyboard controlling mechanics. After some tests and trails, I decided to switch the controlling mechanics to mouse only. Also, I used the frame rate as denominator for the movement speed in a frame-based manner for the game objects. This solution worked out rather nicely. The animations look similar with either 24 fps or 60 fps. It's certainly not perfect, but hey, it works! :)

  • Central game engine: There is a Main class that serves as the entry point for the program and it is intended to act like a game engine as well. However, I didn't end up utilizing this class enough, and later when I tried to add in intro screen, game over screen, and a pause feature, it turned out to be a mess because I had to sparkle code all over different places. Then I decided to cut the pause feature because it will require a lot of changes in the other codes. I realize the same-old "big game loop" will work better than the different initialization code that I added in the constructor.

    Also, the flash library become quite crowdy when I kept adding in different movie clips. A better resource management could be implemented with the engine as well. Next time I'll try to plan ahead of what my engine should do.

  • Class inheritance: I was surprised to find out at the end that most of my game objects, which are usually movie clip subclasses, have many properties and methods to share in common. It would be nice to have a parent class or interface for all these objects. It would make the code more neat and clean.

  • Music, arts, and dedication: A lot of time was spent on making my ship look nicer or finding the appropriate sound effect for firing bullet. Then I just again realize that I'm not an artist or musician in any shape or form. I should have network more with some artists/musicians in the GDC 09. :P

    Then it's the final note: if one wants to become a game developer, making game on his/her own time is necessary. Not only it looks nicer on the portfolio or resume, but also it shows one's dedication for gaming. It doesn't really matter the quality of the game, what really matters is the lessons learned from making the game.

Tuesday, August 5, 2008

From Google Pages To Google Sites

I have made an online professional portfolio earlier using the Google pages creator. However, according to Google, they are no longer accepting new sign-ups for Page Creator because they have shifted their focus to developing Google Sites. More importantly, my portfolio site seems to be down for a long time now.

I tried the Google sites thing, but it doesn't seem like a good choice for a personal site, such as a portfolio. It's more like a wiki pages creator. Just as they said it on the homepage: simple, secure group websites. The design and functionality of it are more oriented for groups. The targeted users are more like a hobby club, a company website, or a team project site, etc.

I will probably still make a portfolio using the Google sites, since I really want to have a working one to meet my very-soon job hunting needs. But I guess I am more eager to have my professional portfolio somewhere else. Currently I'm aiming for the Google App Engine. I was thinking about to put up a Flex site on the GAE, but didn't get it working still. Plus, the Flex application size is greatly confined by the GAE size limit, which is not good. Now I'm trying to make it all python by using the Django framework, but I gotta learn this new framework from ground-up, and it's not like I know python very well either. Well, the programmers have to learn new thing almost every day, I think it doesn't hurt too much to have one or two more. :D

UPDATE: ok never mind, it's simply that I couldn't access the googlepages service in China. My portfolio is still sitting there (I'm back to the U.S.). You can view it from here.

Wednesday, July 2, 2008

Old Blog Name Already Taken

I change my old blog name and URL just about 3 days ago, and today I found out they are already taken by other people. I am a little surprised at how fast this is happening. The old blog name is "Fei's Engineering Blog" and the URL was "fei-engineering-blog.blogspot.com". I thought they were odd enough such that no one would really use them, but obviously I am proven wrong. From the post of the new blog owner, it seems like he/she is not a pure English speaker because the language looks like Spanish to me. o_O

Anyways, good luck to the new blogger, and as a reminder to my friends and any other potential reader, my blog's URL is currently "jianfeiliao.blogspot.com". The name of the blog at this moment is "A newbie's level up journal", thought it might be changed later on.

UPDATE: Obviously the new blog under that old name is banned due to rules violations. Too bad I cannot use that URL again. -_-

Monday, June 30, 2008

Handle Chinese in Python while using Pydev and Pygame

I never really try to program anything that has to deal with the Chinese before, even though I'm a 100% Chinese. However, I recently came accross a problem of renaming some of my files, which have Chinese in them. I decided to write a little script to do the task in order to practice my Python skill. Very soon I encountered the unicode problem. After some searching and hacking, I was able to solve the problem. To avoid forgetting the solution, I put down this sample program as my note for future reference.

To display the string correctly in the eclipse console, set the encoding to UTF-8 under "Run Dialog => Common". Also in the project properties, set the "Text file encoding" to UTF-8.

# -*- coding: UTF-8 -*-

import sys
import pygame
from pygame.locals import QUIT

pygame
.init()

# This string contains both simplified Chinese and traditional Chinese.
unicode_string
= u'Hello Unicode String!简体!繁體!'
# Test the string in Eclipse console.
print unicode_string

# Must use a font that is capable of displaying Chinese.
string_font
= pygame.font.SysFont('simsun&nsimsun', 16, True, False);
string_surface
= string_font.render(unicode_string, True, (0, 255, 0))

# Display the string to the pygame screen.
screen
= pygame.display.set_mode((300, 40), 0, 32)

while True:
# Missing this event handle loop will cause the pygame window freezes somehow.
for event in pygame.event.get():
if event.type == QUIT:
exit()

screen
.fill((0, 0, 0))
screen
.blit(string_surface, (10, 10))
pygame
.display.update()


Sunday, June 29, 2008

Ready . . . Get Set . . . Go!

It's been a while after my last post. I was trying to keep up the posting as the summer starts, but didn't expect the blogger was blocked by the GFW of China. -_- Fortunately it's finally unlocked now, and I can access my blog again.

It seems like the Blogger has upgraded the system and added a bunch of cool new features. Therefore I figured I might as well give a new look to my blog, and I even changed the title and URL of the blog.

Since I don't really start looking for jobs until August, I have quite a long summer to spend. I think it will be helpful for me to learn something and probably do a project during this time. Currently I'm learning the Flex 3 and python, even thought they don't really go together. Also, an old article about making a game in a week came across me accidentally, and it really inspired me. I think I will try to do something similar in this summer.

After all, 1/3 of the summer has been gone, and I think I am getting ready. It's time to run.