Golden Lunch Bucket Contest #4: Extending the Warrior

goldenbucket If you’ve put off entering one of the Golden Lunch Bucket Contests, you’ll not want to miss this one. This one is as easy as pie. In a recent post, Wrong Way Warrior Part II, the Warrior class was modified to get its weapon behaviors from another interface named Fire. The Warrior class did nothing more than extend the Sprite class and set up a reference to the Fire interface. However, you will notice that two other behaviors were implied in the commented-out references to Movement and Communicate as shown below:

?View Code ACTIONSCRIPT
1
2
3
4
5
6
       public class Warrior extends Sprite
	{
		protected var fire:Fire;
		//protected var movement:Movement;
		//protected var comm:Communicate;
	}

For this contest, all you have to do is to create the necessary interfaces and classes only for Movement (we’re saving the Communicate until later) so that the Warrior instances will retain their current weapons behavior but include the Movement behavior as well. The movement algorithms must come from a separate interface and concrete movement implementations (just like Fire did).

You can use the “warrior” movie clips used in the original or make your own. (I cut the size of the movie clip graphics in half so that they’d have more room for movement.) Here are the rules:

The Rules

  1. You must build on the existing Fire and Warrior design in Part II of the Wrong Way Warrior
  2. All entries must use ActionScript 3.0
  3. Either Flash or Flex formats are acceptable
  4. All output must be visible on the screen.
  5. You can have any kind of user interface for movement that you want.
  6. All entries must be in by September 20, 2009
  7. All entries must be placed in a ZIP file. (Nothing fancy for my Mac)
  8. Send entries to wdsanders@comcast.net with the subject line Golden Lunch Bucket Contest #4
  9. Include your name, age, where you’re from, and a 100 x 100 jpeg/png photo

Remember, all of the points for this contest go toward the Golden Lunch Bucket World Cup.

  • Share/Bookmark

Related posts:

  1. The Mediator at Work: Golden Lunch Bucket Contest #3!
  2. Hello World! : The Second Golden Lunch Bucket Contest!
  3. US Moves to Second Place in Golden Lunch Bucket World Cup—Contest #5 Announced!

8 Responses to “Golden Lunch Bucket Contest #4: Extending the Warrior”


  • Hi William.

    Wouldn`t it be more convinient to build upon an open source alternative (FlashDevelop?) instead of using the flash IDE? I do not have CS4 and I cannot open your warrior.fla.

    Additionally you are using fl.controls.Button which are not available outside of the IDE, are they?

    Greetings,
    Mark

  • Hi Mark,

    Once again, it’s “Bill”–but no worries. I am assuming that those who use FlashDevelop can create alternative sprites using code. The .as files have all of code required outside of the Library use of the buttons and movie clips.

    So just go ahead of develop alternative UIs and sprites, and you’re good to go.

    Kindest regards,
    Bill

  • just a proposal for coming Lunch Bucket Contest. The way it works now, everyone needs Flash or needs to edit every Warrior Class according the used sprites. The other way round even Flash users can compile the files without altering anything.

    But I agree with you, your files can be altered to be useful… I can add an swc with the button class in it to my library…

  • Mark,

    I’m a lousy artist; so don’t think anything you create will be worse than mine! In the future, I’ll try to make the contest equally easy for both Flash and Flex (FlashDevelop).

    Take care,
    Bill

  • Short question about dependencies: When I have a class that has a field “fire” typed to the interface Fire and within that class I instanciate a concrete class RocketFire which implements Fire, then that class is dependened to RocketFire, isn’t it? It needs to import RocketFire… it would only be entirely independened if I would set RocketFire by a setter method which awaits something which implements Fire. Right?

  • @ Mark: Yeah, if you hard-code RocketFire then the functioning of your class will depend on RocketFire. If you instead go with the “setter way” that you have already mentioned then your structure will be much looser. You’ll only need to pass in an object that implements Fire in order for your class to work correctly ( let it be RocketFire or whatever else ).

    Cheers,
    Barni

  • Hi Bill,

    I just emailed you my entry to this contest — hope my OOP noob status isn’t sticking out too much. I think I followed all the contest rules, but not sure I followed all the best OOP rules. Thanks for making the contest.

    Barbara

  • Hi Barbara,

    Thanks for the entry! We welcome one an all regardless of background or experience. Entering the contests is a way of getting to know design patterns better and having some fun.

    By the way–only 4 more days for entries!

    Kindest regards,
    Bill

Leave a Reply