I'm thing of creating a game in flex

I'm thing of creating a game in flex. It will be a original strategy game based more on playability and thinging rather than sheer Graphics. Could you give me and tips before I start out?
The game will be based on a collection of circles that group together and by stonger together than apart(for both attacking and defense) but there will also be a map where statigic objectsives will be based. You will have some type of simple base and resource gathering.
thanks

Maybe I should be more specific in my requirements. My game will have upto say a maximum of battle 10000 units. What is the best way to store the data of the units efficiently.
A unit object would have parameters like this
yLoc
xLoc
health
level
etc
thanks

Similar Messages

  • Create game with Flex?

    Hi all
    this might be a stupid question, but me really not well
    understand what Flex was, and what the Flex purpose.
    me have download the trial version of flex, and found it seem
    more focus on coding and exclude the drawing things which similar
    to Flash.
    my question : is it possible to create Flash game with Flex ?
    what could be done in Flash is it possible to done in Flex
    too?
    thanks

    hi,
    With flex you need to envoke the filereference function save. Because of the security sandbox you can not programmatically save files or create folders, you need to open a windows file browse box then the user can create a folder or save a file.
    private function testme():void
    var fi:FileReference = new FileReference();
    fi.save("hello"); <=== this would open a system file save dialogbox
    David.

  • How to create a Game where each answer controls a flash animation?

    Hi,
    I need to create a quiz where each correct answer advances a character on a game board and each incorrect answer advances the "enemy" character.  At the end the results need to be saved to a MySQL database.  Is this possible with Captivate?
    Currently I have the game developed, but I have done everything in Flash, I would like to use the quiz creation tools in Captivate to create the quiz since the quiz I created is not as fancy as what can be done with Captivate.
    I have Flash CS3.
    Thanks for your help.
    LA

    If I get that right: You created that "game" in Flash. The questions will be made in Captivate. So you will insert the swf. file (the game) onto your captivate slide.
    Have you tried to access the Captivate variable "cpQuizInfoLastSlidePointsscored" within flash? So you could tell the game that if this variable is zero /or 10) the flash file should do something
    About this MySQl thing
    Mybe this will help:
    http://www.adobe.com/devnet/captivate/articles/store_cpresults.html
    http://pipwerks.com/journal/2008/09/07/send-captivate-quiz-data-to-javascript/
    best regards
    captiware

  • New to Java, want to create a game any help appreciated.

    I just downloaded java Studio. I would like to create Java games. Not sure where to start.. Do i need more programs? Any info would be of great help thanks....

    Hey,
    If you want to know which software you need to program java games (or any other java application for that matter), I'm guessing you don't have much experience using java.
    First, to answer your question, Studio will certainly do to create java. But even notepad will suffice. The only thing you really need to have is a SDK, you can get it from the Sun site.
    Second, You should ask yourself if java is the language to program in. Java is well suited for developing games. But it is also a very powerful general purpose language, so it can be very overwhelming. Maybe you should think of the alternatives?
    Flash: Has much better browser support than applets, so if you want to make an online game, this is probably a better choice. Don't be afraid of the possibilities in flash, unless you want to do 3d. You don't want do to 3d yet.
    PHP: if your game is text based, you might want to program it in PHP. It is mostly used for multi-user-"dungeons"(fill that in as you want).
    If you really want to learn how to program in java, I suggest you don't start on your game just yet. Try this PDF for starters: http://www.mindview.net/Books/TIJ/. The java tutorial is also pretty good, but cover the basics first: http://java.sun.com/docs/books/tutorial/ . I also suggest you don't start programming in an IDE(for you: Sun studio) until you start working with multiple classes. I suggest JEdit for "basic"(it has a million features, don't worry) programming. Later you can start to learn Sun Studio (Or Eclipse, if I can lodge in my preference), but be careful: these programs are excellent, and will spare you hours of work, but only if you spend (a lot) of time on how to use them properly.
    As a final thought: the web is your friend. There are tons of good resources on the web for developing games, and lots of them focus on java. A good place for info is http://www.gamedev.net/, lots of articles, and helpful hints on choosing language, tile games, etc... Another specific one is http://www.brackeen.com/javagamebook/. It has working code for a tile-based game, and it even has a software 3d engine. It also has good for for detecting mouse and keyboard actions. Get more experience before you start with these ones, though.
    Good luck!

  • Create a game , how? what to use?

    Hi,
    I would like to create a game. The only one what I know is: I want to make (with my wife) and I want to be distributed over internet. I would like to make it free playable and some custom items could be bought from shop.
    I am very familiar with java (desktop) programming, I have a 3d project finished in java, my wife could be a designer, artist.
    I would like to develop around 2-3, max 6 months, and I would like to earn around 1000-2000 usd / month after a period of stable release. What to do?
    I like the mmo games specially the 3D strategy like: [allods online|http://allods.gpotato.com/] . For my wife the best is a pet care game like superpoke .
    Today I saw a demo for a 3d java library it was an rpg game ( others was implemented in C or idk what , maybe assembly some parts). This kind of games in my mind it will take at least 6 months development to become basic playable and if anybody would give a donate / buy something, but a real estimate is for 10 developers and 1 year to satisfy somebody(at allods are 100 names at credits and had a budget of 12 mill usd). So here leak of HR, time, money. I am right? Have you other idea?
    The pet care games are simpler, but are implemented in Flash. I am wondering if I could find something similar like Flash in Java, JavaFX, or a Swing application launched with webstart? (a jnlp file at web page)
    The development with Flash requires a learning time for me, and is important expense the 1000 usd or more for flash development license, which I would invest only if I have no other choice ( better invest this money on marketing, advertising).
    The third part of games are web based(php), rich javascript on it, like : gladiatus ,travian what java alternative? simple JSP+struts?
    As hardware, I think I meet the requirement for a server at least on the beginning.
    What to do, with what technologies?

    If you're not just doing this for fun, and you expect to earn money from it, then you shouldn't be worrying about the technologies at this point. The very first thing you should do is look into the distribution model. Are there any services that distribute Java-based games, collect money from players, and distribute the earnings to the developers? If not, you'd have to build all that yourself, and even if it were a perfect system you might find it impossible to find users. Given what you've said (you want to earn relatively modest income from it, and you apparently don't have a huge advertising budget), rolling your own distribution system probably isn't an option.
    It's likely that all the technical decisions will be driven by the distribution model. For example, you might find that the best way to create and distribute your game is with XBN (the Microsoft thing; I might have the acronym wrong), and that might require C++ and specific XBN libraries. (I don't know, but you should investigate.)
    There may be sites out there (Pogo.com is one, I think) that will distribute a Java-based game, but I have no idea what their terms are. You should investigate and make sure the terms are palatable before you start coding. I suppose you could do a first pass in Java right away, and then if the distribution model you choose doesn't use Java, you could re-write the code in whatever language you have to use for the distribution system; that would mean you're working with prototypes which is fine but you should be aware of this when you're going in.
    Keep in mind that Facebook games are really hot right now; that might affect what you want to create, and whether people want to distribute what you create.

  • Help Needed For Creating A Game

    Hi, I recently decided to make a MMORPG.A game people will enjoy and have fun, I would of course keep it free sense I have play many games that cost 5-15 dollars a month.I have many creative ideas, but I need someone to show me the ropes and teach me how to use Java and i currently looking for a site to download it at.If anyone would care to teach me how to use this or would like to help me create this game(Medievil type game, Swords armor gold houses dragonslaying and plenty more) post here or send me a pm and we can talk more private.
    I need:
    *A site to download the best possiable Java console
    *Helpful tutorial sites
    *Or any other sites or tips you think i should know.
    Extra Info On Me:
    I dont know if this matters or not probably doesnt but I know how to handle and make a site, ive had some dbz rpgs back in the day(kinda rusty but i can manage).
    Some more recent information:
    I tried game maker and that doesnt seem to helpful.It would only be helpful if I played them 20 bucks which I am not going to do.
    Also i am downloading now JS2E 5.0 for Java.
    I am stilling waiting on some type of input or even a mentor.

    Hi there!
    I'm not really a game programmer.. but here's some links anyway.
    Someone pointed out this tutorial to me, and I think it is worthwhile:
    http://fivedots.coe.psu.ac.th/~ad/jg/
    It has stuff on Java 3D, networking, games for mobile phones/PDAs, isometric tile games, etc. It also has an appendix on loaders and Java Web Start.
    Also, if you want to create 3D games, you might want to check out
    http://www.3dcafe.com/asp/freestuff.asp
    They have free 3D models in various formats.
    For more 3D links and tutorials try:
    http://www.3dlinks.com/
    For a 3D tool, I like Anim8or. That it's free helps a lot ;)
    http://www.anim8or.com/
    And... ms paint!?! You will not be able to draw decent graphics with that. Adobe Photoshop Elements is a nice, low-cost program for 2D images.
    There are lots of sites devoted to java game programming. Try the google. Love the google. Google is your friend. ;)
    :) jen

  • If I Use JavaFX to Create a Game Do I Have to Release the Source Code?

    Hello,
    I've asked this question before, but I just thought I would try it again now
    that version 1.0 is out.
    If I Use JavaFX to Create a Game Do I Have to Release the Source Code?
    Thanx in advance.

    Could you please point me to a resource describing "the JavaFX Runtime license"? I'm trying to find answers to the following questions:
    1. I'd like to use Scenario.jar from the JavaFX project in a desktop app that is not using Webstart and is not an applet. Will I be able to ship the jar with my software?
    2. Can JavaFX applications be distributed as commercial software in the absence of a Web connection?
    What's not clear to me is which is the real license for Scenario.jar (as shipped with JavaFX). Is it the one in openjfx-compiler's trunk, or the one that comes with the JavaFX SDK (which is very vague about redistribution)?

  • When you create your Game Center ID, it does a Security Question, for what reason? It never asks you it!

    When you create your Game Center ID, it does a security question, for what reason? It never asks you it!

    App store frequently asked questions
    http://support.apple.com/kb/HT2001
    http://support.apple.com/kb/HE37

  • How to i retrive a fake person created in game center cant type ( on iphone

    how do i retrive a fake that i created in game center. phone will not let me type (< my name>). I cannot remember the email address. it is a fake hotmail.
    i cannot retrive the game that i bought items for on itunes. help

    Sorry. Pretty sure only restoring the phone as new will clear those cached addresses. It's been an issue for a while, haven't heard anything about an update changing that.
    You can request the feature from Apple:
    http://apple.com/feedback

  • How can i/adobe tell which licence (student or normal) things are created in?

    How can i/adobe tell which licence (student or normal) things are created in?
    Basically i want to know how i can find out, (in an exported jpg for instance) where it would say it was created in the student edition or in the normal edition. I dont want to put files that would be going against the student licence (which for those of you who dont know you cant create items to sell in a student edition) on the internet to make money.
    I have put i/adobe because if no one can tell what files are created in, and i have the licence for the normal one then it should be okay.
    Hope some of you can help,
    James

    no one know still?

  • Wich software should I use to create a game??

    I'm sorry if I did not find answer to my question in the forum, but I don't understand so much english. I would like to create a game, and I'm searching for the software. could you help me? Thank you

    Hi I come back with my new username since a forum update.
    I find I have been well received, as -I ask for a Sun software and I am anwered with Dark Basic, and I ask clearly in my second post how to develop on mobile phones, and have been answered "You don't have the "right" to +complete+ initial post since you didn't tell everything in initial post.
    You. How are you receiving new developers. Do you really want to help users know how to use Oracle products, or do you want to make it as obscure as possible and chock.
    Now I precise, I was -when it was at an enhancement and growing people using it- how to have an editor -visual editor with drag'n drop facilities AND/OR a IDE, to publish on mobile phones using JAVA.
    I don't aim anymore to publish on phones since each new OS has its XNA, Apple or Chrome development tools, but I am amazed how user-friendly and respectful and full of kindness I have been recieved by 2 or 3 pople from the community. Is this forum moderated and can a moderator or administrator or a professional answer me? -> the question is in the title: Which software(s) should I use to create a game? I'm looking up evidently to Oracle-only downloadable products.
    Sincerely,
    Sylvain

  • Creating a game board, as a grid

    Hi everyone,
    i have to write a cluedo like game in java for a class i'm taking. I've already created the game logic, and now i have to implemente a graphic interface using Swing: i have all the boxes contained in a large array. Now how can i print them on screen, using different boxes for each room, displaying walls, and so on, creating then the Cluedo board? Can anybody help me? Swing hasn't been covered much during the course... :(
    Thanks!
    Iacopo

    Ok, i read the tutorial, though i'm stucked trying to print the board in a JFrame as a JLayeredPanel. My intention is to print in the bottom layer, the backgroud (i.e. the grid where the pawns move) and in the layer above the pawns themselves.
    I wrote this code, but it just won't show the background of my boxes....please help me!
    Thanks... ;-)
         private void printBoard (Tabellone t) {
              frame.remove(low);
              frame.remove(startup);
              JSplitPane splitPane = new JSplitPane();
              frame.add(splitPane);
              right.setSize(250, frame.getHeight());
              right.setOrientation(JSplitPane.VERTICAL_SPLIT);
              JLayeredPane pane=new JLayeredPane();
              pane.setLayout(new GridLayout(NUMBER_OF_FILES,NUMBER_OF_ROWS));
              pane.setSize(new Dimension(frame.getWidth(),frame.getHeight()));
              ImageIcon pias=new ImageIcon("C:/Documents and Settings/Iacopo/Desktop/piastrella.jpg");
              for (int i = 380; i >=0; i -=20) {
                   for (int j = i; j < i + 20; j++) {
                        Casella cs = t.getArrayCaselle().get(j);
                        if (cs.getNome()!=""){
                             ImageIcon room=new ImageIcon("C:/Documents and Settings/Iacopo/Desktop/STANZE/"+cs.getIndex()+".jpg");
                             JLabel background=new JLabel(room);
                             JLayeredPane casella=new JLayeredPane();
                             casella.add(background,new Integer(10));
                             casella.setOpaque(true);
                             pane.add(casella);
                        } else {
                             JLabel square=new JLabel(pias);
                             square.setOpaque(true);
                             pane.add(square);
              splitPane.setRightComponent(right);
              splitPane.setLeftComponent(pane);
              frame.add(splitPane);
              frame.pack();
              frame.setLocation((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 4 - frame
                        .getWidth() / 4),
                        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 4 - frame
                                  .getHeight() / 4));
              frame.setVisible(true);
         }

  • HT4314 We have one appleid user account and have created two game center logins,  but can now only access one...any idea how to be able to access the other

    We have one appleid and have created two game center login names under that one apple id.  now we can only access one of the logins.  does anyone know how to get to the other account

    This is to avoid piracy. What could happen is, people could buy music, and give it away for free online. Usually it is then you buy a complete album off iTunes that it will only be available on one device. It is tied to that account, and the device must be registered to that account to listen to it.

  • Creating breakout game. Need help with thread starting.

    Howdy. As the title says, I've got an assignment to make a breakout game. So far it's going alright, but I've run into a rather large snag...I can't get it to animate :P I've got my main applet, then I created a class heirarchy for the paddle, ball, and brick objects. For this question, lets just focus on the ball object.
    This is my applet code so far (it is not even close to being done, so don't laugh :P )
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * Class BreakoutApplet - Plays a simple game of Breakout.
    * @author Kris Nelson
    * @version November 10, 2004
    public class BreakoutApplet extends JApplet implements Runnable
        protected Brick brick; // creates an object of class brick
        protected Ball ball; // creates an object of class ball
        protected Paddle paddle; // creates an object of class paddle
        protected boolean running; // tells the program whether or not the thread is running
        protected ArrayList brickArray = new ArrayList(); // stores all the bricks in the game
        protected Thread timer; // the thread which controls the animation for the applet
        * Called by the browser or applet viewer to inform this JApplet that it
        * has been loaded into the system. It is always called before the first
        * time that the start method is called.
        public void init()
            // this is a workaround for a security conflict with some browsers
            // including some versions of Netscape & Internet Explorer which do
            // not allow access to the AWT system event queue which JApplets do
            // on startup to check access. May not be necessary with your browser.
            JRootPane rootPane = this.getRootPane();   
            rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
            createBricks(); // creates the games array of bricks
            ball = new Ball(400, 400, 2, 2); // sets the values for the ball
            paddle = new Paddle(300, 660, 2); // sets the values for the paddle
            // !!!!!!! have tried placing ball.start() here
        * Paint method for applet.
        * @param  g   the Graphics object for this applet
        public void paint(Graphics g)
            // draws the background, border, and all the games objects
            g.setColor(Color.lightGray); // sets the drawing color to light gray
            g.fillRect(0, 0, 600, 700); // displays the game screens background
            displayBorder(g); // displays the game screens border
            displayBricks(g); // displays the array of bricks
            ball.display(g); // displays the ball
            paddle.display(g); // displays the paddle
        * Creates the games array of bricks
        public void createBricks()
            int colorNumber = 1; // starts the color of the bricks at orange
            double yPosition = 100; // starts the bricks y screen position at 100
            for(int i = 0; i < 4; i++)
                double xPosition = 12; // starts the bricks x screen position at 12
                for(int j = 0; j < 8; j++)
                    if(colorNumber == 0)
                        colorNumber = 1; // sets the color of the bricks to orange
                    else
                        colorNumber = 0; // sets the color of the bricks to green
                    brickArray.add(brick = new Brick(xPosition, yPosition, colorNumber)); // adds a brick to the current container in the brick array
                    xPosition = xPosition + brick.getWidth(); // move the bricks x screen position to the next column
                yPosition = yPosition + brick.getHeight(); // moves the bricks y screen position to the next row
                if(colorNumber == 0)
                    colorNumber = 1; // sets the color of the bricks to orange
                else
                    colorNumber = 0; // sets the color of the bricks to green
        * Displays the game screens border
        * @param  g   the Graphics object for this applet
        public void displayBorder(Graphics g)
            g.setColor(Color.black); // sets the drawing color to black
            g.fillRect(0, 0, 600, 24); // draws a border on the top of the screen
            g.fillRect(0, 0, 12, 700); // draws a border on the left of the screen
            g.fillRect(588, 0, 12, 700); // draws a border on the right of the screen
        * Displays the array of bricks on the screen
        * @param  g   the Graphics object for this applet
        public void displayBricks(Graphics g)
            Brick currentBrick; // holds the brick data from the current ArrayList container
            for(int i = 0; i < 32; i++)
                currentBrick = (Brick)(brickArray.get(i)); // grabs the brick data from the current ArrayList container
                currentBrick.display(g); // displays the current brick
        * Called by the browser or applet viewer to inform this JApplet that it
        * should start its execution. It is called after the init method and
        * each time the JApplet is revisited in a Web page.
         public void start()
             if(timer == null)
                 timer = new Thread(this); // creates a new object of type Thread
                 timer.start(); // starts the new thread
                 running = true; // tells the program that the new thread is running
        * Runs the code that controls the animation
        public void run()
            do{
                repaint(); // redraws the screen
                try{
                    timer.sleep(100); // puts the thread to sleep for 100 milliseconds
                } catch(InterruptedException e) {running = false;}
                // !!!!!!! have tried placing ball.start() here
            } while(running);
            timer = null; // destroys the timer thread
        * Called by the browser or applet viewer to inform this JApplet that
        * it should stop its execution. It is called when the Web page that
        * contains this JApplet has been replaced by another page, and also
        * just before the JApplet is to be destroyed.
        public void stop()
            running = false; // tells the program that the thread is now done
    }These are the bits of code for my class heirarchy, just to (hopefully) make it easier to follow.
    import java.awt.*;
    * The parent class of all the games objects.
    * @author Kris Nelson
    * @version November 9, 2004
    public class Sprite
        protected double screenX, screenY; // stores the x and y location of the object
        * Constructor for objects of class Sprite
        * @param  xPosition   the initial x screen position
        * @param  yPosition   the initial y screen position
        public Sprite(double xPosition, double yPosition)
            screenX = xPosition; // sets the initial x screen position
            screenY = yPosition; // sets the initial y screen position
        * Sets new x and y screen locations for an object
        * @param  newX   the new x screen location
        * @param  newY   the new y screen location
        public void setScreenXY(double newX, double newY)
            screenX = newX; // sets the new x screen location
            screenY = newY; // sets the new y screen location
        * Sends back the current x screen location
        * @return     the current x screen location
        public double getScreenX()
            return screenX; // returns the current x screen location
        * Sends back the current y screen location
        * @return     the current y screen location
        public double getScreenY()
            return screenY; // returns the current y screen location
    import java.awt.*;
    * Parent class of any game object that moves.
    * @author Kris Nelson
    * @version November 9, 2004
    public class MovingSprite extends Sprite implements Runnable
         protected double speedX, speedY; // stores the speed of an object in the x and y directions
         protected Thread timer; // the thread which controls animation for all moving objects
         protected boolean running; // tells the program whether or not the thread is running
         * Constructor for objects of class MovingSprite
         * @param  xPosition   the initial x screen position
         * @param  yPosition   the initial y screen position
         * @param  xSpeedValue   the speed in the x direction
         * @param  ySpeedValue   the speed in the y direction
         public MovingSprite(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
              super(xPosition, yPosition); // passes the initial screen positions to Sprite
              speedX = xSpeedValue; // sets the speed in the x direction
              speedY = ySpeedValue; // sets the speed in the y direction
         * Sends back the speed in the x direction
         * @return     the speed in the x direction
         public double getSpeedX()
             return speedX; // returns the speed in the x direction
         * Sends back the speed in the y direction
         * @return     the speed in the y direction
         public double getSpeedY()
             return speedY; // returns the speed in the y direction
         * Starts the thread in order to start animation
         public void start()
             if(timer == null)
                 timer = new Thread(this); // creates a new object of type Thread
                 timer.start(); // starts the new thread
                 running = true; // tells the program that the new thread is running
         * Empty since the child objects have their own run methods
         public void run()
         * Stops the thread from running
         public void stop()
             running = false; // tells the program that the thread is now done
    import java.awt.*;
    * Creates a single ball who's purpose is to bounce around and destroy the bricks.
    * @author Kris Nelson
    * @version November 10, 2004
    public class Ball extends MovingSprite
        protected static final double BALL_WIDTH = 15; // sets the width of the ball
        protected static final double BALL_HEIGHT = 15; // sets the height of the ball
        * Constructor for objects of class Ball
        * @param  xPosition   the initial x screen position
        * @param  yPosition   the initial y screen position
        * @param  xSpeedValue   the speed in the x direction
        * @param  ySpeedValue   the speed in the y direction
        public Ball(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
            super(xPosition, yPosition, xSpeedValue, ySpeedValue); // passes the initial screen positions and ball speeds to MovingSprite
            // !!!!!!!! have tried placing timer.start() here
        * Displays a ball onto the screen
        * @param  g   the Graphics object for this applet
        public void display(Graphics g)
            g.setColor(Color.blue); // sets the balls color
            g.fillOval((int)(screenX), (int)(screenY), (int)(BALL_WIDTH), (int)(BALL_HEIGHT)); // displays the ball
        * Runs the code that controls the balls animation
        public void run()
            do{
                try{
                    timer.sleep(100); // puts the thread to sleep for 100 milliseconds
                } catch(InterruptedException e) {running = false;}
                screenX = screenX + speedX;
                screenY = screenY + speedY;  // this is VERY SIMPLE BALL MOVEMENT FOR TESTING PURPOSES, WILL BE CHANGED LATER
            } while(running);
    }Sorry if that was too much code. I'm just trying to make this easier to follow.
    I placed a // !!!!!!!!!!!!! comment in the places where I have tried starting the ball thread.
    So basically, everything is running fine, except that I'm not at all sure of where to start the ball Thread, and thus can't start anything moving. If someone could tell me where I should be starting the thread, I would REALLY appriciate it. Thank you :D
    - Kris

    Some advice.
    1. the start method on the ball should be called from the start method on the applet and should in turn call the start method on the sprite's thread.
    2. the run method of the Moveable sprite should have been declare abstract
    3. don't implement borders manually. There's a java.awt.Border class for that.
    4. probably, you don't want to have the game invoke each sprite by name; just make a big list of all the sprites and invoke all of them every time
    5. do you really need provision for a non-circular ball? this isn't rugby.
    6. I don't think you ever had a threading problem, just a display problem.
    7. Don't write comments like this:     ball.display(g); // displays the ballHere's my (even more simplified version):import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * Class BreakoutApplet - Plays a simple game of Breakout.
    * @author Kris Nelson, modified by Michael Lorton
    * @version November 10, 2004
    public class BreakoutApplet extends JApplet implements Runnable {  
        protected Ball ball;
        protected Paddle paddle;
        public boolean running; // tells the program whether or not the thread is running
        protected Thread timer; // the thread which controls the animation for the applet
        public void init() {
            // this is a workaround for a security conflict with some browsers
            // including some versions of Netscape & Internet Explorer which do
            // not allow access to the AWT system event queue which JApplets do
            // on startup to check access. May not be necessary with your browser.
            getRootPane().putClientProperty("defeatSystemEventQueueCheck",
                                            Boolean.TRUE);
             ball = new Ball(this, GAMEWIDTH / 2, GAMEHEIGHT / 2, 5, 5);
        public final static int GAMEWIDTH = 600;
        public final static int GAMEHEIGHT = 400;
        public void paint(Graphics g) {
            g.setColor(Color.lightGray);
            g.fillRect(0, 0,
                       GAMEWIDTH, GAMEHEIGHT);
            ball.display(g); // displays the ball
        * Called by the browser or applet viewer to inform this JApplet that it
        * should start its execution. It is called after the init method and
        * each time the JApplet is revisited in a Web page.
        public void start() {
            if(timer == null) {
                timer = new Thread(this); // creates a new object of type Thread
                timer.start(); // starts the new thread
                running = true; // tells the program that the new thread is running
            ball.start();
        * Runs the code that controls the animation
        public void run() {
            do{
                repaint(); // redraws the screen
                try{
                    Thread.sleep(100);
                } catch(InterruptedException e) {running = false;}
            } while(running);
        public void stop() {
            running = false;
    abstract class Sprite {
        protected double screenX, screenY; // stores the x and y location of the object
        protected final BreakoutApplet parent;
        * Constructor for objects of class Sprite
        * @param  xPosition   the initial x screen position
        * @param  yPosition   the initial y screen position
        public Sprite(BreakoutApplet parent, double xPosition, double yPosition) {
            this.parent = parent;
            screenX = xPosition; // sets the initial x screen position
            screenY = yPosition; // sets the initial y screen position
        * Sets new x and y screen locations for an object
        * @param  newX   the new x screen location
        * @param  newY   the new y screen location
        public void setScreenXY(double newX, double newY) {
            screenX = newX; // sets the new x screen location
            screenY = newY; // sets the new y screen location
        * Sends back the current x screen location
        * @return     the current x screen location
        public double getScreenX() {
            return screenX; // returns the current x screen location
        * Sends back the current y screen location
        * @return     the current y screen location
        public double getScreenY() {
            return screenY; // returns the current y screen location
        abstract public void display(Graphics g);
    * Parent class of any game object that moves.
    * @author Kris Nelson
    * @version November 9, 2004
    abstract class MovingSprite extends Sprite implements Runnable {
        protected double speedX, speedY; // stores the speed of an object in the x and y directions
        protected Thread timer; // the thread which controls animation for all moving objects
        protected boolean running; // tells the program whether or not the thread is running
        * Constructor for objects of class MovingSprite
        * @param  xPosition   the initial x screen position
        * @param  yPosition   the initial y screen position
        * @param  xSpeedValue   the speed in the x direction
        * @param  ySpeedValue   the speed in the y direction
        public MovingSprite(BreakoutApplet parent,
                            double xPosition, double yPosition,
                            double xSpeedValue, double ySpeedValue) {
            super(parent, xPosition, yPosition);
            speedX = xSpeedValue; // sets the speed in the x direction
            speedY = ySpeedValue; // sets the speed in the y direction
        * Starts the thread in order to start animation
        public void start() {
            if(timer == null) {
                timer = new Thread(this); // creates a new object of type Thread
                timer.start(); // starts the new thread
                running = true; // tells the program that the new thread is running
        * Runs the code that controls the balls animation
        public void run() {
            while (parent.running) {
                try{
                    Thread.sleep(100);
                } catch(InterruptedException e) {
                    System.err.println(e);
                step();
        abstract protected void step();
    * Creates a single ball whose purpose is to bounce around and destroy the bricks.
    * @author Kris Nelson
    * @version November 10, 2004
    class Ball extends MovingSprite {
        protected static final int BALL_DIAMETER = 15;
        * Constructor for objects of class Ball
        * @param  xPosition   the initial x screen position
        * @param  yPosition   the initial y screen position
        * @param  xSpeedValue   the speed in the x direction
        * @param  ySpeedValue   the speed in the y direction
        public Ball(BreakoutApplet parent,
                    double xPosition, double yPosition,
                    double xSpeedValue, double ySpeedValue) {
            super(parent, xPosition, yPosition, xSpeedValue, ySpeedValue);
        * Displays a ball onto the screen
        * @param  g   the Graphics object for this applet
        public void display(Graphics g) {
            g.setColor(Color.blue);
            g.fillOval((int)(screenX),
                       (int)(screenY),
                       BALL_DIAMETER, BALL_DIAMETER);
        protected void step() {
                screenX = screenX + speedX;
                if (screenX < 0) {
                    screenX = -screenX;
                    speedX = -speedX;
                else if ((screenX + BALL_DIAMETER)> BreakoutApplet.GAMEWIDTH) {
                    screenX = 2*(BreakoutApplet.GAMEWIDTH  - BALL_DIAMETER) - screenX;
                    speedX = -speedX;
                screenY = screenY + speedY;
                if (screenY < 0) {
                    screenY = -screenY;
                    speedY = -speedY;
                else if ((screenY  + BALL_DIAMETER) > BreakoutApplet.GAMEHEIGHT) {
                    screenY = 2*(BreakoutApplet.GAMEHEIGHT - BALL_DIAMETER) - screenY;
                    speedY = -speedY;
    }

  • HT2490 I can't change my system preferences because I did the wrong thing in creating the admin profile, so whenever i tried to change the system preferences, I can't do it. How do I resolve it?

    I cannot change my system preferences because I did the wrong thing in creating the admin profile. So, whenever I wanna change the preferences again, it says to me that you cannot do this. How do I resolve this?

    Do you have an account that is a type of Administrator? If not, try this tip to restore an Administrator account.

Maybe you are looking for

  • Can't shut down, some applications don't close and others don't open

    I installed Leopard about 3 weeks ago as a clean install not an update. Since then, I have frequent problems shutting down and con only do it manually. I also have some applications - like Firefox - which won't close - the blue light in the dock stay

  • Does any one know the pdf only scenario?

    Hi we came across an 'undocumented feature' of interactive form usage in WDA, that's the so called  pdf only scenario. This is how it works: 1. for the form form UI element , only the pdfsource is bound to a context node , datasource and template sou

  • Smartform output uneven....

    hi all, i m having couple of issues if  u can help me out.. 1. i have defined a table and then line type for one internal table i need to display. I have assigned the texts to the columns and then the fields. problem is output i receive is not in str

  • Any way to run diagnostic (like Disk Utility) on the Time Capsule Drive?

    I have a Time Capsule with an internal drive that "needs repair", and yet I have no way of repairing it. I have a call in with AppleCare and am still awaiting their call back (2 days) as to what can be done about the drive short of erasing it, and my

  • Win2k cannot start oracle services

    Hi, Usually, our oracle servers can start up autometically when the machine start up. Just now, oracle services cannot start. I try use start->control panel->administrator tool-> services to start oracle service, it gets errors as following: could no