Monday 3 October 2011

Learn The Trigonometry Functions

Sunday 2 October 2011

Beyond the Game

I've recently watched Beyond the Game, a documentary about the competitive Warcraft III: Reign of Chaos scene in Asia.
It's very interesting, especially the fact that they compete at a high level and train like professional chess players.

But the difference is that chess is an open game system, the "algorithms" & mechanics of the game are exposed and played in a physical space.
But Warcraft runs in a total virtual plane were the game mechanics are somewhat hidden, I know, as a player, that there's a certain randomization on almost every damage hit but I don't see it being run, I only see the result exposed by the visual feedback layer.

A dice roll in a video game compared to one done with a real dice and thrown by an human hand will always have a certain degree of suspicious development because we don't see the actual process but only the result.

That's why I find it very fascinating that some will want to develop mastery of a video game when at the end, complete understanding of the system & control over it can be subtly manipulated by the makers of the system, especially in the context a lot of competitive gaming do not actually freeze to a specific build of the game but do take into account the developer's patches.

Simple Solution: Reading Twitter Feeds

I was working on a way to feed Twitter messages into an indie game prototype last March. Basically, certain events and unlocks could be triggered by specific commands embedded in subtle Twitter messages.

I was slamming my head against Twitter API and JSON, when it clicked, I could simply read the generated RSS feed and parse out what I need.

In other words, I find that most of the time, it's easier to bypass the official API of the service provider and always check for simple alternatives.

Links:
iPhone SDK: First Steps With JSON Data Using the Twitter API
With Just 3 Lines Of Code Add Twitter/Facebook Into Your iOS App

Use self()

I’m building a database abstract layer in PHP using a Singleton pattern, I based my code the following article.


In the comments, I found that you can self-instantiate a class with “self” instead of calling it by name, very useful if you plan to change the class name over time.


Must re-write code if you change the class name:


self::$m_pInstance = new Database();

No worries with self():


self::$m_pInstance = new self();

PHP & Enums

Enums are not native to PHP, at least not for the moment but I found a way to simulate with the help of this post on stackoverflow.

<?php

class DiceEnum
{
        const d4 = 4;
        const d6 = 6;
        const d8 = 8;
        const d10 = 10;
        const d12 = 12;
        const d20 = 20;
}
?>

But if I base myself on the SPL documentation, it’s seems we are going to have a supported native integration very soon.

Syntax :: the use of ?

I had a PHP exam this morning for a job interview, which I feel I probably failed, my main problem is that I had doubts on how PHP5 handles object references, I’ve been programming in C++ and objetive-C recently and my mind is stretch out with all the different IDEs, scoping, syntax and specifications of each language.


This causing me to go from one mindset to the other and in a written exam, were you don’t have access to documentation when in doubt or a debugger to feel out the language, it gets very difficult.


And so I’m reviewing the PHP5 documentation in hopes it will help me perform better at my next job interview.


While reading up, I found this very interesting proof of concept, the thing I like the most about it it’s the use of the syntax:


($bar === $this ? “Yes\n” : “No\n”)


Never used it or at least not everyday and it’s actually was a question on the exam.


At least when I fail, it’s always epic!



<?php

class Bar
{
public $prop = 42;
}

class Foo
{
public $prop = 17;
function boom()
{
$bar = &$this;
echo "\$bar is an alias of \$this, a Foo.\n";
echo '$this is a ', get_class($this), '; $bar is a ', get_class($bar), "\n";

echo "Are they the same object? ", ($bar === $this ? "Yes\n" : "No\n");
echo "Are they equal? ", ($bar === $this ? "Yes\n" : "No\n");
echo '$this says its prop value is ';
echo $this->prop;
echo ' and $bar says it is ';
echo $bar->prop;
echo "\n";

echo "\n";

$bar = new Bar;
echo "\$bar has been made into a new Bar.\n";
echo '$this is a ', get_class($this), '; $bar is a ', get_class($bar), "\n";

echo "Are they the same object? ", ($bar === $this ? "Yes\n" : "No\n");
echo "Are they equal? ", ($bar === $this ? "Yes\n" : "No\n");
echo '$this says its prop value is ';
echo $this->prop;
echo ' and $bar says it is ';
echo $bar->prop;
echo "\n";

}
}

$t = new Foo;
$t->boom();
?>

Toy Drummer

I’m currently working on an open source project which could be of interest to the chiptune scene, it’s basically an XNA application which makes it simple to connect a Rock Band/Guitar Hero drum kit your PC or xBox and assign custom sound samples to each pad.


The idea came about when I wanted to add a drum kit to my own nerdcore/chiptune performance setup but couldn’t afford it so when I saw my old Rock Band kit standing in the corner of my living room coated with dust , I decided as well use it for something, especially now that music video game market is dead, all that hardware is going obsolete and unused, a little bit like 2600s and C64s after the 80′s game market crash.


I tried to use Andrew Rudson’s Drum Machine (http://andrewrudson.com) tool but it wasn’t exactly what I needed, so I decided to make my own tool and open source it.


As I’m writing this, the code is at version 0.2.1, it’s still very dirty but it’s functional at a basic level.


I’ll be adding some VJing features in the coming weeks, customizable retro games, video loops and glitches/video effects which call all be mixed live and triggered by hitting the pads.


You can check it out here (http://toydrummer.codeplex.com), please feel free to contribute or send feedback, it’s always appreciated ^-^

Metrics in social games…

I’ve been reading some articles on the use of metrics in social gaming, like this short one from Gamasutra.


This is something I’m going to add to my online game framework I’m currently developing. The project’s name is P.O.G.E. (Persistent Online Game Engine).


It’s basically a framework build in PHP and Lua which I’m going to use to construct a new online game which will use different aspects of social gaming, MMO & augmented reality.


I said to myself, I’m spending all this time building tools why not share them with indie game community and so I’m going to release my framework under an open source license.


For the metric & stats aspect, it would be interesting to integrate it to the game engine, it’s data that could be used to modify the behavior of the game or add more dynamics between the “game master” or game A.I. and the players.

Watching GIFs on OSX

One thing I really love are GIFs but OSX and iPhoto don’t play them natively so I build the following Applescript to generate a local web page which lists and displays all my GIFs that are located in a specific folder.


You can download the .scpt here.



set gifFolderName to "gif:"
set gifDisplayPage to "GIFDisplayPage.html"

tell application "Finder"
set currentFolder to container of (path to me) as string
set gifFolderPath to (currentFolder &amp; gifFolderName)
set fileList to every file of folder gifFolderPath
-- display dialog currentFolder
end tell

set gifPage to (currentFolder &amp; gifDisplayPage)
set htmlStart to "Watch your GIFs" as string
set htmlEnd to "" as string

try
open for access file gifPage with write permission
write htmlStart to file gifPage as string
repeat with currentFile in fileList
set currentFileName to (name of currentFile)
write ("<img src="gif/&quot; &amp; currentFileName &amp; &quot;" alt="" />") to file gifPage as string
end repeat
write htmlEnd to file gifPage as string
close access file gifPage
on error errorMessage
log errorMessage
try
close access file gifPage
end try
end try

tell application "Finder"
open file gifPage
end tell

Game Layer a.k.a. Gamification

Last Thursday, I attended a PHP QC conference were the co-founder of Empire Avenue gave a very interesting talk.


One thing which mentioned that really got me interested is how he integrated a ‘game layer’ to his application.


The concept of ‘game layering’ is very fascinating and very related to the gamification concept.


How to make a “flat” app more dynamic by using game mechanics is something I’m going to focus on with my next projects.

Steering Behaviors for Text Animation

I’ve been reading this very fascinating white paper called ‘Steering Behaviors For Autonomous Characters‘.


Great resource for anyone working on pathfinding or NPC scripting.


But I’m thinking of using those very advance algos for simple text animation.
By example for animating title screens by giving each letter a group behavior and a path.

Hello World!

Hello World!