Wednesday, July 28, 2010

Going Going Going Gaming

Well, I am still working on a Ninjas game tutorial from over at Flixel.org. There are some components of Flixel that are not currently working on Flixel Android, namely FlxTilemap. I spent a few days trying to work out all of the errors in the lines of code before deciding my brain already hurt and needed a rest, so I started working on modifying a random tile painter which works; however, I am still having issues translating the block collision detection, which caused my brain to hurt even more. I mean it looks simple enough:
[code]
for each (var existingBlock:FlxBlock in levelBlocks)
{
collisionWithExistingBlocks = existingBlock.overlaps(newRandomBlock);

if (collisionWithExistingBlocks) break;
}
++loopCount;
}
while (collisionWithExistingBlocks && loopCount < MAXIMUM_RANDOM_PLACEMENT_ATTEMPTS);

this.levelBlocks.add(this.add(newRandomBlock)); }
[/code]


Yeah so much for a simple translation, since the android / java sdk does not like the FOR EACH statement, so I tried a few variations of this theme, but to no avail


[code]
for(int i = 0; i < this.map.lastIndexOf(newRandomBlock); ++i)
//for(int i = this.map.indexOf(existingBlock); i < this.map.lastIndexOf(existingBlock); i++)
{
FlxBlock existingBlock = (FlxBlock) map.get(i);
collisionWithExistingBlocks = existingBlock.overlaps(newRandomBlock);
if (collisionWithExistingBlocks) break;
}

++loopCount;
}
while (collisionWithExistingBlocks && loopCount < MAXIMUM_RANDOM_PLACEMENT_ATTEMPTS);

this.map.add(this.add(newRandomBlock));
}
[/code]


So, I am waiting for that eureka! moment to happen in which suddenly the fog of why its not working correctly hits me and I say BUT of course, while I research Java For Loops. Unfortunately I cant use a =< method because thats a boolean not an int and the commented statement did not work either. So I am thinking the block arrays never collide since it never actual maps to the last block. I also tried FlxG.collideArrayLists(newRandomBlock, existingBlock) however, I can not set a break because that is not part of a loop it would seem, which will not let me compile. Maybe I will try it anyway and see if it implies a break inside of FlxG core. Do not know; however, I did add the enemies and working on fixing up the spark.png since a 1x1 pixel causes Android to do crazy things.

Also been playing around on the Storm8 games (ALL of them to be exact). I like the format of the development and the text of the game. Its a like a mini game I can play for 5 minutes an hour and then not touch it for 4 hours and then come back and be pleasantly surprised. Just a word of advice, not always having a HUGE hoard is not a bad thing. Your companions need to grow with your equipment lest you be unable to defeat other players. My Ninja horde is 50 strong and I only have enough equipment for 10, OUCH. However, in the Rock Band game, I have a band of 4 and enough equipment for all 4 members to dominate everyone. So equipment / abilities have to grow with the number of players in your horde or you can not defeat other players.

Sunday, July 25, 2010

APK File Downloads


Okay so I decided to link the Demo APK files. For the really observant, the source code is also available in its entirety by following the code.

First up is Matthew Casperson's Demo on making games with Android Flixel. Lots of hard work from Matthew porting Flixel to the Android platform, including a really easy to follow tutorial. Got to say that it probably is the most quote tutorial if you Google Search - Android Flixel. **Play Tips** your DPAD moves you left and right, DPAD up for Jump and Space Bar for Shoot. Flixel Default P pauses. One day I will learn the modifications for the pause screen, but hey its my first Demo - EVER on Android. Okay, I did do the standard Hello World, Android, but that doesn't count. BTW, PRESS AND HOLD LEFT after hitting the Center Button on the DPAD, You'll see what I mean if you download the APK.

The first block of QR code is the link for his demo as is, no changes, just me learning how to program in Java / Android / Flixel all at the same time.

This second block of QR code is the link for his demo, plus some changes that I wanted to see. For example, there is no easy way to leave his Demo, nor is there any way to adjust the volume while playing the game, since the special functions keys to get at a 1, etc. So I changed up the programing by making the volume keys go up and down respectively, and I added a mute button by pressing the camera key. I also made the Menu key kill the player and return to the Menu Screen, the Back key also returns the user back to the Menu and if already at the Menu stops the demo to conserve battery life.

**Comment about Killing the game vs. leaving it in the background** I have read where on the Android platform there is no need to kill process once your done using them, they just regulate themselves to the background and can be continued (restarted) later. With so many other game applications, they have taken this approach to end cycle gaming. Flixel will pause the game when running in the background, so if a call comes in you can take the call, then return to the paused game and un-pause it. I like this approach to games that are in cycle or actively being played; however, I have noticed that sometimes when un-paused Flixel does not completely restore all functions, i.e. sometimes it stops getting KeyEvents or the sound does not play. So I have decided to allow the user to stop the game when done to free up those resources, simply because it feels more correct to me.


Lastly, we have a Defender-esque Demo by Andres Zecher from Creative Applications dot Net. Now this one was a little bit tougher since it was a Demo written for Flixel 2.x and I am using a v1.25 port for Flixel. Also it was written entirely in ActionScript 3, which is not the same way Android Flixel games are built; however, there were enough commonalities that the game was ported over with a couple of days worth of work. A few of the porting changes were input methods, I dumped the particle emitter in favor of using Sprite sheets, reused from Flixel Mode. And I still am not able to get Flixel to change the background color, and changing the color in the XML file leaves a screen you can't see anything on. I also changed the scoring system to be 10 base rather than 1 base. I also included my basic button configuration and Menu navigation from the First Flixel Game.

I want to extend a heartfelt thanks to both Matthew and Andres, not only for writing games, providing the source code and graphics, but for also taking the time to write up tutorials to help beginners like myself get started.

Flixel Defender / Flixel Tutorials

I finished two Flixel tutorials today. One is a Defender-esque demo shooter. It includes a simple enemy that floats at you which you have to kill. I need to read up on creating a high score record for between games, thus far my record is 1030.

The other tutorial is a semi-platform style game by Matthew Casperson, whom is resposible for porting Flixel to Android. Currently it is a simple platform with 4 enemies to kill. It is this work that got me excited to start building Android Flixel games. However, it also humbled me some as well, since it was my first run with Java coding and took me a little while to get my development enviroment up and running.

So I am contemplating placing the apk file links for download for those interested in playing around with the Demos. Just not sure since none of the work is mine, other than the porting to Android.

Published with Blogger-droid v1.4.8

Saturday, July 24, 2010

Welcome to my Android Development Blog

welcome to my blog about Android application development. So far I have setup my development IDE with the Android SDK. I am also using Flixel as me primary 2D gaming engine.

I am also suprised at the lack of what I consider core games on the Android Market. Games like Asteroids, Defender, PacMan, Centipede, and 1942 classics.

Published with Blogger-droid v1.4.8