Basic Game Design

I'm pretty new to Java programming (and programming in general), but I understand the basics pretty well. As practice (no current plans to publish) I've been designing some basic rpg-type games, and I seem to be running into the same basic design problems no matter what the game is.
First, is there any guideline as to making multiple categories of a particular type of object? For example, creating many species of dog, or many types of enemies. Is it best to make an abstract base class (dog) and make a subclass for each category (species in this case)? Or is there a better way?
Also, what is the best way to handle an event like a battle or a race? Should it be an object? If so, would it be better to have a base class? Like an abstract class Competition and subclasses Race, Frisbee, etc.? Or should methods be built into the code for a JPanel object? Or a competition interface?
If there's already a tutorial on this somewhere, please let me know. As I said, I'm new, but I catch on quick. Thanks

if you aren't using swingCan't vouch for Swing; I've never used it.
don't care at all about realistic timingI don't understand what you mean by that and why you think unthreaded code can't provide "realistic timing"
don't mind having all your animations tied to the framerait of the slowest animationThis problem can be solved by logic to the effect of:
if (animationInstance.timeSinceLastDraw > animationInstance.timeBetweenFrames)
     animation.render()
     animationInstance.timeSinceLastDraw = 0.0
else
     animation.timeSinceLastDraw += timeSinceLastFrame
always plan to have the same animations going at once and with exactly the same number of framesYou could definitely have a list of animations to run every frame which you add to and remove from.
and either plan on enforcing beefy minimum requirements or seriously limit the number of animations you plan to run at onceWell, yes, at some point, your requirements get so heavy that you need more than one processor, in which case I agree threads are necessary. For high-performance apps, it does make sense to use threads for animation to allow the user maximum use of his or her system's resources.
Seriously, there are so many tools for threads it is so easy to use them, I can't understand why so many people are so insistant on avoiding them like the plague.According to Guido Van Rossum, creator of Python, "unfortunately, for most mortals, thread programming is just Too Hard to get right.... Even in Python -- every time someone gets into serious thread programming, they send me tons of bug reports, and half of them are subtle bugs in the Python interpreter, half of them are subtle problems in their own understanding of the consequences of multiple threads...."
A big problem with threads is that it is all too easy to introduce subtle, difficult-to-reproduce bugs. Because the behavior of a threaded program is in many ways non-deterministic, such a program can be very difficult to debug.
Edited by: cronosprime1 on May 6, 2010 5:37 PM

Similar Messages

  • Advice on basic game program

    Some might remember the Battleship like game that I posted on here a little while ago. Well in this part of the code, I have found where the opponent has placed his ship and have to finish him off. I can do a basic random selection of shooting where I tell it to try shooting 1 space up, 2 spaces to the left, etc. What I want to do be able to have my program do is basically this:
    1. Opponent is hit once
    2. Shoot up one space - he was there and was hit successfully
    3. Shoot up two spaces - no hit
    4. Shoot down 1 space from the first hit in step number 1
    So there won't be any random shooting in this case. But I can't think of a good way to do this. Can someone help me with what I should be trying to do here. Not looking for an exact code to do this but rather something that will help me get started in doing this. Here is the basic part of the code with just random firing going on. L is a location on the 5x5 grid with r standing for row and c standing for c. found_opponent is a boolean class variable. location_is_bounds is a public boolean I have earlier in the code to make sure that the shots stay in the 5 x 5 grid.
    else if (found_opponent == true) {
                do {                  
                      switch (myRandom.nextInt(8)) {
                        case 0:
                            L.r = b.r + 1;
                            L.c = b.c;
                            break;
                        case 1:
                            L.r = b.r + 2;
                            L.c = b.c;
                            break;
                        case 2:
                            L.r = b.r - 1;
                            L.c = b.c;
                            break;
                        case 3:
                            L.r = b.r - 2;
                            L.c = b.c;
                            break;
                        case 4:
                            L.c = b.c + 1;
                            L.r = b.r;
                            break;
                        case 5:
                            L.c = b.c + 2;
                            L.r = b.r;
                            break;
                        case 6:
                            L.c = b.c - 1;
                            L.r = b.r;
                            break;
                        case 7:
                            L.c = b.c - 2;
                            L.r = b.r;
                            break;
                } while (!location_is_in_bounds(L));

    There is a Java Game Development Forum here
    http://forum.java.sun.com/forum.jspa?forumID=406and the purpose of it is
    Use this forum to discuss Java gaming topics such as game design, algorithms, optimization, 3D workspace, Java 2D, Java 3D, and artificial intelligence.
    This question belongs there; this forum is primarily about Java, not game algorithms.

  • Simple game design,

    so I have a basic understanding of java, I took a class on it this spring and did well. I am wanting to make a simple game, a single picture, a map, that is clicked.
    based on the location clicked, the player gets an item. this is an online game.
    I am going to use SQL for this game on the back end. it will have a db with two tables, users, and map.
    users will have user name, user ID, items owned, tools, and searched today.
    map Im not quite sure about yet.
    so basically, Im trying to figure out how I should go about this. Im not quite ready to hack code yet, I need to get a good plan together and make sure I go about this correctly.
    can I open this for discussion and get some help on designing this. Im trying to stay really very simple, so as not to undertake too much.
    this is my outline right now:
    login: a screen with name and pass fields, an ok button. when the button is clicked, the program checks the db for the name, and verifies the password, if everything is in order, goto the account screen, possibly a cookie or session of some sort is set.
    account screen: show the username, items owned and number of each, any tools or special items owned. button to logout, button to goto map. radio buttons on the tools to determine which one, if any, is equipped. there should also be a special area near the top that shows what item was found on the previous day.
    map screen: this is a small image of a map. the user clicks and shows a pin placed, as well as any other pins currently on the map for the day. a search button that when clicked, locks in the location untill the end of the day.
    the user can search one location per 24 hour period, server time.once a location is picked, its locked in till server is rolled to new day. based on the location, and the tool selected, the player gains an item, these will be used for creating items and such in a later game that is tied to the IP.
    pretty simple, login, pick a tool, pick a location, complain in the forum that you can't find good items, and that the main game isnt done, move on till tomorrow :)
    I need to go over each part in detail and do this right. I should mostly be SQL with a graphic frontend, which as of now Im choosing Java for, so this can run in a web browser. Im also considering PHP, but I fear it wont be dynamic enough. Flash is my other choice. I would like to get a good idea of what I need to do for each aspect before I make it. The screens I will make in netBeans, probably using Swing, and all of my actual logic will be in click events.
    Help me out guys, I need to talk about this step by step with someone.

    lord_midnight wrote:
    ]morgair: I have done some small projects here n there, mostly just demos, I am almost finished with a retro styled platformer, just placing tiles and entities, finishing up the art, code is done except for a few custom routines for a boss. this project is actually pretty small, other than being online, its a good choice for a first game type of project. Im confident it is within my skillset.Thank you for the reply, I was unsure what level of help you needed, many on here come in and have never done any programming before, let alone, an actual game on-line or otherwise. It's nice to hear where you're at.
    ]mrw: yeah, its not so much that I have a problem, I just want to make sure I think everything through before I start. Im trying to get a good grasp of what Im doing, so I don't have very many problems, Im sure I'll have a few though, somehow no matter how much I plan, something goes awry.
    ]soultech2012: Im actually in college, I took java this spring, and Im taking advanced java as soon as its offered online. still, its not so much instruction I want, as discussion.
    maybe I was not being so clear, Im not looking for anyone to write code, or tell me what to do, I want to talk with people, Im sure I will have direct questions at some point, but right now, I want to think it through. If anything, another set of eyes looking at the design, pointing out possible snags or logic problems. its pretty simple as far as games go, I did some prototyping in flash last night, I think this will be pretty easy. does anyone see any serious problems in the design ?
    I think it will make a nice little game, its not meant to take much time out of the players day, just a 2-5 minute jaunt into my website. login, pick a spot on the map, select a tool to use to help gather items, and slowly over several weeks, have accumulated a collection of goods for a game Im doing at a later date.
    getting the x,y will be easy, I have done a couple of very simple apps that interact with SQL,
    the only real logic parts of this are some ifs or a switch, and adding to a field in SQL.
    getting pixel color might be tricky, it was easy in flash, and Im pretty sure I saw a similar function last time I browsed the javadocs, so Im not too concerned.I like to use getRGB and setRGB from a BufferedImage.
    honestly, I looked around and I can all but make this in javascript and PHP/SQL, java might be overkill.
    anyone see any obvious ways to cheat the game ?If you store any logic on the client side they can easliy find and modify it, that way they can have a super character or all of the items. Runescape is perfect example of this, they run client server and there are groups that have made their own client to cheat with.
    am I underestimating the complexity of the task ? I have plenty of time to work on it, no hurry, but Im hoping to have something on the site within the next month or so.That is doable, If you are careful in your implementation, you can build a basic game engine and then work on map and support making for facilitate different levels.
    I need to make a list of terrains, the colors Im using for them, and items found, and I need to draw out a table that Im using to plot out the sql.
    Im taking PHP/SQL this fall, Im starting to get the hang of it, and I have a pretty good grasp of basic programming concepts. this should be well within reach, honestly, its glorified tic-tac-toe, or match-findingThe big things that seem to pop up for people are:
    Picking up items
    putting down an item
    weilding an item
    using an item
    combat
    breaking off combat
    automatic path plotting (least cost algo from map)
    frequency of random events
    regeneration of items
    regeneration of health
    real language interaction with characters (pattern matching for content)
    Just remember: choose what you want and don't let the scope of your game creap or you'll have a bunch of code that has no implementation end in sight. Keep your compiles short and changes departmentalize so you can have running code that works from one feature to another. I see a lot of people--experirenced too--that literally throw hundreds of lines of code out and then try to debug it after they make changes thorughout the stable code base to allow integration of the new feature; this can be very daunting, keep it as simple as possible to integrate new features--small steps are good.
    thanks for the input, and comments are welcome, best I can offer is thanks and bonus tools in the game once its done, so thank you.

  • Anyone around here with an apple developer program membership who lives in the us and wants to participate in entering the atari  indie developer challenge for pong? I have the great idea required, ample coding skills and a completed game design document.

    If you have a membership with the apple developer community or know anyone who has and also resides within the united states, please contact.
    The purpose is to partake in http://www.atari.com/pongdeveloperchallenge
    The initial game design document is fully completed and the ideas expressed in it are more than strong enough to compete for the top prizes.
    I'm well versed in different programming languages (c, scheme, js, assembly, python,...) as well as being a proficient sound designer and musician and a skilled graphics and animation manipulator myself. Assistance with the actual development would appreciated but is not really necessary.
    Winnings and proceedings arising from participation would distributed most fairly. If you know anyone besides yourself that is able to help out, you would also be rewarded financially from an ensuing victory.
    Reply to this post, pm or send  a gmail to aelgoa
    Have a good one
    Marnix

    If you have a membership with the apple developer community or know anyone who has and also resides within the united states, please contact.
    The purpose is to partake in http://www.atari.com/pongdeveloperchallenge
    The initial game design document is fully completed and the ideas expressed in it are more than strong enough to compete for the top prizes.
    I'm well versed in different programming languages (c, scheme, js, assembly, python,...) as well as being a proficient sound designer and musician and a skilled graphics and animation manipulator myself. Assistance with the actual development would appreciated but is not really necessary.
    Winnings and proceedings arising from participation would distributed most fairly. If you know anyone besides yourself that is able to help out, you would also be rewarded financially from an ensuing victory.
    Reply to this post, pm or send  a gmail to aelgoa
    Have a good one
    Marnix

  • HT201272 I was re-charged for an app that I re-installed at the game designer's suggestion.  How can I get my money back.\?

    as above, I was re-charged for downloading an app (game) I had already paid for.  This was done at the game designer's suggestion to reset the results. Why was a I charged a second time?  What can I do to get a refund?

    Unlress you changed it in Settings>General>Restrictions, there is a ten minute window for making additional purchases once you entered you password.
    Also, could the charge be for an in-app purchase in the free app?
    You can try to get a refund by:
    How to report/refund an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase

  • Is the i7 13" Macbook Air capable of playing some basic games?

    I'm looking into possibly grabbing a 13" Macbook Air with the i7 1.7Ghz processort and was wondering if it's capable of playing some basic games that are out in the Mac App Store such as Angry Birds, N.O.V.A. 2, or even Grand Theft Auto: San Andreas? Also I tend to use Vuze and sometimes Handbrake, would the high end 13" Macbbok Air be capable of doing all this for me?

    Capable? Yes indeed it is. However, if the game or application is CPU or GPU intensive, then you can expect longer waits for completion of tasks. It's not so much noticeable on rudimentary games, but it really has an effect on detailed fluid motion in games that rely on such.
    Handbrake tasks will just take longer to complete, it won't stop it.
    I use my MBA's for medium intensity gaming without any complaints. But really, you should refer to the system requirements on each, on a case by case basis.

  • Multiplayer game designing for mobiles using J2ME

    i m supposed to design a small multiplayer game for mobiles.It's my semester project.Have found many books for designing single player games but found none on multiplayer game designing.someone plz help me
    plz treat with due regards.

    I understand why results is different: bcs message arrival is not sequenial?
    UPD: There is 1 more thing i cant understand.
    If i will use NetStream and connect directly to peer it is possbile to fail bcs of Firewall or smth? In this situation i should use routing?

  • Game design

    Hello,
    Is the following correct for a tetris game?
    One thread for painting the game area and one thread for controling the falling rate of the tetraminos.
    Generally for games....
    One thread for painting the game area and one thread for each component that needs to control the update of its state on its own (for instance one thread for enemy spacecraft movement and one thread for missile movement)
    Are there any books related to games design which use Java for sample code?
    Thanks in advance

    One thread for painting the game area and one thread
    for controling the falling rate of the tetraminos.Java automatically creates and handles the UI thread, but you do need to create a new thread to drop the piece. For that, you should really check out Java.util.Timer and TimerTask
    Add a listener to the KeyboardFocusManager, and you should be good
    for each component that needs to control the update
    of its state on its own (for instance one thread for
    enemy spacecraft movement and one thread for missile
    movement)I definitely wouldn't do it this way. For games with discreet time steps, you should need one thread.
    Even handling 2 players at the same keyboard requires just the UI thread.
    In general, having multiple threads only helps in situations where
    1. You are waiting for something to happen, or for a certain amount of time to pass
    and
    2. You have other stuff you'd like to be doing in that timeframe.
    >
    Are there any books related to games design which use
    Java for sample code?
    Thanks in advance

  • Game Design Students need Animators

    Hello,
    We are a team of game design students in the middle of a five
    months flash game project. The team is composed of a
    Project chief/game designer/programmer (me), a
    game designer/script , a
    game/level designer,
    two graphists and a
    sound designer .
    The project started 2 mounths ago and must be finished for
    the end of april 2009.
    We are actually pretty stuck because of the lack of
    2D animators and are ACTIVELY looking for some
    here are some pictures of the project :
    The
    protagonist
    Some
    ennemies
    If you are interested in the project or if you know someone
    that should be, please conctact me :
    [email protected]
    or (messenger) [email protected]
    (sorry for my english, I’m french)
    Thanks

    I have this design for a game, but there is a snag in
    the implementation that I cannot resolve (that is see
    how I would design it).
    Summary (And this may have been done before):
    People design AI or Robots. By design that is
    program. Submit them, and have them compete against
    other robots.Definitely done before.
    >
    Question:
    How do I time slice evenly? And how do I control a
    robot that may use threads outside of the main thread
    alocated to it. That is I would like programmers to
    have the ability to program their robots using
    threads if they choose, but I need to make even (by
    processing time) with folks who don't use threads.
    Threads in this case only buys you a convienient
    abstraction.A non-trivial task.
    You create your own language. That language runs in an interpreter. The interpreter controls timeslices for each player.

  • What are you doing with software (games) designed to run on Snow Leopard.  Have you heard of anyone making a patch for LION?

    What are you doing with software (games) designed to run on Snow Leopard when the Os is Lion?

    It is up to the publishers of games to accommodate their software to Lion.
    Blizzard, publisher of StarCraft, WarCraft, and Diablo, has posted a statement about that -
    Blizzard Support
    Although they were able to create patches to allow the use of their (OS 9) games in OS X up through Snow Leopard, apparently from their perspective it is not possible to patch those games for Lion.

  • Invitation for Sculpt 08, A Game Design contest

    Invitation for Sculpt 08, A Game Design contest
    Hello Designer,
    International Institute of Information Technology, Hyderabad, India cordially invites you to be a part of Felicity, the annual cultural and technical festival, to be held from 8th - 10th February,2008.
    Sculpt 2008, the online Game designing competition is all set to start on 16th January,2008.Felicity 08 is sponsored by companies like Electronic Arts Mobile , Computer Associates , Google , Cozy Games and many more .
    Expecting a Huge response.
    Registration Starts: 16th January , 2008.
    Submission Date : 20th January to 10th Feburary, 2008
    Language : No bar on language .
    Visit Sculpt 2008 at
    http://felicity.iiit.ac.in/sculpt/
    Register Today !!!
    Thanks and Regards
    Team Sculpt @ Felicity 2008

    Invitation for Sculpt 08, A Game Design contest
    Hello Designer,
    International Institute of Information Technology, Hyderabad, India cordially invites you to be a part of Felicity, the annual cultural and technical festival, to be held from 8th - 10th February,2008.
    Sculpt 2008, the online Game designing competition is all set to start on 16th January,2008.Felicity 08 is sponsored by companies like Electronic Arts Mobile , Computer Associates , Google , Cozy Games and many more .
    Expecting a Huge response.
    Registration Starts: 16th January , 2008.
    Submission Date : 20th January to 10th Feburary, 2008
    Language : No bar on language .
    Visit Sculpt 2008 at
    http://felicity.iiit.ac.in/sculpt/
    Register Today !!!
    Thanks and Regards
    Team Sculpt @ Felicity 2008

  • I'm starting 3D Game Design College. Macbook Pro 13" or Macbook Air 13"?i

    I Am getting a new laptop for college. I have an iphone and an ipad so I figured why not switch to a mac computer as well. I am torn between the 13" Macbook Pro and the 13" Macbook Air. I am doing 3D Art and Animation/Game Design. Which is the best notebook for me?

    Is it a very noticable difference? Will I REALLY notice it? I know that the Pros are more powerful but I just wanted to factor in the SSD in the Air.

  • Best practice game design

    Having decided to use java to develop what will be for the most part a 2D (overhead) tile-based RPG game I'm wondering what the best practice is for designing a game like this.
    At the minute I'm intending on using a 'state' system, varying game states (main game, shop, battle, world map etc., state transitions and single use states to create further immersion in the game) implement a State interface that defines how the main game engine interacts with the state (mainly a tick method called on each game loop). When the program wants to switch the game state it makes a call to the main engine, something like setState(State).
    Has anyone written an RPG along these lines? What kind of memory usage did you have, and did you encounter any problems along the way with this design?

    So far, I've identified two perspectives.
    The first is to consider yourself as a sort of "overmind" that tracks each object within the game as a seperate entity. The primary advantage seems to be that it is trivial to add objects as you go along. The primary disadvantage is dealing with all the message passing.
    For example, say you are fighting a horde of goblins when a dragon flies overhead and breathes fire on the battlefield. You would have to call each goblin instance, and have that particular goblin check to see if it dies, and if so, call its death routine. You would have to call your own player object, and have it check to see if you are carrying potions. Each potion then would have to check to see if it boils and explodes in reaction to the dragon breath. And so on. But it would be trivial to add an orc to the battle, or change the dragon into an evil wizard.
    This consumes quite a bit of memory (for all the objects and references), and it can be a little tricky incorporating it into the game loop.
    The other aspect is to code the player as the "center of the universe" and everything happens with respect to that player. It becomes easier find relevant objects and interact with them, but it becomes much harder to just drop an object in place.
    Using the prior example, the dragon becomes your combatant. Damage is done to a goblin in the array and it dies. The next enemy in your array dies. Do so much damage to your inventory and remove them as appropriate. Keeping track of what's going on appears to be much more straightforward, but it would be harder to add the evil wizard to the mix.
    This consumes less memory - the game is only worried about things that happen around you as opposed to well... a whole bunch of "entities" at the same time, and is significantly faster and easier to add to the game loop.
    State machines tend to follow this approach, event driven games tend to follow the prior approach.
    Obviously, I don't code games for a living. I would think that most games these days are somewhat of a mish-mash. Use a basic state machine as in the FF7 example to keep track of broad activities, and within each activity, let the objects manage themselves in response to events.
    For example, each game tick could switch among movement activities, "peaceful magic" activities, battle activities, clean up activities (such as death and xp rewards), and finally general inventory and shop activities, skipping steps as appropriate.
    And say within the movement event, you could have an monster object scream and add itself to the battle mode queue if it detects your player object within such and such a distance.
    Anyway, I've been toying with the idea of coding or volunteernig to work on an RPG as well, so I'd be interested in hearing from you guys on how to organize things too.

  • Where can I learn Flash CS5.5 basic + Game development?

    Hey where can I learn Flash CS5.5 basics along with game development with the Adobe Gaming SDK?

    By the way i own the site 02geek.com its an online school for programing and we do focus a lot of our time in flash. if you want a step by step from 0 to geek type of training give my site a try

  • Need help in a game design.Cirles,lines intersections

    Hello,
    Im trying to create a board game (the go game) but i have problems with the design. Till now i have design a 19 * 19 table and what i want is when i click with the mouse on this table to display circles, but i want them exactly on the intersection. With my program i get circles everywhere i click and not on the intersection of the line.
    So if anyone can help me,i would like to tell me, how can i place the circle exactly on the intersection? Also i would like to eliminate the clicks just on the table and not outside of it.
    Please help if anyone knows, im not that expert in java
    My code is this till now.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class goGame extends JFrame {
    private int x1Value , y1Value ;
    boolean isWhitesTurn = true,first = true;
    public goGame()
    super( "Go game" );
    Color redbrown = new Color (75,17,17);
    setBackground(redbrown);
    addMouseListener(
    // anonymous inner class
    new MouseAdapter() {
    // store drag coordinates and repaint
    public void mouseClicked( MouseEvent event )
    x1Value = event.getX();
    y1Value = event.getY();
    repaint();
    } // end anonymous inner class
    ); // end call to addMouseMotionListener
    setSize( 700,550 );
    setVisible(true);
    public void paint( Graphics g )
    Graphics2D graphics2D = (Graphics2D ) g;
    Color redbrown = new Color (75,17,17);
    g.setColor(redbrown);
    Color lightbrown = new Color (192,148,119);
    g.setColor(lightbrown);
    if (first) {
    //paint yellow the big rectangle
    graphics2D.setPaint(new GradientPaint (600,100, Color.yellow,100, 10,Color.red,true));
    graphics2D.fillRect(60,60,450,450);
    graphics2D.setPaint(Color.black);
    graphics2D.setStroke(new BasicStroke(3.0f));
    //draw rows
    int y=60;
    for (int n=0; n<=18 ; n++)
    g.drawLine(60,y,510,y );
    y= y + 25;
    //draw columns
    int x = 60;
    for (int n=0; n<=18 ; n++)
    g.drawLine(x,510,x,60);
    x = x + 25;
    g.setColor(Color.green) ;
    //draw the 1st 3 vertical dots
    int z = 133;
    for (int n=0; n<=2; n++)
    g.fillOval(133,z,5,5);
    z = z + 150;
    //draw the 2 vertical dots of the 1st row-dot , the 1 already exists
    int w = 283;
    for (int n =0; n<=1; n++)
    g.fillOval(w,133,5,5);
    w = w + 150;
    //draw the 2 vertical dots of the 2nd row-dot
    int t = 283;
    for (int n=0; n<=2; n++)
    g.fillOval(283,t,5,5);
    t = t + 150;
    //draw the last dots
    g.fillOval(433,283,5,5);
    g.fillOval(433,433,5,5);
    first = false;
    if (isWhitesTurn) g.setColor(Color.white);
    else g.setColor(Color.black);
    g.fillOval( x1Value, y1Value,20,20 );
    isWhitesTurn = !isWhitesTurn ;
    // execute application
    public static void main( String args[] )
    goGame application = new goGame();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    This will capture vertical and horizontal
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class GoGame extends JFrame
    public GoGame()
         getContentPane().setLayout(null);
         setBounds(10,10,510,520);
         getContentPane().add(new TheTable());
         setVisible(true);
    public class TheTable extends JPanel
         int[][]points  = new int[19][19];
         boolean black  = true;
    public TheTable()
         setBounds(20,20,453,453);
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   Point p = clickOnIntersection(m.getPoint());
                   if (p != null && points[p.x/25][p.y/25] == 0)
                        int x = p.x/25;
                        int y = p.y/25;
                        if (black)
                             points[x][y] = 1;
                             black = false;
                        else
                             points[x][y] = 2;
                             black = true;
                        capture(x,y);
                        repaint();
    private Point clickOnIntersection(Point p)
         Rectangle rh = new Rectangle(0,0,getWidth(),4);
         Rectangle rv = new Rectangle(0,0,4,getHeight());
         for (int h=0; h < 19; h++)
              rh.setLocation(0,h*25-1);
              if (rh.contains(p))
                   for (int v=0; v < 19; v++)
                        rv.setLocation(v*25-1,0);
                        if (rv.contains(p)) return(new Point(v*25+1,h*25+1));
         return(null);
    private void capture(int x, int y)
         onTheY(x,y,points[x][y]);
         onTheX(x,y,points[x][y]);
    private void onTheY(int x, int y, int col)
         for (int j=x-1; j > -1; j--)
              if (points[j][y] == 0) break;
              if (points[j][y] == col)
                   outOnY(j,x,y);
                   break;
         for (int j=x+1; j < 19; j++)
              if (points[j][y] == 0) break;
              if (points[j][y] == col)
                   outOnY(x,j,y);
                   break;
    private void onTheX(int x, int y, int col)
         for (int j=y-1; j > -1; j--)
              if (points[x][j] == 0) break;
              if (points[x][j] == col)
                   outOnX(j,y,x);
                   break;
         for (int j=y+1; j < 19; j++)
              if (points[x][j] == 0) break;
              if (points[x][j] == col)
                   outOnX(y,j,x);
                    break;
    private void outOnY(int f, int t, int y)
         for (f=f+1; f < t; f++) points[f][y] = 0;
    private void outOnX(int f, int t, int x)
         for (f=f+1; f < t; f++) points[x][f] = 0;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(new GradientPaint(getWidth(),getHeight(),Color.yellow,0,0,Color.red,true));
         g2.fillRect(0,0,getWidth(),getHeight());
         g2.setColor(Color.black);
         for (int n=0; n < 19; n++)
              g2.fillRect(0,n*25,getWidth(),3);
              g2.fillRect(n*25,0,3,getHeight());
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);          
         g2.setColor(Color.green) ;
         for (int n=0; n < 3; n++)
              g2.fillOval(25*3-1,n*150+74,5,5);
              g2.fillOval(25*9-1,n*150+74,5,5);
              g2.fillOval(25*15-1,n*150+74,5,5);
         for (int x=0; x < 19; x++)
              for (int y=0; y < 19; y++)
                   if (points[x][y] != 0)
                        if (points[x][y] == 1) g.setColor(Color.black);     
                        if (points[x][y] == 2) g.setColor(Color.white);     
                        g2.fillOval(x*25-9,y*25-9,20,20);
    public static void main(String[] args)
         GoGame game = new GoGame();
         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Noah

Maybe you are looking for