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);
     }

Similar Messages

  • [Newbie] Which JAVA API is a good choice for creating a game board?

    I'm a newbie in JAVA game programming.
    I would like to create a chess game for fun. I have a fairly good idea on how I want it to be, but I'm having some difficulty on the game board.
    I am not sure which set of JAVA API I should be using to design my board. I guess that the board will sits in the back, and in the front, there'll be my chess pieces that I can drag and drop.
    Should I be using JAVA Swing to do this? or JAVA 2D API? It will require some study for either one, so I figure I should pick a good one to learn.
    Thanks in advance! :-)

    Also if you would like to create a much simpler, 2D chess game, I would suggest you use the Swing API, which comes with Java from version 1.2 and on up. Naturally I would suggest at least using the latest 1.4 or 1.5 software development kit, because they have greater and more stable features, bug fixes and so on. I also would suggest you go to the library or Barnes and Noble nearest you, and pick up a book on Java. One recommendation that may be simpler to get an understanding of Java is from Deitel and Deitel: http://www.deitel.com/books/jHTP6/ though my beginner's Java book was geared directly toward how to program games (small games like memory, or tetris), though I can't remember what it was called. Anyway I believe it is very important to learn the basics of Java before you get into things that you may or may not understand. My opinion, so have a go at it.

  • Question about creating a traditional board game with

    I'm creating a classic board game (i.e. monopoly, sorry,
    mouse trap) where the users will move based on the random result of
    a roll of dice. The board has 100 squares that the piece can land
    on.
    What's the best way to give all 100 squares a value so that I
    can take the current value of the player piece (movieclip) and add
    the result of the dice roll?
    Thanks in advance for your assistance.
    Note: I'm developing this game for Flash Lite.

    use array t store value of squares n then add the
    corresponding value t the value of dice generated randomly using
    math.random fuction. -- atulag

  • 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

  • Setting up a game board

    Hey, i was wondering if anyone could give me some pointers on how to set up a game board using JFrame or an Applet?
    fyi the game i am trying to make is checkers

    Ok got the game board i think...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.ArrayList;
    public class CheckersBoard
        final int EMPTY = 0;
        final int RED = 1;
        final int BLACK = 2;
        int board[][];
        void checkersData()
           board = new int[8][8];
           setUpGame();
        int pieceAt(int row, int col)
           return board[row][col];
         void setUpGame()    //* Set up the board with checkers in position for the beginning
                             //* of a game.
                             //* The first 3 rows contain black pieces, last 3 rows contain
                             //* red pieces
               for (int row = 0; row < 8; row++)
                for (int col = 0; col < 8; col++)
                   if ( row % 2 == col % 2 )
                      if (row < 3)
                            board[row][col] = BLACK;
                      else if (row > 4)
                         board[row][col] = RED;
                      else
                         board[row][col] = EMPTY;
                else
                   board[row][col] = EMPTY;
             }       }  // end setUpGame()
        public void paintComponent(Graphics g)
                /* Draw the squares of the checkerboard and the checkers. */
             for (int row = 0; row < 8; row++)
                for (int col = 0; col < 8; col++)
                   if ( row % 2 == col % 2 )
                      g.setColor(Color.LIGHT_GRAY);
                   else
                      g.setColor(Color.GRAY);
                      g.fillRect(2 + col*20, 2 + row*20, 20, 20);
                  switch (pieceAt(row,col))
                     case CheckersData.RED:
                         g.setColor(Color.RED);
                         g.fillOval(4 + col*20, 4 + row*20, 15, 15);
                         break;
                     case CheckersData.BLACK:
                         g.setColor(Color.BLACK);
                         g.fillOval(4 + col*20, 4 + row*20, 15, 15);
                         break;
       }//end class checkersboardbut now im stuck...I kno i need an abstract class piece, then create redPiece and blackPiece extending into piece. and i also need to input the rules, which i think i will add to the gameBoard class. And a class for people. Im not sure how to do any of that =P, ill be reading up on it more over the next couple of hours so plz drop some hints if u can.
    PS, I have no idea how to display my board...
    Edited by: JavaNoobie on Feb 15, 2008 2:18 AM

  • 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)?

  • I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign?

    I need to create 4 @ A2 boards that print adjacent to one another (all landscape format) with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards? Is it best to use Illustrator(CS3) or Indesign?
    Thanks.

    Re: I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign
    If possible, please try Indesign CS 4.

  • How do I create a message board/forum using forms in Dreamweaver?

    I want to create a forum or messageboard using the form in Dreamweaver but I don't know how to do it. Is there any guidance on how I could create a message board or forum on Dreamweaver?

    I don't think it can be done with just dreamweaver,
    You will have to download something like PHPBB,
    If you have a host with fantastico deluxe you can easily set up a forum
    with it.
    Daniel

  • 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 create a message board page?

    Does anyone know how to create a message board page?
    Thanks.

    Forumotion definately. You can do so much with their forums from template editing, theme uploading, pure HTML page creating...they are the best i have been with.
    If you haven't got much time, and want to see what the new phpbb3 can offer, just try it out on this host : free forum hosting

  • 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

  • When using FF 5.0, rollover type ads on Facebook game Lexulous pages are 'enlarged' and block 1/3 of the game board. Using up to date versions of Win 7 Home Premium, Adobe Flash and ActiveX

    When using FF 5.0, rollover type ads (i.e. ads for XBOX) on Facebook game Lexulous pages are 'enlarged' and block 1/3 of the game board. Using up to date versions of Win 7 Home Premium, Adobe Flash and ActiveX on an HP Pavillion dv7 laptop. Does NOT happen at all in MS IE 8, but occurs every time in FF 5.0.
    Also, Google 'translate this page' links do not work in FF 5.0, but works in MS IE 8. All I get in FF is a blank page, time after time.

    Hi,
    I am using a Nvidia 4200M adapter in my Laptop, Driver 266.96, Direct X 11
    In my desktop I am using an ATI XFX 6950, latest revision drivers (I am not at home right now so I cant get that info).
    The issue I did describe above, but it was a long explanation.
    In some flash games the game files load initially and get as far as the "click to start" button. Then the flash area usually goes either all white or all black (usually depending on the falsh game default background color) and then it stays that color. Cant see anything after hitting start (usually most games have an intro video or animation before the game starts, but I cant see any of it.
    For the very few games that do start, the flash game or application does not seem to work correctly in that when the rare game starts, it wont save any game files or save files to the pc and so if I exit the game (navigate away to another page or close browser) and then later come back, even though I click the option to save games (and ensure that the flash application slider shows it can save files and lots of space) it does not save and I have to start from the beginning all the time.
    More explanation I gave above.

  • Game Board on Pogo Games is partially hidden

    For some reason the game board on my Pogo games has slid or moved over under the chat area.  I cannot get it to move back.  I can enlarge the outside screen but the game board doesn't move.  Their support services have been unable to resolve the problem.  I have tried changing the screen resolution, but it doesn't help.  Any help would be greatly appreciated.  Thanks.

    Is Java working now you have updated to Firefox 8.0.1?
    * http://www.java.com/en/download/help/testvm.xml - How do I test whether Java is working on my computer? - 1.4.2_xx, 1.5.0, 6.0

Maybe you are looking for

  • Error message if i want to register in SAP service market place

    Hi...        I am getting this error message while registering in SAP service market place how can i solve this problem and what is the way to register.The following is the error message: A user ID cannot be created with the specified data, because n

  • Possible Bug in ID5.5 When Exporting Images to ePub

    Just wanted to relate my experience with exporting images to ePub in InDesign CS5.5. I've already spent the better part of two weeks trying to find a resolution for the problem with Adobe's customer service techs in India. Nice guys, but so far not o

  • Import from Canon HF200 stalls

    When importing 1080i clips, 30 sec. clips behave normally, but 10-11 minute clips start normally then freeze with about 15% imported. The program (iMovie) quits responding and has to be force quit. If the import is stopped before the freeze, nothing

  • Reload sequence file when changes on disk

    Hi, I wrote a custom user interface based on the TestStand (TS) Operator Interface. When I run a sequence file on it and I edit it in the TS editor and I restart an execution, it seems to keep loading the first one when I launch the execution. The on

  • Objects not in BI-CONTENT

    Hello Experts, when i replicate a COPA DS to BI7.0 i got the message that some objects r not in active version.But when i tried to search them in BI-CONTENT for activation ....i couldn't find them......r all objects not available in BI-CONTENT ....if