Thursday, September 27, 2007

Double Vision

Well I have been doing some more coding. It is surprising how long it can take for such a little difference. I have split the display into two. I added two empty movieclips that are for each side of the display/stage. They are associated with a 'Screen' class, and there is once instance created for each side of the screen i.e. a left and a right. Each character and associated control gets assigned to a screen.
Coordinates systems are relative to the screen (and not the stage), so are the same for each side, which means no code changes in that regard. Although there is a lot of changes regarding assigning characters to screens, and double drawing.

In terms of control I have the 'Controller' which is the main object and in charge of everything (what happens when etc). It gets kicked off in the _root AS frame at the start.
I also have two keylistener objects (same KeyboardControl class, just two instances - one for each control (left and right). It seemed like the simplest thing to do rather than having one object handling both controls at once.

I don't know if flash is multi-threaded or not, but I am assuming not. i.e. listeners are executed sequentially one after the other, rather than in parallel. Things could get a bit messy otherwise!!!!

The room switching has broken again, but that is because the url for the door clips have changed since adding screens to the hierarchy. Will fix that tomorrow before the meeting. I'd rather not use relative urls to reference the door clips (e.g. _root.left.rooms.kitchen_lounge), but that seems to be the only way. I don't think that you can get/find an instance of a movieclip unless you know its unique id (which I do have) and it's depth (which I don't have)... unless that whole movie clip is treated as one. An example would be the SideCroller.fla file with the ball. There is a reference to a symbol 'level', and 'ground' and 'ground2' within that. How many depths would be assigned when the 'level' moviclip is added to the stage? 1 (just for 'level') or 3 (one for 'level', 'ground', and 'ground2')???

I am raving here, but it has given me some thoughts for tomorrow...

I also restructured the character symbols so they are only one layer and a single frame. We were doing some frame switching before to display character labels at the 'Choose Character' screen, but it is easier just having different movieclips rather than having different frames within a single movieclip. The later has a limitation in that timelines can't run/play backwards (I think that's right?), so it doing it this way is probably better.

At the moment the character has only one clip associated with it, so will probably need to augment the code so that there are different clips associated with different character actions.

Sunday, September 23, 2007

Progress

Tom Reville kindly talked me through his code today for the side scroller that he made.
The method he used was checking if the character co-ordinate was in a certain range (i.e. door space) and if the space bar is pressed then the character goes through to the next room.
I think that I would rather do a hit test, than doing the math as it is a bit easier, and we will have at least one or two doors in every room. Doing a hit test also means we can have doors in difference locations and in different shapes.
I have got the hit test working (grabbed some code from the sidecroller.fla file), so just need to do the programming to set up the room links and make the character switch rooms.

Friday, September 14, 2007

OOPs...

Well I haven't managed to get access to Tom's code yet (as he has password protected it), so need to email re that. Forging ahead anyway. Been creating some classes:

  • Controller - basically the game controller/logic. The master.

  • Drawer - draws stuff on the stage.

  • Room - contains generic information about each of the rooms.

  • Kitchen - a subclass of Room containing kitchen specific stuff. Want to do that for each of the rooms (polymorphism). It may be overkill at this stage. It depends on how different each of the rooms end up being in terms of behaviour.

  • Character - stuff about characters.

  • ControllableCharacter - initally this is linked to the Skanky Dred Fred (SKD) movie clip, and gets instantiated when the character is attached to the map. Has key listeners attached to it so you can move him around.

  • Door - the connecting elements between rooms (haven't got as far as coding this yet).

  • xxxxFactory - Factory classes to get instances of objects.


Having a major problem at the moment:

1/ Linking movie clips to ActionScript 2.0 classes. It doesn't seem to be working for me at the moment. I have the ControllableCharacter class linked to a movie clip 'sdf', which is the Skanky Dred Fred character.
The clip is getting created on the stage with attachMovieClip (which works fine), and the ControllerCharacter class is getting instantiated. But then I try and refer to this._x and this._y is comes up undefined. I tried a trace with 'instanceof' to check what object type this was and it came up with:

trace(this instanceof Object) => true
trace(this instanceof MovieClip) => false
trace(this instanceof ControllerCharacter) => false

It should at least be an instanceof MovieClip as my ControllableCharacter extends the MovieClip class.

Also tried casting 'this' to a MovieClip and that didn't work either!!!!
Stumped at the moment about why this is occurring.

Not sure how useful the clip-class linking will be for our purposes as when the character moves from room to room the previous room clips will get unloaded (i.e. object deletion and associated loss of data). Because I want to keep the room data when the room is unloaded, I will need to store the data in another object/class.

signing off
the-thwarted-one

Tuesday, September 11, 2007

Tuesday, September 4, 2007

Project 2 - Final

Well managed to clean up most of the tiles. It's not perfect but pretty good considering I didn't use a 3-D program to make them. Also got the key pickup to work.
It's pretty basic as it automatically unlocks the door once you pick it up, even though you are nowhere near the door, but it works. An info message might be nice.

Would of liked to of added some bots to interact with but, but that would be a whole other chapter. Also map fog, so you don't see stuff on the other sides of walls etc, when your line of sight is obstructed. That would also reduce the number of clips on the map at any one time.

Anyway here are my final files:
Flash File

Monday, September 3, 2007

Open Sesame!

Eureka! Managed to get some doors in that open and close, so v. happy about that.
Still need to do north-south facing doors. I can't do a simple _rotation = xxx on them which is a bit of a bugger as all the verticals rotate as well. We'll see if I can get that fixed by tomorrow. I think tomorrow is just going to be clean up day without any more development. A pity as I was on a roll, and was thinking about doing locked doors that you could only open with a key...that just would be too exciting!

Sunday, September 2, 2007

Two days to go

Well I spent all of Saturday trying to glamourise my level with better tiling. Ended up wasting a lot of time (basically the whole day). Didn't get it finished and the way I sliced and diced the tile to prevent overlapping was a dud. For the walls I was endeavouring to use curved shapes with gradients and it all got a little complicated. Yo can't do multi-directional gradients, and splicing gradient shapes together is cumbersome and time consuming. So scrapped that. I am cranky about that as wasted a whole day.

I did manage to change the character movement to variable speed, so it accelerates and decelerates as opposed to using a set movement distance. Also changed the movement so it is multi-directional (you can press two related movement keys at once e.g. up-left). Not totally resolved as it is a bit clunky when you hit a wall), but good enough considering it's not used much. I am much happy about that as it is in line with the original game and makes it a lot more fluid and smoother. It also introduces an element of momentum and its corresponding lack of control or delay of movement response.

I have also been having another look around the community blogs. Matt Grainger's work is most similar to my own. He is doing isometeric tiles, but the principles are the same. I am very impressed with his 3ds-max character! I'd like to do a 3ds robot but I don't think time will permit.

It's a toss up between doing some character walk cycles or making some opening and closing doors....(flip a coin?). My character is just a moving pyramid at the moment!!! 0 points for character design.

Also noticed the project brief talks about two flash files, and I only really have one development stream. I hope that won't be a problem ;-)