Object oriented design
July 23rd, 2008 by spenderHere’s the slides from the talk we gave to FlashBrighton last night.
Here’s the slides from the talk we gave to FlashBrighton last night.
Objects? Encapsulation, data-abstraction, the importance of interface, dynamic/late binding and modular programming. That what we talking about, not just stuff lying around your house. And 101, what’s that? A room? A quantity of dalmations? The emergency telephone number in Belgium? Well, yes, all those things and more but what we mean by it is “learning at the 101 (i.e., introductory) level“.
We’re lucky in Brighton to have waaay loads of a-list geeks around. Even without the usual headline stars though there are plenty of other super-smart-cookies to to call upon for help, none with more knowledge and authority than FlashBrighton and FlexibleFactory’s own doyens of Object Orientation Tom Kennett and Chris Sperry.
That’s right kids, comedy cartoon celebs and ubergeeks extraordinaire Tom and Sperry are orienting the object by the horns at FlashBrighton next week. As well as hunting for cheese, getting hit by brooms and being squashed flat against the stairs by the refridgerator they’ll also be looking at reducing complexity in code and how design patterns can aid that goal. They’ll look into the most prevalent design pattern in AS3, event driven programming, and how the use of events can reduce the dependencies and complexity of code.
Just like you [probly] over at Flexible Factory Tom and Sperry write a lot of code but are forgetful and lazy too, and they know how Object Oriented Design can help them stay like this but still create large, complex systems without getting in a tangle.
So don’t be like Tom and have Miss Mammy Two Shoes after you with the broom for being a loser. Be like Sperry instead: avoid the mousetraps in your code and make off with the cheese by REGISTERING ON UPCOMING FOR THE OBJECTS 101 MASTERCLASS.
Got it all working now :~)
I was rolling back all the collidable objects to the first collision time everytime, when I only needed to do that if there were multiple collisions.
so now, if there is only one collision per step, only the colliding objects are rooled back. If there are multiple collisions they are all rolled back.
Example
There are two random movement bots that reverse if they hit something, and one base bot that just sits there. For every frame, a unit of energy is taken from each bot, at every collision, 5. The base bot still has the advantage I think, but it is not always the winner.
I just want to comment everything, as there have been a few architectural changes, then I will commit my changes.
OK, so I’ve got the sweep test working to Seb’s suggested method.
for those not at the project night at the beginning of the month (June), here is a brief explanation:
It works very well, except… at the moment the bots will keep going in the same direction even if something is obstructing it, this means two things:
Thing 1
I think because of the way the x and y data is rounded to the pixel, the bots are only stopped dead at a collision point, if the time of the collision is 0 (ie no velocity is applied), otherwise the bots will push through the wall (or each other) as if it is made of jelly.
I have fixed this by backward predicting whether there was a collision in the previous frame, and returning t as 0 (though this also fails occasionally).
// if collition in the next frame, // return time of collision if (t && t>0 && t<1) { return t; } // if collision occured in the last // frame, return 0 else if (t && t>-1 && t<0) { return 0; } // else, no collision occurs // that we are interested in else { return -1; }
Thing 2
When there is a collision, because the colliding bots continue in the same direction (ie through each other or the arena), all the bots are rolled back to the same position, so there is effectively no movement until the colliding bot changes direction.
so, where to go from here?
I also seem to have broken the scoreboard.. oops
Box2D is an open source 2D physics engine for games. It’s an open source 2D physics engine. For games. That’s all that Box2D have to say about themselves so lets try to fill in the blanks a bit ourselves shall we?
Box2D is great! It’s an open source 2D physics engine that you can build games, simulations and loads more with. It’s fast, robust, scalable and written in C++!
Uh, you wot?
That’s right kids: originally a C++ project some of the Internet’s intrepid denizens have put in some long hours and ported it to AS3 just for you! Isn’t that nice? Before you sing ‘Hallelujah’, crack open the champers and build a ‘Donkey Kong’ emulator with it though, a word in your shell-like: it’s a straight port which means that - whisper it now ‘lest we offend someone - Box2D AS3 looks like C++ and C++ sure does look like some bad-@ss low-level geekery. Oh no, whatever shall we do?
I’ll tell you what: get Box2D superuser and all-round hard workin’ FlashBrightonian Owen Bennett to explain it to us, that’s what. Owen’s had his hand in the Box2D for a while now and next Tuesday he’s gonna show us how to get from the murky base classes of Box2D to something light, fluffy and usable with the focus, as Owen himself puts it, “squarely on how to integrate the engine into your own projects“. It’ll be proper hands-on: one hour of lectured theory will be followed up with one hour of workshopped practice, where we’ll be having phab physicsy phun straight away!
Dr. Owen says: Get in trim for the sesh’ by checking out some Box2D examples here and downloading the source code here.
PS: The raffle was concluded at last weeks Carnival O Fun which means A WHOLE NEW RAFFLE HAS NOW BEGUN! So why don’t you get on the next get-shedloads-of-raffle-tickets bus by registering on Upcoming NOW for Owen’s session.
We have reached the end of phase 1. More details on phase 1 can be found on the wiki http://code.google.com/p/as3bots/wiki/PhaseArchive.
Tasks completed for phase 1:
What’s new:
Details of phase 2 can be found at the Google Code page http://code.google.com/p/as3bots.
Summer is here and the Carnival is on! Your Carnival King n’ Queen Rich Mitch-O-Son and Sarah Bird-O-Paradise welcome you to the FlashBrighton and BANG Carnival O’ Fun, one of the catchiest titles you’ll hear all year. With real nice up animated shorts and bad bwai fun time films it’s def going to be a night to remember!
King Rich will be reigning over his usual selection of anim-and-YouTube-funnies whilst Queen Sarah has a real treat in store with a special guest appearance from Brighton-based animation scriptwriter and producer, Bob Swain. He’ll be talking about the successful animations and TV series he has created, including Zombie Hotel (voted best animated series at the Annecy Animation Festival) and giving us a sneak peak of his latest film The Blue Man.
So come one, come all, as the Carnival King & Queen - and Bob - turn Brighton into Rio for one night only!
Tuesday 8th July, 7pm (screening starting just after 7:30pm) at the Lighthouse Digital Lounge, 1, Zone B, 28 Kensington Street, BN1 4AJ.
Sign up on EventWax now!
We’re looking at our members projects again next Tuesday. We don’t have all the details to hand but you can expect to hear about:
So, we don’t know exactly what state these projects in but half the fun is in the mystery anyway, so get thee over to Upcoming now and register to find out.
In the almost unbelievable case that there is ANYONE out there who doesn’t know what a Flojo is, it’s:
A coding team in rotation, five minutes in the ActionScript hotseat for each coder, then the next person takes over. A collective goal to aim for; in our case, FINISHING THE SAME BL**DY PONG GAME WE’VE BEEN CODING FOR WHAT MUST BE YEARS BY NOW! That’s right everyone, put some time in on “Mavis Beacon Teaches Typing” over the next few days cos next Tuesday we’re really gonna go for it and try put this pongy puppy TO BED! The aim is to finish the game!
Now, the more anally-aware of you might be thinking:
“but wait a cotton-picking moment, the helpful and informative FlashBrighton calendar says the 24th of June is reserved for the latest ‘Flash Film Carnival ‘O Fun’ with our own ringmaster of enormous fun Rich ‘Gwan-an-ting’ Mitchelson… doesn’t it?”
Well… yes, ‘least ways it did until recently. We wouldn’t be about to deny that “you right ’bout that” for ’tis true, but we’ve put that particular amazing amalgam of animated antics back a few weeks so we can get the right venue and make it not just plain awesome but TRULY STELLAR. Watch this space for details…
In the meanwhile: heads up y’all, lets get ship-shape and Bristol fashion cos we’ve got a hot Florence-Griffith-Joyner enroute and a game of Pong to finish. YOUR PONGY NEEDS YOU! Get your coding fingers at the ready. Hell, why don’t you get some typing practice in by going over to Upcoming and reserving your hotseat at the table RIGHT NOW?