A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 46

Thread: Best game tools / resources / design patterns / framework

  1. #21
    Member
    Join Date
    Jan 2009
    Posts
    90
    Quote Originally Posted by TOdorus View Post
    I don't see why you would use events for your view. The way I see it, is that the view handles the view and not the individual objects in the model. I feed the view coordinates and rotations and it decides what to render and where. If you use blitting to draw to the screen that's actually a performance boost instead of a loss. It also allows me to easily create a game with sprites (as in graphics, not the Flash container), just feed the angle and position into the view and it uses the angle that it got fed to select the right picture from the spritesheet and places it on the screen (if it is onscreen) using the coordinates. I also do this for parallax scrolling and tiles. Feed the screen coordinates into the view and it calculates what tiles to display where and where the parallax background should be drawn.

    If I try to think a non MVC way to do that, the only thing I can come up with is have every object in your model have it's own view function. This is basicly the same, the difference is that the code is organised in a more decentralised way, but not that there's a performance cost.
    Maybe my understanding of MVC is different. I have, for example a ViewPort (the main screen) and ScannerView (mini map) class that handle different visual displays of the game entities, and each handles scale and offset translation. The game entities are composite objects containing position, veloctiy, etc.

    But I don't consider this to be MVC, because the entities are tightly coupled with the views-- the entities directly make calls to the view, as opposed to the view acting as an Observer. I cannot, for example, simply replace my viewport with a different viewer and turn it into, say, an ASCII text game without making changes to the entity classes.

  2. #22
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    But changing that would be really simple. Because the point of OOP is to not let other classes know about one another, and it's better to program to an interface than inheritance, then all you need to do is have a display function in your ViewPort/ScannerView that accepts a Vector/Array of display objects. Of course, depending on what it is, you might only accept Shapes or Bitmaps...

    It's always better to have a separate View class. And hey, wouldn't it be cool to plug in in either 2d or 3d Views just like that?

    @Squize: It's obviously never good to chop up code into tiny classes that don't do much, but it's always good to organize the code between several distinguishable classes.

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  3. #23
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    This is somewhat related, and I figured some of you might find it interesting (if you hadn't seen it before)

    Examples of several different design patterns in AS3:
    http://www.antropyconsulting.com/code/adobe_flex/

  4. #24
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Ha, I have the book they mention in the first sentence of their post. In fact, my brother lent it to me, and I just read it through, which has helped me with my understanding of course...good book...and good link! I recommend that xanderbeedle take a look!

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  5. #25
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    Yeah, I was thinking about getting the book.

    $40 on Amazon, so it's not cheap, but based on the reviews it's probably worth it:
    http://www.amazon.com/Design-Pattern.../dp/0201633612

  6. #26
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    It's definitely a helper!
    It explains all of them thoroughly, and you really see uses for each one, especially since they have a case study you follow along through the whole book. Before they present any of the patterns, they describe how they want to make a text editor. Then, they relate all the patterns to individual parts of the text editor, and where/how they'd use them.
    I'd say it's worth it unless you already know the design patterns quite well. Then again, the book (as they themselves say) is also meant to be more like a pattern catalog. If you need to know what to do, just flip through the book, read a few, and see which one fits best!

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  7. #27
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    Thanks a lot everyone, it's been useful to see how people handle this.
    The only thing I could suggest that would top this off would be some code examples!

    http://gist.github.com/

    Just a couple of files, showing how the functions are laid out would be amazing

    I'm going to need a huge credits section for my new game...

  8. #28
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    I'm guessing you skipped out a few posts?
    Schfifty Five posted this link:
    http://www.antropyconsulting.com/code/adobe_flex/

    Look to the right, and there'll you'll have a nice big list of examples for each design pattern! I should check 'em out myself...

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  9. #29
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    http://blog.gamingyourway.com/PermaL...01e0b123b.aspx

    There's a simple game using my framework.

    Squize.

  10. #30
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    No examples of MVC though, which is what I'm most interested in.

  11. #31
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Ah, I see.

    Well, I'll try to cook up something for you. AS2.0 or AS3.0?
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  12. #32
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    AS3, but don't bother writing something up from scratch, I was just hoping to see some code that someone had already written using the MVC pattern.

  13. #33
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    Nothing?

  14. #34
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Still don't want me to make an example? I don't think anyone has a simple enough sample of MVC to really help you out. Plus, if you're working with vector graphics, then Flash technically already has a built-in View (since you just need to call the addChild() methods on your root Sprite/MovieClip.

    Trust me, I can probably make a simple MVC thing for BitmapData's in the next week if you really need something to work with.

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  15. #35
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Isn't box2D MVC ?

    I've got to be honest, I'm one of these people who only cares if something works, rather than how, so I've never looked at the source, but as the original is written in some form of c and the as3 version is quite a literal port, and there are no visual elements to it ( Aside from debugging ) then it's quite possible.

    OOP is just a tool to do a job with, I really can't see the point in getting bogged down in semantics too much.
    Doing "pure" clean oop is something people who write books and tutorials do, game coders need to get Flash performing more than writing clever code that no one will ever see.

    Squize.

  16. #36
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    If you wouldn't mind, a clear example would be a massive help.

    These methods aren't just a theory, they exist for a reason and if you can use them well you can work a lot smarter.

  17. #37
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Flash developers usually use MVC without even knowing it. It isn't on of those academy taught, "pure" clean oop, it's simply the name of what most people just used/did.

    And box2d can't be MVC. It's simply a math library, which sorts out coordinates, etc. It doesn't have any of the MVC components! For example, the model of an application is where you do operations such as:
    a = b * c;
    or
    box2d.checkCollisions();
    Then for view...well, it's basically a class that translates functions into the visual components on screen. And control takes user input. Box2D doesn't even come close to doing any of these.

    OOP is a tool to do a job with, and with every tool, there come techniques to be used with that tool to get that tool to do the best job it can! Think of it that way.

    I will try to make something for you, xanderbeetle!

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  18. #38
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Alright.

    I tried to do as good of a job as I could in 10 minutes, but here's a small example. What it does is create a Sprite, draws some graphics into it, and then you addChild it to the View class, which is created, and then the Main class calls the view.update call, which goes through all the views children, and renders them onto itself (View extends BitmapData).

    Then, the control class is where it detects keyboard input. The Main class checks with the control class if the Up, Down, Left, or Right keys are pressed, and then moves the player Sprite, whose reaction is shown in the view!

    P.
    Attached Files Attached Files
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  19. #39
    Nelly is on the lose!
    Join Date
    Mar 2009
    Location
    somewere in USA!
    Posts
    2
    what is the best web site to make a game?

  20. #40
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    Sorry nelly, there isn't really a good site to make games. If you are serious, you want to use a programming environment such as flash, or C, or Java.

    This site has lots of good resources for flash games, otherwise google is your friend!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center