Archive

Archive for the ‘Game Programing’ Category

Test Code in game script

November 28, 2009 Leave a comment

Your C/C++ code is asynchronous code, so it’s difficult to use a unit test framework. Game objects (actors) consist of some assets that are loaded async, receive message from asynchronous message system and have many behaviours that you should check with your eyes.

Where should you write test code for game objects? One of solutions is that you write test code in game script. It’s possible to wait the timing that asynchronous process completes, because game script can do yield/resume in the game main loop.

For example, to test whether a game object is able to equip a certain weapon, you may write the following setUp function in script.

  function setUp() {
    mObj = Entity.Load("soldier");
    mArm = Entity.Load("sword");

    while (!mObj.hasLoaded()) yield();
    while (!mArm.hasLoaded()) yield();
  }

After setUp(), you can write test code and tearDown().

  function testEquipSword() {
    TS_ASSERT(mObj.equip(mArm));
  }

  function tearDown() {
    mObj.unload();
  }

Maybe, for core system engineers, this is a kind of integration test. However, for an engineer writing game specific code, this is really unit test. Writing test suite and test case in script detects issues as well as standard test unit written in C/C++.

 

When you write test case in script, you need good assertion. Most script language don’t provide macro feature, but assert() function is there, so you may use assert right now. In many cases, assert() is implemented as a builtin function in default librariy. If assert() is not enough for your test, you can change source code of assert().

Many game specific languages aren’t rich than generl script languages — Python, Ruby, Perl and PHP. Perhaps you write table instead of class. But, implementation of xUnit family in those languages is good reference for us. I used example from “PythonUnit” and wrote simple unit test framework.

- Add TestCase instances to TestSuite.
- Call TestCase.runTest() after TestCase.setUp().
- Call TestCase.tearDown() after test is failed.
- textXXX() methods are called automatically, so you don’t need to implement runTest() in most case.

Assert function that is provided in default may be unenough to stop test when a test in test cases is failed. So you use example from the assert() function, write custom assert() function and bind it as new assert() builtin function.

Categories: Game Programing Tags: ,

Book: REAL-TIME CAMERAS

November 24, 2009 Leave a comment

REAL-TIME CAMERAS is “a guide for game designers and developers”. This book lists many useful articles — basic knowledge, technical terms, camera motion, camera collision, script co-operation, camera path, interpolation and math.

I imported this book from U.S. via Amazon Japan.

The book says “this is a guide for also game designers”, but I feel that this book is basically for programers because most articles require technical knowledge. Or, can game designers in North Amerika and Europe read this book? Perhaps most game designers in Japan (we call “planner”) can not this book, but this book has worth that they should read.

Camera systems are often developed for each title by each project. The reason why each project writes camera code is that the camera spec of each project is not generic. Generic camera code is very difficult. UBI tried a generic camera system, but that wasn’t success enough.

However, there is another reason that we don’t understand frequent specs and frequent discussions. Have you taken hit-and-miss-approach for camera system requirements? Don’t you understand what camera system is? I could learn many things from this book. And I knew that my knowledge about camera is not enough. So I recommend this book.

By reading this book, game designers and programers can share knowledge, prevent wasted discussions and avoid hit-and-miss-approach.

Categories: Game Programing Tags:

Video game development productivity

November 18, 2009 Leave a comment

Video game developers develop games for users who play games. If we release games to get saraly, we are no longer video game developers.

I’m interested in video game development productivity, because improving productivity is very interesting activity for programers. The activity simplify development and make pipiline clear.

Is this activity for our budget? No, I think that this activity is for game users. Improved productivity enables that game designers develop games by iterative method. This improves game quality.

We, Japanese developers can learn various methods/technologies and many things from North America/Europe developers.

- “Scrum” development.
- Establish the job called game desiger.
- Tool-driven development.
- Build up a game engine that integrates components.
- Improve content pipeline and asset pipeline.

My favorite activity of various activities to improve productivity is asset pipeline design. That’s really interesting. Now, I work on asset load pipeline.

Great pipeline bring in great productivity. Perhaps, general asset pipeline consists of convert, load and hot-swap. We have to provide short loading time and great graphics to users. And programers have to provide hot-swap feature to game designers and artists.

So writing code to improve asset pipeline is very interesting. That is one of reasons that I work on improved productivity. Programers have to dissolve fat pipeline, and re-design it. It requires expert skill to programers, so programers have to check many existing pipeline system. There is worth that we work on. After we improve pipeline, game designers, artists and users become happy.

Categories: Game Programing

Abstraction by Include/Link Switch

March 1, 2009 Leave a comment


The virtual function is often used as one of solutions to accept the same source code to different environment. This way makes surface of source code beautiful, but it is not good performance because virtual functions are heavy process. Programers who work on real time application think that’s beautiful way but feel that isn’t ideal performance.

Because compilers generate indirect-jump with a function pointer table from virtual function, CPU’s branch prediction feature is not useful for a such situation. It surely triggers pipeline-stole. If a perfect JIT will be completed in the future, the perfect JIT will be useful for this situation. But, there is not a such JIT now.

Virtual functions are very good approach. But we hope to fix as many as possible of the function address. If there are some functions that we don’t need to handle as abstract functions at runtime, address of those functions should be fixed to let CPU use direct-jump. Let’s say you have to develop the middleware that can be used for both of PS3 and Xbox360. Firstly, you may plan to use virtual functions to abstract different between two platforms. But, imagine use of game software. Users never able to change platform while they are playing the game.

In other words, developers decide which libraries to link when compiling. The middleware you’re developing makes it possible that developer compile each application for multi-platform from the same source code, so you may supply the plural include files and libraries for each platform. Developers will write each makefile. Because this approach doesn’t use virtual functions, most function address will be fixed. And, some of them will be compiled as inline-functions.

A such approach is one of standard approaches of multi-platform programming. We take the approach for the following purpose.

- Writes inline-assembly code on multi-platform that has different CPU.
- Changes JIT of game script for multi-platform that has different CPU.
- Solves the different compilers and different compiler versions.
- Changes link libraries to their debug edition or others.

Maybe the approach is also useful for script programming. We often focus on the “runtime-compile” feature of the script program environment. But, the environment has also the “runtime-link” feature.

Let’s say you have to write functions that remove platform difference between PHP4 and PHP5. The platform condition is not changed at runtime. Therefore, when program tries to include a file declaring the functions, you may prepare two files for each platform. That’s like the approach of C/C++. C/C++ can change include-path and link-library by platform conditions. And, that’s better performance than the approach that each function checks platform and changes execution.

That’s one of standard approaches if our language is C/C++. However, the script programming world has the different common sense from C/C++. Therefore developers who work on PHP may not agree the approach that change include-file by platform condition.

Categories: Game Programing, XOOPS Cube Tags:

Little Big Planet gives many hints to XOOPS Cube

October 29, 2008 3 comments

Little Big Planet will be on sale tommorow in also Japan. This game will give many hints to XOOPS Cube project. If you have PS3 and XC users, it’s useful to research this game for you.

An ideal software design (2)

May 14, 2008 Leave a comment

In large scale systems/applications, a specification is prepared before. Basically it is trusty. So a software architect can design program for program and programers. But, large scale systems/applications orient rather program, not programers. Because such systems/applications are used for a long time. So these systems/applications should be flexible to respond a little change and have extendability. To implement these features, a software architect designs software on program ground, not programer ground. It devides software in rational modules.

That’s very excellent. But, does it hold good in all cases?

Large scale systems/applications are just a kind of software. All of projects is not large scale. And, there are period, goal, scale, software life-time, runtime style (realtime or not?) and specialized programers. An ideal software design is optimal solution for those factors that is written during design period.

If someone see the design from another situation, he may feel that the design is not good.

Some architects quest for beautiful design. They think that is justice. But software design is not art that an architect dedicates his life. And software design is not game that an architect has fun. However, it’s sure that there are not good guidances with the exception of large scale systems/applications. Some architects feel cool from those guidances and try to apply it to their project…

Tight situations may detach your design from an ideal software design that you think. On the other hand, tight situations sometimes bring you to optimal solution.

Categories: Game Programing

An ideal software design (1)

May 12, 2008 Leave a comment

Normally, we try to decide software design before a team begin writing program. That may be simple block wiring diagram or UML. Many programmers gather to your team for rapid development. The thing that you must do is software design. For that, you divide software in modules. That is a good design for program.

But your mission is that each programmer becomes able to bear part of programming. Can your design realize it?

A logical design for program and a logical design for programers have difference. If you design software and write its program yourself, you perhaps don’t notice this truth.

An ideal design that have many modules for program often blocks specialized programers. That makes it impossible to start productive development.

There are many specialized factors of program — makefile, memory management, resource management, peripheral, hardware control, content-pipeline, parallel processing, shader, effects, particle, animations, graphics, audio, cinema sound, AI, physics, geometry, procedural technology, script, network, debug system,third-party middleware and so on.

Can you design software by combining these specialized factors systematically? Perhaps, you can do it. But, an ideal software design that you’ve designed for program is bad news for programers who gather to a project. A game system requests a composite of their knowledges and their code from thebeginning. So a project becomes tangled.

Categories: Game Programing

Is an Object-Oriented Game Engine necessary? (1)

What is the validity of the class-hierarchy that makes GameObject class and specialize those for downward classes? In this case that each object passes a message to each other, the only task of the object list is telling a signal. Specialization like down-cast is done within each object. Nor there may be more strange code to do specialization.

(snip)

A rule of game (game-design) defines the situation that each object send a message to each other, from the top-view. Loosely-coupled like plug-in is not good solution for game. It requires a perfect description. If a new kind of game objects is added to code, all existing game object classes have to define response to the new class. In this jigsaw puzzle, a kind of piece has to define “joints” to all of other piece.

[The validity of managing Game Object without generalization - Worklog]

I understand his struggle, because I have ever tried to handle game-engine and graphics systematically with researching middle-ware, engine and scene-graph for several years now. But, in my project at my office, I can not live up to it. A video game programing that is real-time application requests performance always and many programers are assigned to a project, so a systematic architecture that makes a sacrifice of both performance and the early stage of projects is not useful.

High-level languages like C++ tempt us to change our programing style. Amazon and book stores display books that teach how to write object-oriented programming. We read these books and begin to plan to handle game object classes with object-oriented programming. It’s sure that there are enough discussions about object-oriented architecture of large scale systems design. But, there are not enough discussions for video game application design, especially in Japan.

In America and Europe, developers discuss game object design. But, most of them develops FPS and RTS. These genres are a good match to object-oriented design. But all of games is not FPS and RTS. So many Japanese developers don’t discuss game object class design. In other genre, it’s necessary that a game core controls game totally. And, the most important thing of video game development is tuning and tweaking. In our world, an ideal architecture collects entertainment control panels to one place for easy to tune and tweak. Video game developers have to put entertainment feeling before the fixed spec documentation.

If we write source code with books that teach large scale system design, the game application feed programers’ vanity. But the application is bad as video game program. Our ideal program design might be different from the large scale system. And, a video game object-oriented design might be different from a large scale system object-oriented design. So the books don’t teach all thing to us. We have to find an answer ourselves. Japanese, American and European don’t find the answer, yet.

Categories: Game Programing

PowerPC Personal Computer

March 21, 2008 Leave a comment

All major game consoles take PowerPC class. There are many special technics to write high-performance code on PowerPC. In holidays, we were able to try it with ApplePC, but that’s old story. Because ApplePC changed from PowerPC to Intel, there are not reasonable PCs to practice in PowerPC programing at home now. How can I try PowerPC and multi-core programing in home?

There are old mac mini, latest iMac and PLAYSTATION3 in my home.

My old mac-mini is not multi core, but that’s valuable for me, because the mac-mini is small, light and good to enjoy PowerPC programing.

The current my PC, iMac is dual core and good to practice in multi-core programing. However, intel core duo is not taken by major game consoles. Therefore, I can practice in pure multi-core programing, but that’s not useful directly for my job.

PLAYSTATION3 may be useful. It’s possible to install Linux and practice in heterogeneous muliti-core programing. Of course, heavy linux environment is inconvenient to program, than PS3 SDK, but there is no chose, because standard PCs don’t have heterogeneous multi-core. Fortunately, we can get all of tool-chain of PS3 except specialized libraries like SPURS.

PowerPC multi-core PCs like Power Mac G5 are valuable very much in retrospect.

Working hours are not enough to research multi-core programing. I should have researched more in R&D status. Now, our team had completed R&D and began developing a product. That’s good. But, I want time for more trial and error. My PCs are valuable a little for that.

Many expert developers got ways in multi-core parallel processing in games. I don’t arrive at such stages, yet.

Is little endian or big endian?

January 24, 2008 1 comment

I saw interesting code to check endian.

bool isLittle(){ unsigned int val = 1; return *((unsigned char *)&val);}

If a machine is little-endian, ‘val’ is reversed and stored to a memory. That may be implementation-dependent way. But I think that it isn’t problem for specific products, if the library having the check code supports specific type of applications.

Of course, if this value is not cached, we should use const.

Categories: Game Programing Tags:
Follow

Get every new post delivered to your Inbox.

Join 54 other followers