Friday, June 22, 2007

Vivid random colors

If you want more control over how to create random colors, you need to steer away from the RGB space and go into the more human-friendly HSB color space, which is Hue/Saturation/Brightness.

Unfortunately flash doesn't natively support this but you can convert between the color spaces using some help functions like the following which were found here:

function hsv2rgb(hue, sat, val) {
var red, grn, blu, i, f, p, q, t;
hue%=360;
if(val==0) {return({r:0, g:0, v:0});}
sat/=100;
val/=100;
hue/=60;
i = Math.floor(hue);
f = hue-i;
p = val*(1-sat);
q = val*(1-(sat*f));
t = val*(1-(sat*(1-f)));
if (i==0) {red=val; grn=t; blu=p;}
else if (i==1) {red=q; grn=val; blu=p;}
else if (i==2) {red=p; grn=val; blu=t;}
else if (i==3) {red=p; grn=q; blu=val;}
else if (i==4) {red=t; grn=p; blu=val;}
else if (i==5) {red=val; grn=p; blu=q;}
red = Math.floor(red*255);
grn = Math.floor(grn*255);
blu = Math.floor(blu*255);
return ({r:red, g:grn, b:blu});
}
//
function rgb2hsv(red, grn, blu) {
var x, val, f, i, hue, sat, val;
red/=255;
grn/=255;
blu/=255;
x = Math.min(Math.min(red, grn), blu);
val = Math.max(Math.max(red, grn), blu);
if (x==val){
return({h:undefined, s:0, v:val*100});
}
f = (red == x) ? grn-blu : ((grn == x) ? blu-red : red-grn);
i = (red == x) ? 3 : ((grn == x) ? 5 : 1);
hue = Math.floor((i-f/(val-x))*60)%360;
sat = Math.floor(((val-x)/val)*100);
val = Math.floor(val*100);
return({h:hue, s:sat, v:val});
}
So to create vivid random colors you just randomize the Hue, and set a high Saturation and Brightness. If you just want random shades of a color, you set the Hue and Saturation and just randomize the Brightness.

Tuesday, June 19, 2007

Random seed not settable in Flash Pseudo-Random Number Generator

I'm still polishing up the puzzle game I'm working on. I was in a debugging session and I wanted to set the random seed for the PRNG. And surprise!!! There is no method to set up the random seed for Math.random().

However I came across this which provides a class for a PRNG. Pretty useful ;)

Tuesday, June 12, 2007

Dynamic text problem

I wanted to markup some text in a dynamic text field using the .htmltext property . But the bold characters were not showing. I found the answer to the problem here.

I just needed to create an off-stage dynamic text whose only purpose is to embed the bold font. If I wanted italic as well, i would have to do another dynamic text which embeds the italic font.

Now if only flash warned me that there are missing font definitions, argh!

Array instantiation for actionscript classes

If you want to avoid some nightmares, don't instantiate the arrays in the variable definition inside a class.
i.e. DON'T do the following

class myClass {

var my_array:Array = new Array()

function myClass()
{
}

....
}


Coz this would end up with a behaviour similar to having the my_array defined as static. What I think that it is happening, is that it won't re-initialise the variables when you instantiate a class but will just give you a reference to the array. Thus each instance you create will have a reference to the same array. How dumb!

So the solution is ofcourse to move the array instantiation in the constructor, like so:

class myClass {

var my_array:Array;

function myClass()
{
my_array = new Array();
}

....
}

Monday, June 11, 2007

Dictionary service and getTextExtent

I'm still working on the word puzzle game so far.
I got this idea this morning, that when you manage to connect a word it would access an online dictionary service and give you a definition. Basically I was testing the game and I was forming words that I didn't ever hear before. So you can actually learn something by playing this game :)

I found this free dictionary service
http://services.aonaware.com/DictService/
I'm currently using it to request word definitions and then place them in a speech bubble.

I also worked on scrolling the speech bubble text if the definition didn't fit. I used the TextFormat.getTextExtent() method, even though it is errouneously marked as deprecated for Flash8.

Friday, June 8, 2007

Word list in Flash word game

I'm working on a word puzzle game for a client and I had the challenge to find if a word was created on a game board and had to access 28,000 words (taken from a word list found at http://wordlist.sourceforge.net/ which are used for spell checking, word games, etc)
Originally there were over 80,000 words but I trimmed off the long words which cannot be created on the board.

To overcome the slow speed of flash accessing a huge array, I split up the word list in 26 arrays (one for each letter). This was not enough. You could tell that the CPU was doing something since the animation stop until he checks the board. So I re-split each array into another 26 arrays. Flash doesn't have red-black trees (or is there??) so I had to improvise ;) This was the simplest and now you won't notice it is checking the board for 28,000 words :D.

Wednesday, June 6, 2007

Not much progress this week

Not much progress on the prototype this week. I'm currently busy doing a flash puzzle game for a client and also getting updated on all the changes (and problems/bugs) with AS3.

Monday, June 4, 2007

Player disconnections

It was a busy day, but I found some time for the flash game prototype ;). Started coding some support for player disconnections. The idea is that when a player disconnects, the other players will know that the other player was disconnected (by showing an icon in the HUD near the avatar which got disconnected). And then the player with the same username only can reconnect to the game session. We will also notify the player that he has a game pending and he can reconnect (without going to the lobby).

For now anyone can reconnect ;)
But we will get to the above semantics.

Debugging Flash Player 9 with a logfile

There has been some changes in Flash Player 9...
mainly that you cannot change where the log file will be saved.
You will find the flashlog.txt in C:\Documents and Settings\user_name\Application Data\Macromedia\Flash Player\Logs

You need the debug player/activex/plugin from here.

For more details on setting the necessary mm.cfg check out the docs.

Saturday, June 2, 2007

Trolls and ActionScript3

I have started coding the trolls which currently are very simple objects that just move horizontally. Nothing really intelligent.

I have also started learning a bit about AS3 (about time huh?). There are some new concepts which I'm reading about. It seems like they have taken a good direction into scrapping a lot of stupid stuff that was in AS1/2 like movie depth assigning ... they have have gone for a display list approach. I will comment more once I will start using it. They have changed so much that you have to read a bit about migrating the code to AS3. So I think it will be time well spent ;). Especially because of the optimizations they have done. FINALLY we have int and uint! (instead of just Number class), i.e. optimizations can be done by the compiler. Also no more removeMovieClip... you just set the reference to null, and a movie will be garbage collected.

Wednesday, May 30, 2007

Change of focus, bigger screen size, reached end marker, and dying

So the most important thing I've coded today is the change of focus. This is used a lot to give some visual cues to the player. For example when he throws an arrow, the focus is now on the arrow (until the player decides to moves or the arrow strikes something). It is also used when he activates some lift and we want to show him what he activated. It will later be used when he clicks on the minimap and when we want to show the players the waypoints.

Another important thing is the concept of dying. Well the player doesn't really die. We just reset him to the start position. The player dies when he falls at a certains speed, or (when we have health and damage implemented) when health reaches 0.

I've also increased the screen size to 640 x 480.
And I've made a "very good" sign to appear on the avatars' icon that reach the exit point.
Also I've added the ping that is automatically sent every 10seconds and displayed under the respective avatar. Give's an indication of how much the latency is ;)

Tuesday, May 29, 2007

Mantis bug tracker installed

I needed a central place where to put the number of features being proposed and also the number of bugs that crop up ;). So I've installed Mantis... it's open source and free plus easy to use and installs within a couple of minutes.

I will later give access to anyone who takes part in the development ;)

Fixed some bugs and new help screen


Today I didn't do much as regards to new features. However, I've fixed the following bugs:
- arrow falling from help sign (this was actually funny)
- character not having right characteristics (was using a static variable pfff)
- tile glitch fixing (was moving the tiles with floating point and so some seams where appearing)
- initial speed of projectiles
- no aim for the runner (doesn't need it)
- some minor code cleanup

I've also tried out Sven's idea for zooming out. Ofcourse it was very crude... I just modified _xscale and _yscale of the _root movie, but still got an idea if it would be useful. Let's say that i need to feel it in a bigger level before I take out the guts of the level class to cater properly for this feature. The effect looks pretty cool though ;)

I also created a new help screen. Hopefully it gives a better idea of what keys are to be used and the characteristisc of each player.

Coming up next is the notion of having a focus point for the level. So I can follow an arrow, another player, or show the players where they need to go before they start playing.

Monday, May 28, 2007

ActionScript3, Proxy Servers and Binary Sockets

I tried to show the prototype to a friend of mine, but he cannot do a direct connections. In fact he uses a proxy server for browsing too.

I made a quick search and apparently there are some hints that ActionScript3 supports the CONNECT method which basically uses HTTP to tunnel a connection. Although I'm not really sure how to do this.

Another interesting thing I've learnt is that now in AS3 there are Binary Sockets... (rather than using XMLSocket)

I've also found this blog entry (which is almost 1yr old) of this guy who seems to work @ adobe who has done some class that uses the CONNECT method. Will look into it sometime later on.

If anyone has ever used these or would like to dig deeper on how we can use it for the prototype, leave a comment or send me an email ;)

Exit pointer

I've just implemented an exit indicator which is shown when the exit area is not on screen. It renders itself near the edges of the screen and it also displays the distance the player is from the exit area. Nothing special but gives some bearings to the players ;)

Attachmovie and Graphic type

Be ware when you're using attachMovie(). Make sure that the type of the object you want to attach is actually a Movie type and not a Graphic. Else you will be manipulating _level0 without knowing!

Game sessions,minimap and in-game chat

I have finally updated the server code so proper game sessions are held. Basically when you're playing you don't receive lobby related commands, and when u're in the game you will only broadcast game related messages to your level players only.

Also I have implemented the minimap. It will show the other players' positions with small colored pins. Your pin will be white. For now it is not clickable. However in the future I will make it clickable so the view will jump to where you clicked.

I've also placed the avatars' faces at the top. And whenever someone chats, a speech bubble is displayed under the avatar which talked. Cool :D

Sucky flash comboboxes

I wanted to use combo boxes (aka dropdowns) for when editing a help sign to make it easier to show what the user is selecting (rather than entering 1 for the shooter actor).

The first problem I encountered was the depth of the rendered list when you click on the arrow to the discover the list. It doesn't use the depth of the combobox itself. It somehow uses it own shitty depth which would render behind the tiles in the level. (So that is why I'm pushing them to the side of the help sign so that the lists are visible at least).
Update: this problem has been temporarily solved by swapping the depths of the related tile when entering edit mode, so that it is not hidden under some other tile.

Secondly if I set the selectedindex while i'm loading the level (using a class file and not in a frame coz in a frame it works fine), the selectedindex is set alright, HOWEVER the combobox is not rendered right... it is just blank. WTF!!! So I had to save the selected index value in a temp variable, and when we switch to the editor mode, I set the selectedindex to the temp variable value.

If anyone has some idea why this happens and any solution for this... leave a comment or email me. Don't have time to waste on such stupid things...
on to the next thing...

Saturday, May 26, 2007

HUD mockup

I just made a HUD (heads-up display) mockup. Comments from the artists please ;)

It's shows a chat msg in action.
The minimap area is reserved as well.
The player icon will be marked with some overlay icon when he reaches the exit area.
There will be the names of the players underneath the respective player icon (not shown in mockup).

Sven's zoom in/out idea

Hey Nev,

Have you thought about the possibility of a zoom? This game almost cries out to be able to zoom in and out smoothly according to what u do, like smooth out when you run/walk, and zoom in when u interact with things.

Sven
I love this idea... especially for the runner. Since he is much faster, the player needs to view more in order to control the player better. I will keep this in mind for later. But definitely a very good idea.

Help sign


Today i've done the help sign which will be used in the tutorial levels to give hints of what needs to be done.
Basically each help sign has three parts of information:
  1. Actor... who should be doing what
  2. Action... what needs to be done
  3. Where... an arrow points to where the action needs to be done.
I still need to enhance the language that can be described by the signs, but the main idea is there ;)

Friday, May 25, 2007

Not much work today...but some ideas

Today I was busy to finish up some work not related with this prototype :(
The only thing I did for the prototype is to edit a bit the level so it can be played more effectively somehow (i.e. you cannot fall in any abyss :) ... unless you encounter a bug)

But I got some ideas for a better user experience.
  1. Help items. I've noticed that when I show the game to my friends they are like "ok what do I do now?" So I thought of help signs near the level objectives that explain using icons what needs to be done, e.g. icon of exploder, grenade and down-arrow showing where it needs to be placed. When the player moves the avatar near the help sign, a text blob together with bigger icons will be displayed and also what key needs to be pressed.
  2. Improved in-game chat. Somewhere on the screen there will be overlayed the faces of the characters being controlled. When someone types something in the chat field, a text bubble is shown near the face of whoever talked and will fade out after a while. This will save some space hopefully for not having a chat window always being displayed. Ofcourse there will be a history button to see what was said if you missed some speed while doing some action.
  3. Objectives shown at start of level. When the level is loaded, the level is panned smoothly over each objective and in the order in which they need to be done. And finally it will pan to the exit area and after a while it will pan back to the start of the level. This should give a good idea of what needs to be done in this level. Ofcourse this should be done only for the initial levels. As the game will progress, the players will need to discover by themselves what needs to be done.

Thursday, May 24, 2007

Lobby system partially done


Today I worked mostly on the lobby system.
So far 3 users can select with what character they want to play and when the 3 slots are filled, the game is launched.
However for now there is no distinction between the game sessions on the server side when the players are actually playing. I will be doing this hopefully tomorrow before I release the updated prototype.

I've got some bugs in the editor which I want to iron out as well.
Looking forward to show you what I've done this week ;)

Wednesday, May 23, 2007

Started coding the lobby

I've started coding the lobby, but before that I started cleaning up a bit the UI for the login and do some checks server side (like checking if the username is already taken).

So the lobby will basically be a list of what i call game sessions. Each game session will group together 3 players to play in a level. The user will click on the preferred character type he wishes to play with. When the 3 slots of a game session have been taken, the players will be launched into the level.

So far I've only worked a bit on the UI and put on paper the logic and server protocol. Tomorrow it will be implementation day :)

Different characters, arrows, grenades and parachuting

I've just introduced the different character abalities. Each player will choose the player he wants to play with, but for now for debugging purposes I can just switch between them by pressing 1,2 and 3. :)

Runner
He jumps high enough to reach a 2 block high platform
He has a bit more acceleration and more speed
No projectiles

Shooter
He has a medium jump
Medium acceleration and speed
Fires arrows

Explosives guy
He practically doesn't have a jump, but when he's falling he has a parachute so he can reach places where others would die if they try to.
He's a bit slow
Fires grenades

I've improved a bit the graphics for the grenade (including a timer) and also the graphics for the arrow. I've also pasted the static concept art we have for the avatars. They look cool even if they aren't animated yet ;)

I'm going to start working on the lobby system. Need to think a bit before starting coding.

Tuesday, May 22, 2007

Targets and some code tweaks

Today I've put in place targets which when hit with an arrow will operate a tile (like a gate or lift).

I've also tweaked a bit the level class so that I can distinguish easier between tiles that are collidable, targetable, destructable, static, etc

I will be working on different character classes next ;)
Can't wait to get these done, so I can start working on the lobby system which will be a bit of a headache but fun and educational (unless I encounter some other flash bug or undocumented feature)

Monday, May 21, 2007

What's next

Got some feedback from some of you... (i fixed that ladder bug Sven ;) ).
Any feedback is always welcome...

So what's next?
Here are some features that I will be implementing next
- Targets that can be shot with arrows (And which trigger some action, like opening a gate)
- 3 Different character types (one which handles explosives, the runner/jumper, the projectile guy)
- Bigger tutorial level with help blobs
- Smooth movement multiplayer code (to eliminate as much as possible the glitches due to latency)
- Lobby system (where people can match up and play a level together)
- Some minor fixes to the scrolling (need to add the concept of overlays, i.e. not just 1 layer of tiles)

Thursday, May 17, 2007

Prototype testing

Ok,
So before you visit the link here is what the prototype is about.
- It shows a working scrolling platform level
- Editor mode (but please don't save anything for now ;) )
- Very rough multiplayer server without any smoothing, so you will see some jerking for now.
- Chat client (duuh)

The aim of the mini-level is for the players to reach the exit point (it's just a graphic though... no game-complete check for now). The players right now all have the same abilities, plus just for testing purposes you can keep on jumping as if you're flying... so you can browse through the level at your own pleasure hehe.
To reach the lifts switches, you need to destroy the cracked tiles in the beginning of the level. Switch the weapon to grenades (LSHIFT), and then aim with A and Z and hold and release space. To activate switches press (LCTRL).

Run the prototype...
(If it tells you connection failed, it's probably coz my PC restarted ;) )

Coming up:
- Smooth multiplayer movements
- Mouse scrolling to see the level
- Mini-map
- Different character capabilities.
- Match making

Feather/Hay Particle system

I'm working on a simple game for someone, and I needed to create a particle system for hay / feathers... you know you fall on a stack of hay and puffffffffffffff <atchoooo hayfever hehe>.The particles gravity decreases as time goes by, until they reach a certain speed when falling, and then they start swaying... like feathers do. Pretty cool ;)

Needless to say, I can reuse this code in some other game :D

Also yesterday I tested the prototype with Sven and Alex and there were some glitches but it looks promising. Today I will be working on the prototype so I will send all of you the link for testing as promised.

Wednesday, May 16, 2007

Almost there...

I'm almost there to send you a link to a playable prototype.
I've got lifts activation working over the server and also changing of weapons.

So now I just need to fix some minor bugs and implement the exit point, and then we can meet online to discuss the game when you see it in action :D.

I hope MS kills Flash

Ah man flash is so fucked up.
I have a users list component... and this component doesn't have a removeItem()... but only removeItemAt(index). So I decided to link an array using the dataProvider property. So when I added an item to the array, the list is automatically updated. Then i used splice() to remove items from the array AND SURPRISE SURPRISE, the list component is not updated.
I call this CFUASS - "classical fucked up actionscript shit"... yeah i'm pissed off coz i wasted 30min on something stupid as updating a boring list.

Tuesday, May 15, 2007

Tidying up code

I decided to tidy up a bit the code (but not too much for now :) )...
Basically I moved the server code into a class which extends Flash XMLSocket class and moved the player code into a class which extends MovieClip.

This is the first step so that if someone would want to help in the coding part, he can just use the ActionScript files and I would up them on a CVS server ;)

Tonight I will try to continue on completing the server protocol so all the game language is there (activating lifts, ladder climbin, destruction of tiles etc)

Monday, May 14, 2007

CPU busted... no work today :(

My hard-working Athlon XP 2100+ CPU decided to die on me. Was gonna upgrade to a dual-core but Alex saved me lots of bucks coz i'm now using his retired Sempron. Don't need much CPU power especially since if I'd get more CPU power, that means I can play more games, which in turn means less work :)

No update on the prototype today, however I heard about Microsoft's Flash-killer... Silverlight. Still a long way to kill Flash but it may have potential.

Also I found these tiles at Lost Garden which I will try to temporarily use later on for the prototype.

Saturday, May 12, 2007

Server code update started

I've started working on the update for the java server code.
So far I only added jumping and projectiles support.
Will need to support lifts (activating, hooking), destructable grounds and ladders.

At the end of next week I should be able to send you a link to test it out together. So the week will be a race to elimanate bugs and polish some usability stuff ;)

Thursday, May 10, 2007

Created first level... almost

I didn't work a lot on the prototype today coz of some other work.
So tonight i just wanted to create a dummy level which would use the different stuff i had in mind and when everything is up and running it would be playable cooperatively too.

As I was using the editor I spotted some bugs and fixed them and also started inserting some usability tweaks to make it less frustrating to use :).
One thing that I must implement is selecting of multiple tiles and moving them around.
Another important thing is a mini-map (even for during the game, and not just while editing).

Bugs i need to fix:
- falling at high speeds can miss a collision with a tile
- big with climbing down a ladder that touches the ground (continues to go through the ground :) )

Wednesday, May 9, 2007

Aiming and some bug fixes


I've implemented aiming and strength.
The player can now aim where to throw projectiles (arrows and grenades) by pressing A and Z, and when he's ready to shoot he presses the spacebar to start charging the throw and on release, the projectile will be fired according to the strength given.

I've also done some minor bug fixes, minute details like I forgot to move the projectiles in the scene if I panned the level, destructed tiles where been selected wrongly (was destructing the undestructables ones hehe).

I've also started working on some graphics for the tiles coz I got bored looking at spheres, rectangles and triangles :). I stuck in an avatar from maple story MMO (not animated ofcourse for now). Yesterday night I tried firing up MAX to start working on a chibi character until Ganni makes a cool character, but damn it I forgot everything in MAX argh. I'm happy using the current avatar for the time being rather than waste hours to do something really ugly in 3d :)

Above is the first screenshot with pre-alpha graphics, everything is temporary.
Below is the game in level editor mode.


You can barely see the cross hatches to highlight the corners of the tiles. To the right you have the currently available tiles and you simply select the tile you want to place and just click where you want it to be.

Coming up next is a semi-decent playable level, then I will re-visit a bit the server code and then I can post the link here for you to see the prototype in action.

Tuesday, May 8, 2007

Ladders, projectiles and destructable tiles (with grenades)

It was a very productive day today...
I've implemented ladders, and projectiles (arrows and grenades), together with destructable ground (i.e. tiles).
Started to subclass the MovieClip class for the projectiles. Should make the code much more maintainable. I'll probably port the avatar code to use the same technique rather than code placed in frames blehhhh.

Will start coding the controls for firing a grenade/arrow :D

Level scrolling, edit mode, collision detection, lifts

It's been a while from my last post. I was busy perfecting the scrolling and going round the stupid bugs found in actionscript (besides other things like meetings with companies). I really got frustrated when i found missing important documentation to be found in some forum or when the native methods don't behave as they should.

Anyways, now I have level scrolling in place and also moved the editor inside the game, so the user can switch to edit mode while playing and add/change tiles on the fly and see how the level will feel. Pretty cool :D

The avatar is currently only a sphere graphically :$ but you can move him around and jump around. Collision detection with tiles have been put in place. I've also created a lift which is activated by a switch.

Coming up are ladders, projectiles and destructable tiles (with grenades)

Wednesday, April 4, 2007

Started level scrolling

Today I continued on the level editor and I have introduced dragging of the scene using the middle mouse button. Similar in concept when you want to pan around in 3dsmax.

I have extracted the level code into an actionscript class and started using it in the game fla. So now we have level loading too :). I've started working on the scrolling of the level when the player moves the avatar. It's giving me some headaches to make the scrolling work pixel based rather than tile based. I will look into it tomorrow.

Tuesday, April 3, 2007

game development blog started

So I've decided to start taking some notes on a new project I'm trying to get together. The project is another game, this time a multiplayer cooperative platform game.

The game will be played in flash and the server will be java-based.

So far we got a very basic chat client working, and players can connect and control a ball for now and can just go left to right. But the data is broadcast to the connected players. Currently we are simply broadcasting the keystrokes and where the ball stops. Any discrepancies are interpolated smoothly at the client side, so we avoid jerking as much as possible.

Also I've started working on the level editor, so I can easily create levels to test on. This is also flash based and will be as user friendly as possible for other users to use it when the prototype is decent enough. The filesaving is done via the server too so this should make it easier for users to share their content later on.

I will try posting some screenshots tomorrow so a record is kept of the progress of the visuals as well :)