Tower Defense Game - OOP Design

I'm making a tower defense game in Flash CS5 using ActionScript 3. Each object will have its own class. There is a class for towers, a class for creeps (enemies), and a class for the projectile coming from the towers. There can be multiple instances of towers, projectiles, and creeps at any time. How could I use the hitTestObject function to detect a collision between a projectile and a creep?

I would probably create a timer that checks all the projectiles that you have on the stage and see if they are "hitting" any of the other items on the stage. This would require you to probably creating arrays for the items on the stage. I would have an enemy, tower and projectile array that stored the movie clip when it was added to the stage. So when the timer hits the handler it would cycle through the projectile array and see if it's "hitting" any of the objects in the other two arrays? Or you could probably just do a projectile array and a collision array. The collision array could contain all objects that a projectile could collide with?
Just a thought...

Similar Messages

  • Tower Defense Action Script Problem

    Hi, I've been working my way through a tutorial to create a tower defense game. I've ran into a slight problem with a bit of code:
    package{
              imporProxy-Connection: keep-alive
              Cache-Control: max-age=0
    I get an Identifier 1078 error, I was hoping that someone might be able to tell me a little more about what this is doing, and
    if anyone knows of a solution. Any help would be greatly appreciated!
    Here is the link for the tutorial
    http://www.flashgametuts.com/tutorials/as3/how-to-create-a-tower-defense-game-in-as3-part- 2/

    Remove the 2 lines. They're not AS.
    imporProxy-Connection: keep-alive
    Cache-Control: max-age=0

  • Bad OOP design?

    I have to access some data before my program starts (to prevent a slow down while the program is running). The thing is, I need to init some objects before my program loads. It works fine now, but when I do the thing that I need the objects for, it hangs for a very short time (while it creates them, you see, right now I can only create them when the action they are needed for is called; it is to detailed to explain). The problem is it just looks unprofessional. Anyway, java.awt.component has a method that would make it possible for me to do the object creation before the program starts. Would it be bad to make a class that extends Component, and then define a method in there that get the information I need to makes it possible for me to create my object before the program starts? Is this bad OOP design?
    Thank you!
    Joshua

    Of course you can't really initialize stuff "before your program loads" since the initialization is part of your program, just before you program tells the user it's loaded.
    Probably the way to intialise stuff early is to do it in static, which will happen as soon as the class loads.
    Mostly you can do it with static object variables initialised to new objects.
    But you can get fancy and put a static code block in the class. Just a piece of code under
    static {
      .. do some initialization

  • Book Review: A Serious Guide to OOP Design Patterns

    I've just finished reviewing a new book: AdvancED ActionSpript 3.0: Design Patterns by Ben Smith, published by Apress as part of the Adobe Learning Library
    I liked the book very much and I wanted to share my discovery with those of you who (like me) would like to bring the advantages of Object-Oriented Programming and Design Patterns to your Flash/AS3 application development efforts.
    I posted my review (“A Serious Guide to OOP Design Patterns”) on Amazon just the other day. Take a look at my review and browse through Mr. Smith's book—if you're interested.

    Nikimathew wrote:
    Every now and then I ask people if they are familiar with the book, Design Patterns: Elements of Reusable Object-Oriented Software. On such occassions, I'm often surprised to hear someone respond, "Yes, I've read it." Having spent close to three years running a study group devoted to understanding the subtleties, combinations and variations of the patterns in this book and others, I am often compelled to ask these individuals if they actually believe that the book can be "read" rather than "studied"? trolling for new members?
    three years? c'mon. i love the GoF book, but it's not holy writ. and it hasn't saved object-oriented software development.
    sounds like you need to move on to a new topic. go buy another book.
    %

  • Java game server design

    Hi,
    I am new to Java game programming. Could anyone tell me or let me know some tutorial about multi-player java game design, especially game server design.
    Thanks in advance
    nqthanh

    look here:
    http://java.sun.com/docs/books/tutorial/together/index.html

  • OOP Design: controllin​g multiple (similar) devices

    Hi guys,
    We have some software that controls different kinds of "widgets." They are identicle  in function, but they are from differering vendors and have different drivers and APIs. But here's the tricky part: they may be used by themselves, or in any combination you can  think of, up to 3 at a time. 
    Currently, we use a seperate version of our software for each widget combination, duplicating a massive amount of code-  since the only thing we do with each widget is configure it, then read its data (which it continuously takes), then close it when the program is closed. The rest of the software is the same. 
    I'm wondering what the best approach would be to combine the code. I'm thinking LabVIEW Classes would be a good approach, but, I am new to OOP so I'd like some advice with the design. I've seen the example "Board Testing", that looks interesting and somewhat similar - there they use a different subclass for each board. Analogously I guess I would use a different subclass for each widget. But I'm not sure this is a good idea, since I can have various combinations of the widgets. My main class wire would then have to contain multiple sub-classes. 
    Any ideas?

    pobrepablo1 wrote:
    OK, with these comments in mind I've created an Initialize method. "Wrapper" is the name of the driver refnum.
    I'm calling this subvi with "initialize" as the argument iff First Call? is true. I think this is the best approach? Or at least simplest for me. I've never used DVRs before (except on a TV... )
    This would not be the way that I would implement this. First of all I would have explicit methods for my operations instead of implementing like the old style action engine. Also, I would store the data in the class private data, not in unitialized shift registers. I would consider using a better name than "Wrapper". It is a poor name for your data.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Game Object Design Question

    Ok, I have a question on the logical design on my game. The game will consist of a world, levels within the world, items, NPC's, and a Player.
    I will have NPC's wandering around the world automatically. In order to move, they are obviously going to need to be able to look at the level they are on, and figure out where they want to go.
    My question is regarding the acces to the Level object. What is the smartest way to make someNPC.Move(int x, int y) be able to access the Level? Should I write some static methods for the World or Level classes? The only other way I can think of is to pass the World object on to the NPC's upon thier creation and have them store a reference to it...
    Thank you all very much,
    Michael

    My book on Java 1.3 says calling public final methods is fastest (together with calling private methods). public static methods take about twice as long to call but are still pretty fast. Values assume the jit has optimized the method. Calling synchronized methods is very slow. Instead of using synchronized, make sure only one object is making a movement decision at the same time.
    I would coordinate movement using the level objects, because unless objects move to a different level, only objects on the same level influence each other's movement (by standing in the way and for example).
    Every object in your model will have a position, and I assume part of the position information is the level it is on. You have several co-existing levels. In that case I would make the "level" postion information a reference to the level for direct access and I would make the methods the moving objects use public final (or just final if possible).
    Give your objects a reference to the level they are on. If you knew your exact position on the planet but had NO way to know what planet you are on, how would you decide where to move ? It would have to be something like "ok, I don't have any sensory information but I know I exist and I know my exact location. Lets make a step to see what happens. Oh, I still exist. This means I cannot be on the planet where the step would have resulted in a lethal drop. And oh, my position really did change. This helps too. Only 1.000.000.000.000 more planets to exclude by trial and error..."
    But Kayaman is right, the World or level needs to have a reference to each moving object too. You need a list of objects in the same area so the moving objects check for collisions, the level can tell them about environment effects that effect them (to all you moving objects inside me, the death star : You are dead because the rebells have blown up my reactor).

  • HT203167 my daughter has bought coins for a game called design but i have been charged twice and she has never received any coins for the game?

    My daughter bought coins for design game but never received them is there. Phone number for UK the money has came of my account

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • OOP Design Theory

    Hi,
    When designing a GUI Application, what is the best way to structure the objects.
    Would It be best to have a functional class (the class that does all the processing work) and then have another class that is linked via composition, that handles all the GUI functionaility for that functionility (which is normally encapsulated within a window or dialog.
    If so is it best for the functionility class to create and hold an instance of the GUI class or the other way round.
    Many Thanks
    Cheers
    Alex

    If I was to do it from scratch what implimentation
    key points would you suggest.The key point is to use existing frameworks and focus on designing/building/coding the Model. The Model represents the core functionality of the application (what is does/the verbs of the application) which is based on domain/business requirements.
    Before starting on anything related to implementation. The first step is to gather/derive/discover the domain/business requirements. Once you have the requirements, you can then start on creating a technical design, once you have a technical design, you can start on create a prototype of the application which implements a few of the highest.most important domain/business requirements.
    Once you have an executable prototype, you can revisit the technical design and if everything is ok, you can work on the second phase of the prototype and implement a few more domain/business requirments.
    Once you have the second iteration of an executable prototype, you can revisit the technical design and if everything is ok, you can work on the third phase of the prototype and implement a few more domain/business requirements.
    When everything is implemented in the prototype, you can put the application into test mode and then when done with that put it in QA cycle....and then poof, you have a working software application. Sounds easy....good luck!
    Check out the Spring Framework

  • Completely Resetting a Flash game

    Hi, I've got what I'm sure is a common requirement, but I'm not sure the best way to pull it off, and I have a feeling I'm not going to like the answers. I've looked this up before but didn't find enough of an answer for my circumstances. I apologize for the length of this post.
    In summary: I've programmed an entire game from scratch, without using class files, and there's no menu yet, and I'm not sure how to reset the game without using class files or resetting every single thing manually.
    I'm making a Flash tower defense game with a friend; I'm doing all the code. I'd never used Flash or Actionscript before, so I started off directly programming the gameplay, to figure out if I'd be able to do it. I've done everything from scratch so I didn't know where to start or the "right way" of doing anything, so I figured out as I went along, which went much better than I expected.
    So now I've got the gameplay almost completely programmed, the art assets are essentially finished and game looks great and runs (reasonably) well (and the occasional performance problems are due to graphics rather than code), etc. I didn't know how to use class files in AS3 when I started making the game, and when I read up on them and realized you can't import the class files into the project and must open and edit them separately, I was livid and decided not to use them; I was happy with how the coding was going anyway.
    So now we've got a game where as soon as you run it, it goes straight to the field and the game starts; we haven't implemented a menu yet. We've reached the point of playtesting and it's becoming a huge nuisance having to quit the SWF and reopen or recompile it every time we want to restart the game, so it's time to program a "Reset" button. I thought this would be as simple as making the stage go to a different frame and back to the first frame, but that doesn't work, so now I'm utterly stuck. It looks like the easiest way to reset a game is to load the entire "game" as an object (or something to that effect, I forget exactly what I've read), then you can unload and reload the game object to reset it? It also looked like it would require class files which I'm hoping to avoid.
    I don't think it's feasible to manually remove everything from the stage, reset all the variables, and delete all event listeners and references so everything is reset/garbage collected properly.
    Thinking about it more, I'm also not sure how I'm going to get a menu to load before the game in its current state. Maybe I can move all of the gameplay to the second frame and make the menu on the first frame?
    So, is it possible to reset the game without involving class files? Any chance you can do it by switching between frames and I just implemented that wrong?

    Generic words of wisdom aren't a substitute for an explanation of how to reset the game.
    There's no need to be condescending. Like I said, this is the first time I've used Flash. I'm not a stupid lazy kid who doesn't know how to structure development, I'm a developer who needed to make sure he could program the game before designing it. It would have been an enormous waste of time to plan out the game and our development approach without any experience, then build the menu and the basic structure and then get to the gameplay and realize I couldn't handle it.
    My friend and I had never made a game together, much less in Flash which I'd never even used before, so we didn't have the experience to know the best approach. So I figured it out as I went. Will I be able to dynamically create a grid which highlights under the mouse? Yes. Can I get it so the player can click a specific square and it will drop a tower there? Yes, maybe we'll be able to make the game. Can I dynamically load creeps onto the field, push them into an array, give them a waypoint set, and have them follow the waypoints? Yes. Will I actually be able to get a tower to index through the array of creeps, check which ones are in range and which of those has the lowest health, and launch a bullet which will follow that creep until it hits it? Apparently I can handle that.
    And so on and so on, and by making sure I had the skills to program the game, I had programmed the game! Imagine that.
    Don't decide to build a house, plan the house, and then realize you can't build it yourself and you don't have the money to have someone else build it.

  • How do I make a main menu for a game?

    Hi,
    I need to make a main menu for this tower defense game that I am making.  I have 2 parts to the menu that I need to put together.  I have it as follows:
    I have a start screen where the player presses the start button.  I now need it to take the user to the main menu itself.  I have both the start menu and main menu in the same document but on different layers.  I have a button labeled as start which I have set up to where when it is clicked, it changes colors but I also need it to hide/show the menu layer.  I just need the that start button to take users to the menu layer where I have 3 more buttons which are resume, new, and options.  I will need those buttons to go to their different layers also.  After users hit the resume or new buttons, I need the game itself to start which I will start making after I figure out the other issues. 
    I am new to Flash and I really want to learn how to make tower defense games.  For now, I am using http://www.ehow.com/how_7788131_make-tower-defense-game-flash.html as a guide to make the game stuff but it doesn't say anything about a main menu.  I am using a trial version of Flash Pro CS6 and it is due to expire in 28 days.
    Any and all help will be great! Thanks, xp3tp85

    I used this and it worked:
    import flash.events.MouseEvent;
    start_button.addEventListener(MouseEvent.CLICK,startF);
    function startF (e:MouseEvent):void{
    gotoAndStop("main_menu");
    On the next layer I used this and it worked too:
    back_button.addEventListener(MouseEvent.CLICK, buttonClick);
    function buttonClick(event:MouseEvent):void{
           gotoAndStop(1);
    Apparently it wont let me use the same code twice on one timeline.  Is there any way around this?  I need a few more buttons on the main menu for the game.

  • Game Promotion

    Hey everyone, I have been programming in Java for a while and I am about to graduate with a CS degree.
    Anyways I have made a multiplayer tower defense game using java and I am having a tough time getting it out in the open for people to try, give feedback, and enjoy in general.
    My question is, do you have any tips on sites I can submit the game to or other ways I can get the game out on the internet for people to try?
    Sorry if this is not a direct development question. BTW the game can be found at [http://www.gauntnet.com|http://www.gauntnet.com] and it uses the [Java Instructional Gaming Engine|http://ai.vancouver.wsu.edu/jige/]

    thanks for your guy's replies.
    I have found another forum I am going to post it to also.
    Let me know if you guys have any bug reports or game suggestions.

  • Multiplayer Game (JSP, Servlets)

    I have been programming a Multiplayer game for about a year now.
    It is simmilar to the popular Tower Defense games but I can't give you all the details.
    Would anyone be able to refer me to some examples that include
    Login features (connecting to a database or something)
    two players play a simple game, or chat or something, just to get me started.
    Thanks!
    ~Matt

    A multiplayer TD game? Sounds interesting. Are you planning on sending the game communication through a server, or direct connect to the other player? Are you looking for a Yahoo style setup when you join a chatroom and play from there?
    There is a program on SourceForge.net called JOGRE (Java Online Gaming Realtime Engine). It appears to have many of the features that you would expect on Yahoo, but their demo server is not running, so I could not try it out. It may be what you are looking for. The network communication is all in XML though, I wonder if XML is too network intensive for a multiplayer TD game...

  • Any free game apps that are actually good?

    I got my ipod touch a few days ago and before that I found a list of the "148 best free apps'. I downloaded the ones that looked good but most sucked, so are there any that are actually good and free? Rock band free version was at the top of that list and it sucked because there is only one song to play.

    i spend alot of time playing lightbike, it's kinda like the old game tron, and a good tower defense game i found was TM zero, also, assassin's creed has a free game out, worlds hardest game light is pretty cool, and COD Zombies is supposed to be good, i got it and i'm having a little trouble with the controls, but it's pretty cool, jelly car is nice to, red ball also. i still haven't found to many good ones, but i got most of those recently, i only got my touch 2 days ago, so yeh.

  • CS3 Won't Save (Mac)

    Hi,
    I am a school student making a flash game. We obviously have a server to save all of our files on and each of us have separate accounts.
    I have a problem on Flash CS3 with saving. Every time I try and save it opens a dialog box saying this:
    An unknown error occured while accessing /Network/Servers/harper.discovery1.school.nz/Volumes/Data/Shares/Homes/Leo/Desktop/Tower Defense Game.fla.
    I have tried saving it to multiple places on my account, I have tried saving it to a flashdrive, I have even tried +K, connect to our school server, log into a different persons account, and saving it there, and it still won't work. It has not always been like this, it only started playing up on the day that we had a proxy server set up (I am assuming that it has something linked to this.) I have told the person who has set the proxy up, and he couldn't do anything to save it, I have also got my teacher (who manages all the server etc.) to have a look at it, and he can't seem to fix it either. The way the accounts are set up is 10.6 Workgroup Manager. There are a few other people in my class making a flash game, but only one of them has had the same problem as me (though he managed to fix it.) So finally, I decided to restart the computer, and lose all of my saves. I then logged into my account again, tried to save it, and yet again, it still does not work. I thought that it must be some kind of problem with my account, so I got my teacher to make me a new account. I +K my old account to get the flash game off, put it on my new account, and went on it. It worked for about a week, (it still might be working now) but I am now making a new part of my game on a different file, and it is not saving again (even though it is on a different account.)
    Anyway, I hope someone will be able to help

    Is it because last night I happened to turn on my Firewall
    Most likely, yes.
    > Do I have to reboot?
    Most likely, yes.
    > Problem is, I can't save the html file I just did
    Copy the code from DW and paste it into Notepad. Save it.
    WAIT - are you
    saying you are editing directly on the server? Why can't you
    save it?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Mila D. Aguilar" <[email protected]> wrote
    in message
    news:fbm881$acj$[email protected]..
    > I've been using Dreamweaver CS3 for Mac lately, and have
    been able to
    > upload
    > quite a few pages already. Today, however, I was
    uploading a vital page
    > but
    > would constantly get the following message:
    >
    > "An FTP error occurred - cannot get remote folder
    information. Dreamweaver
    > encountered an internal data error. Please try the
    operation again."
    >
    > Is it because last night I happened to turn on my
    Firewall and turn off my
    > Personal File Sharing and Personal Web Sharing? However,
    I've since turned
    > off
    > the Firewall again, and turned on Personal File Sharing
    and Personal Web
    > Sharing. Dreamweaver still gives the same message above.
    >
    > Do I have to reboot? Problem is, I can't save the html
    file I just did,
    > and it
    > was a heck of a job. Don't tell me I have to do it all
    over again?
    >
    > Or is it because I deleted quite a few duplicate files
    from my local site
    > through my Finder? But I've been doing that before, one
    file at a time,
    > and
    > this never happened.
    >

Maybe you are looking for

  • SSRS - Oracle Stored procedure returns no data but does in SQL Developer Sudio

    HI there, Stored procedure returns no data when executed on the report but when i execute the stored procedure in Sql Developer it returns required rows. Thanks for your help!

  • Persistant Screen Flicker

    3 Genius Bar appointments couldn't solve it - my last chance before I implode is you guys! At random, anywhere from 0-10 times a day, the screen on my 15inch late-2008 MacBook Pro flicks on and off for a split second. Not a huge problem, sure. But it

  • ITunes Producer: submission error message

    Yesterday I made my first attempt to submit my book to iBooks and got the following error message: "@env: parameter is null: (null)" I have no idea what this error refers to, nor does iTunes Producer give you any clues what it is nor how to correct i

  • Commits in 10g

    Hi All, I'm in oracle 10gR2. I have a process that has Delete & Update statements....followed by other calculations. I have explicit commits between most of the DML...but still the results are not consistent.. Is this explicit commit sufficient enoug

  • How do you all...........

    Halloa How do apply for a student version of the latest, Adobe Photoshop lightroom program. Regards Me