Tuesday 10 February 2009

Day ? - Where am I at?

Well it been over 14 days and still no arcade game. How do I feel about this? It's more good than bad. I guess the bad part is that I haven't accomplished what I set out to do. The good part is that I've got a good understanding of the basics, and I think realistically it might take two to four weeks to pull some kind of game off. I'll post the code when I figure it out. Admittedly I haven't geeked out and stayed in a darkened room coding for the last 2 weeks. I've chilled out and done other stuff.

This what I've learnt:

1) There are alot more resources out there on learning AS 3.0 then there used to be when I first had a look around for books etc a couple of years ago. This is can only improve - even i have managed to write this blog and used open source tools to capture my screen and embed video.

2) To build even basic applications requires a very good understanding of AS 3.0

3) Workflow is important. By this I mean the approach you take in building your projects and knowledge in AS 3.0. OOP Projects require more that 1 file and this can get complicated when trying to revise code so achieves goals more efficiently. At the moment I'm using version control to keep succesful experiments.

4) Looking at step 3 means that the challenge to learn AS 3.0 would be very difficult for complete beginners to coding.

5) Get Moock's EAS 3.0, but get Learning AS 3.0 to jump right in too.

6) FlashDevelop isn't too tricky to get working and seems to do the job well (once you the trace working - i think this is easy and was just me being stupid) Couldn't get code indent to work that would have been nice.

7) Although AS 3.0 isn't something you can be expertise in in a week or two. I'm guessing that you could probably get some competence in the order of months (ok I know that remains to be seen). Contrasting this to learning a foreign language which is probably more approaching the order of years, for me, means it worth pursuing.

Sunday 1 February 2009

Day 12 - keyboard event outside the main class

I need how to deal with keyboard events. This isn't too difficult, but I found it tricky to do this outside the main class. Anyway got onto the forums and got an answer off Nutrox, (see the post with a description of the problem in detail and has the code too).

Not sure if this is the right way of doing it, but ultimately I wanted the logic for controlling for the spaceship is a ship class not in the main class, so thats just some background to the problem.

Thursday 29 January 2009

Day 11 - hitTestObject

I'm getting more confident writing basic functionality in classes. Got caught out by a few scope issues.

Got hitTestObject working quiet nicely. As you can see in the video when the blue square hits the red square the blue square stops. The method is called from the main class

blueClip.hitStuff(redClip);

Got better ways of doing this? Or want more explanation please comment.



This is the code for the main class

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;

public class Main extends flash.display.Sprite{
private var blueClip:Rec;
private var redClip:Rec;
private var greenClip:Rec;
public function Main() {
blueClip= new Rec(300,50,0x66CCFF);
addChild(blueClip);
blueClip.go( -1);
redClip = new Rec(20, 50, 0xDC143C);
addChild(redClip);
redClip.go(1);
greenClip = new Rec(70, 50, 0x669900);
addChild(greenClip);
greenClip.go(1);
blueClip.hitStuff(redClip);
}
}
}


This is the code for the Rec class that draws the rectangles

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.utils.Timer;

public class Rec extends Sprite {
//private var movetimer:TimerEvent;
private var moveTimer:Timer=new Timer(10,0);
public function Rec(xPos:Number,yPos:Number,shapeColour:uint) {
graphics.beginFill( shapeColour , 0.5 );
graphics.drawRect( xPos , yPos , 20,20 );
graphics.endFill( );

}
public function go(speed:Number):void {
moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
moveTimer.start();

function onTimer(e:TimerEvent):void{
x += speed;
e.updateAfterEvent();
}
}
public function hitStuff(clip:Rec):void {

addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame():void{
if (hitTestObject(clip)) {
moveTimer.stop();
trace("collision with " + clip.name);
}

}
}
}
}

Day 10 - Practiced some code

Just familiarised myself with rewriting a few classes

Tuesday 27 January 2009

Day 9 - Signed up for Safari Books Online

I finished Moock's Tamagotchi tutorial, and it's well worth it. Still hungry for more tutorials so I signed up for Safari Books Online the cheapest offer is $11.50 for 5 books on the shelf for a month.

Day 8 - Passing arguments and tutorials

Although it would have been nice to get my head round Passing Arguments with Events I admit it was a bit of a stretch. I did manage to use the code and implement my own version, but was a bit uneasy about spending too much time trying this particular technique considering I'm only on Day 8, and still gaining familiarity with basic syntax and concepts. To close Day 8 I ended up midway through one of the mighty Moock's tutorials that creates a Tamagotchi

Monday 26 January 2009