×

Discussion Board

Page 1 of 9 123456789 LastLast
Results 1 to 15 of 130
  1. #1
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Unhappy Desperate Game Project (First time in game developing)

    Hello everyone.
    I am a university senior student and as my thesis project I have to develop a Hexagon game on S60 using J2ME and MIDP profile. I have downloaded and installed everything needed(Net Beans 6.5, JDK etc.) and I did some excersice to learn the mobility pack(buttons, texts..) The problem is I dont have any experience of developing a game before nor im a professional Java coder. I have just learnt what they gave us at the university, no extra stuff but we have been to internships and I worked with C++ on developing a software. However I must use J2ME for this project. Another problem is I have 6 weeks to complete this game with Bluetooth connection supporting 3 players.
    So is there any chance for me to accomplish this? How and where should I start? I dont want to fail the course and to be left behind :(
    I have found an e-book called J2ME Game development with MIDP. I got the link from another thread while searching. Also Im working on another mobile game example, learned a few stuff (canvas, how to draw line etc.) but I am losing time because I think that I need a source focused totally on a hexagon game and bluetooth stuff(which is impossible), otherwise I dont believe i can finish it in 6 weeks. I need help, suggestions and guidence please.
    Last edited by ginnixcan; 2009-03-16 at 11:15.

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Desperate Game Project (First time in game developing)

    Quote Originally Posted by ginnixcan View Post
    Hello everyone.
    I am a university senior student and as my thesis project I have to develop a Hexagon game on S60 using J2ME and MIDP profile. I have downloaded ans installed everything needed(Net Beans 6.5, JDK etc.) and I did some excersice to learn the mobility pack(buttons, texts..) The problem is I dont have any experience of developing a game before nor im a professional Java coder. I have just learnt what they gave us at the university, no extra stuff but we have been to internships and I worked with C++ on developing a software. However I must use J2ME for this project. Another problem is I have 6 weeks to complete this game with Bluetooth connection supporting 3 players.
    So is there any chance for me to accomplish this? How and where should I start? I dont want to fail the course and to be left behind :(
    I have found an e-book called J2ME Game development with MIDP. I got the link from another thread while searching. Also Im working on another mobile game example, learned a few stuff (canvas, how to draw line etc.) but I am losing time because I think that I need a source focused totally on a hexagon game and bluetooth stuff(which is impossible), otherwise I dont believe i can finish it in 6 weeks. I need help, suggestions and guidence please.
    Hi,
    You must not give-up by just hearing the name of the game...
    Tell us more about the game..I mean no. of level..and so on..
    If it is a simple game then you have to just do the folloeing things,can be done in 6 weeks,
    1.read the blue tooth API
    2.Canvas
    3.Data persisting way-RMS
    4.Media if required...
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    Ok. Here is a link that you can have a look at the game.
    http://www.miniclip.com/games/hexxagon/en/

    I have to do the exact same thing for mobile, the algorithm and stuff (excluding graphics and effects) and plus the bluetooth.
    The rules are simple, you can either move to one adjacent space to clone yourself, or you can move to the space ahead the adjacent space and thus you only jump there not cloning yourself. If you move to enemy's adjacent you copy as many stones as he has around you. Same rules apply for the opponent of course. There are no levels, its just a board game.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Desperate Game Project (First time in game developing)

    Six weeks isn't much. I posted some sample game code here. This is not necessarily the "best" structure for a J2ME game. However, it is a simple structure to work with, and will behave well on the majority of devices.

    As you will have worked out by now, you will need at least two classes. A Canvas and a MIDlet. The MIDlet class doesn't need to contain much more than:

    PHP Code:
    private MyGame game;
    public 
    void startApp() {
        if (
    game == null) {
            
    game = new MyGame();  // this is the Canvas from the sample code
            
    (new Thread(game)).start();
        }
        
    Display.getDisplay(this).setCurrent(game);

    Points to note:

    1. Unlike C++, member variables in Java do not start out with random values. They are pre-initialized by the run-time to their default value (0 for numbers, '\0' for chars and null for objects).

    2. startApp() can be called more than once (once at the start, and later after calls to pauseApp()). The "if" is to prevent multiple MyGame instances from being created and started. However, we want the "setCurrent()" in all cases, to make sure we have the game on the screen.

    3. I suggest you leave pauseApp() and destroyApp() blank... you don't have much time to make it "nice", focus on getting it working.

    Try to make use of methods like getHeight() and getWidth() of Canvas, Image and Font, and also the sizeChanged() event in Canvas. Don't "hard-code" values in (even as named-constants) if you can avoid it. This will give you much more flexibility of changing artwork sizes, or even switching to a different device, without suddenly having to make thousands of code changes. Remember that a "real world" J2ME game must be adapted to dozens of different screen sizes at the lowest possible cost, so this is best-practice.

    Don't create Threads (other than the one you start in startApp()). Threads sound clever and tempting, but unless you are very experienced with writing multi-threaded code, strange, confusing things will happen, and your head will explode.

    No matter what books say, don't try to stop and re-start the thread.

    In the example code, you can stop the game's thread by setting "exitGame" to true. On it's next iteration, the loop in run() will exit.

    I recommend creating a nice, simple state model in the Canvas.

    PHP Code:
    private static final int STATE_SPLASH_SCREEN 0;
    private static final 
    int STATE_MAIN_MENU 1;
    private static final 
    int STATE_GAME_START 2;
    private static final 
    int STATE_GAME_PLAYING 3;

    private 
    int state
    If you write yourself a state transition diagram, you can create a STATE_ constant for each state. You'll impress your tutor, and discover that state transition diagrams are actually useful. :-)

    Your run() and paint() methods then containt something like:

    PHP Code:
    switch (state) {
    case 
    STATE_SPLASH_SCREEN:
        
    // do work, or do painting
        
    break;

    Don't add extra sleep() calls. If you need to delay in a certain state (like on a splash screen), then count frames in the run-loop. So, three seconds is 30 frames at 100 milliseconds per frame.

    Take time to read the sample code, and understand why it is written this way. Any questions, ask me.

    And good luck!

    Graham.

  5. #5
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Desperate Game Project (First time in game developing)

    If it only has to run on one device of which you know resolutions you might want to just create a backgound (an Image) of the game area, and use a couple of Sprite(s) for the round moving thingies :P
    then using layermanager (GameCanvas) u could just draw the Sprites on top of the background (which could be a SPrite itself)...
    Then you could create an array with x-y coordinates precisely on the "holes" where u can place the game pieces...
    After that some algorithm should be created which takes into account from which x-y coordinate the player may move to another x-y coordinate... some hash table or something...
    this would be a very coordinate-fixed piece of software, so it wouldnt be dynamic nor it would look good on any other resolution device...

  6. #6
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    Thank you very much for your support Graham. It looks much helpful, I will study your code after I finish what im on right now which is another tutorial and so little left and then ask you questions. So far I have learned how to put a background image, tiled layer, user input navigation etc.

    To Tiger79 and everyone:
    Hehe actually I like the idea. But I was just thinking to put a tiledlayer image to the background with each cell shaped as a hexagon shape. But why you say that it wouldn't work nicely on other devices?? If I cannot put an image, then how can I draw hexagon shaped cells on the background and put the player's hexagon shape stone on it??

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Desperate Game Project (First time in game developing)

    A TiledLayer is built for a grid of squares, not a grid of hexagons. You're going to need to implement a kind of "hex grid manager". This is not a big deal... Hexic works the same way.

    Obviously, an image is always rectangular. Placing the hexagons on top of each other is easy:

    Code:
    int totalHeight = hexagonImage.getHeight();
    y += totalHeight;
    But left to right is slightly more difficult. The trick is to get the proportions of the hexagon right, so you can work out the position of the next column from the size of the image. Look at the web game you posted, you'll see that the hexagon image is 38 pixels tall... an even number makes it easy to work out the "y" value of the next column.

    Code:
    y += totalHeight / 2; // or -=, if the next column starts higher
    In the 'x' direction, they need to overlap, so you need to advance the x by some fraction of the total image width. This fraction is: the width of the hexagon's base (the bottom side), plus half of the remaining image width. (See attached image.)

    Code:
    int totalWidth = hexagonImage.getWidth();
    int baseWidth = (some fraction of the total width)
    x += baseWidth + ((totalWidth - baseWidth) / 2);
    In the attached image, the total width divides by six, and the base width is:

    Code:
    int baseWidth = (totalWidth / 6) * 4;
    The proportions are not great, I'm sure you can come up with something better. Keep the divisor small, though, or it will become hard to make images of different sizes. I made mine square, but the web-game, the hexagons are short and wide - this probably looks more appealing.

    Cheers,
    Graham.
    Attached Images Attached Images

  8. #8
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    well, my tutor said that i should use a grid for the background. but how do i use it? i searched it on google but cant find anything. or is it some kind of merge with other layers so we should implement it by ourselves?

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Desperate Game Project (First time in game developing)

    You'll need to manage your own grid of hexagons.

    Essentially, you are going to refer to the position of any hexagon with a row and column number.

    Then, you need to convert (row, column) into (x, y). For a square grid, this is easy. For a hexagonal grid, you'll need to think a bit more. Remember that columns are not all the same length.

    You can:

    1. Do like Tiger79 says, and draw a fixed background image. This is nice and easy, but as he says, it will not resize to suit a different size of screen.

    2. Do as I wrote above, and create a PNG with one hexagon, then draw it repeatedly for each position on the game board. This doesn't resize either.

    3. Forget looks, and draw the hexagons using drawLine() or fillTriangle(). You can easily make this adjust to fit any screen size. You could use fillArc() to draw the pieces.

    Since you're desperate, I'd go for option 3.

    First task: write a class to represent one element on the grid. Each element can be in one of three states. It is empty, it contains a player's piece, or it contains an opponent's piece. Its state will change during play. It has a row number and a column number, and these never change.

    I've outlined what such a class might look like below. You need to do the hard bits. :-)

    PHP Code:
    public class Hex {
        
    // values for "state"
        
    public static final int EMPTY = 0;
        public static final 
    int PLAYER 1;
        public static final 
    int OPPONENT 2;

        private 
    int row;
        private 
    int column;
        private 
    int state;

        public 
    Hex(int rint c) {
            
    row r;
            
    column c;
            
    state = EMPTY;
        }

        public 
    void setState(int s) {
            
    state s;
        }

        public 
    void getState() {
            return 
    state;
        }

        public 
    void paint(Graphics g) {
            
    // calculate (x,y) for hex
            // PUT CODE HERE!

            // draw hexagon
            // PUT CODE HERE!

            
    if (state != EMPTY) {
                
    // draw piece
                // PUT CODE HERE!
            
    }
        }

    Next step: create as many of these objects as you need, and get them drawing on the screen correctly.

    Then: add code to work out, for a given Hex, which other Hex objects are adjacent to it. You need this for one space away, and for two spaces away. Build the code needed to navigate around the grid, select a Hex, and to select to destination.

    Once you've done this, you're a long way down the road.

    Good luck!
    Graham.

  10. #10
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    **deleted**
    Last edited by ginnixcan; 2009-03-26 at 20:18.

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Desperate Game Project (First time in game developing)

    You're naming all your methods with a Capital letter. In Java, the convention is that Class names start with a Capital, but member names (like methods) start with lowercase. In paricular, this is causing you a problem because you need to implement a method called "run()", but you've implemented a method called "Run()".

    Stick to the Java convention, and all will be OK.

  12. #12
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    Ahhh yes sorry, i was just deleting my post a few seconds ago because i have realized that it was a capital "R". Sorry.

  13. #13
    Regular Contributor
    Join Date
    Dec 2008
    Posts
    69

    Re: Desperate Game Project (First time in game developing)

    Ok. I have a few more questions.
    You say that it will not resize on other devices if I use an image, but how are the other games made for these devices then? Are all Symbian 60 phones same with their resolution and screen size, so we should think about the resolution during developing according to which Symbian version we are developing for? (I never realized if they are or not).
    I researched some about hexagon drawing, mostly i saw codes using math functions, like cos and sin to draw a perfect hexagon. Does microedition library has these?
    Lastly, is there any document like MSDN for java microedition library so I can learn what the code does? I really need it for methods, instance types variable types, libraries etc.

    Thanks.

  14. #14
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,563

    Re: Desperate Game Project (First time in game developing)

    All Symbian devices do not have the same display resolution or orientation. Most of the current Nokia models use QVGA (240x320 pixel) resolution in portrait or sometimes in landscape (and sometimes on devices that can operate in either orientation). Check the individual device specs on http://www.forum.nokia.com/devices/matrix_all_1.html

    Either you need to use separate bitmaps for different resolutions or orientations, or you need to scale them yourself (if and when it makes sense and the quality or performance is not impacted too much). If and when scalable vector formats (SVG) are usable, then that'd work, too. And with games, you might also familiarize yourself with what options you have for 2D and 3D graphics libraries (and on some devices you can also have 3D hardware acceleration available, too).

    Consider reading a book like this one:

    http://www.amazon.com/Java-ME-Game-P...8162682&sr=1-2

  15. #15
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Desperate Game Project (First time in game developing)

    Quote Originally Posted by ginnixcan View Post
    You say that it will not resize on other devices if I use an image, but how are the other games made for these devices then? Are all Symbian 60 phones same with their resolution and screen size, so we should think about the resolution during developing according to which Symbian version we are developing for? (I never realized if they are or not).
    Usually, if you're writing a J2ME game, you want it to run on as many phones as possible (more phones = more downloads = more money). That means you're probably dealing with screen sizes from 96x65 up to 352x416 (or even up to 800x480!). You're also dealing with JAR size limits as low as 64k, heap memory as low as 200k, and vastly differing processing power. All that, without making the game rubbish on high-end devices.

    Porting a game to a full range of devices can require more man-hours than were required to write the game in the first place. Porting can easily result in 50 distinct versions.

    Even just Series 60 come in 176x208, 240x320, 352x416 and 360x640 (any more?). And as Petrib says, many of these devices work on two different orientations, so you need to cope with 240x320 and 320x240 on the same device. At the very least, you will need different bitmaps for different screen sizes.

    Quote Originally Posted by ginnixcan View Post
    I researched some about hexagon drawing, mostly i saw codes using math functions, like cos and sin to draw a perfect hexagon. Does microedition library has these?
    CLDC-1.1 has floating point math; CLDC-1.0 does not. However, you don't need perfect hexagons, just symetrical ones. All that matters is that they fit together, and that you can easily work out where the centre is. Forget "perfect", and think "adequate, but works". :-) I suggest you make the top and bottom flat, and the other sides at 45 degrees. Make them wider than they are tall.

    Quote Originally Posted by ginnixcan View Post
    Lastly, is there any document like MSDN for java microedition library so I can learn what the code does?
    Mainly, there are the javadocs. Take a look in:

    Code:
    C:\WTK2.5.2\docs\api\midp\index.html
    (or, wherever your wireless toolkit is installed). The MIDP API is pretty small, so it doesn't take a lot of reading... :-)

    There are lots of optional extra APIs (SVG, 3D Graphics, Multimedia, Location Services, etc.), which I suggest you ignore. You can do everything you want just with regular MIDP stuff, so keep what you need to learn to a minimum. If you're going to attempt the Bluetooth two-player stuff, you'll need to use the Bluetooth API (also known as JSR82), but worry about that later.

    Cheers,
    Graham.

Similar Threads

  1. Anrufen Online - Massive Multiplayer Symbian Online Game
    By zdrawde in forum News and Announcements
    Replies: 10
    Last Post: 2009-08-10, 07:06
  2. Replies: 3
    Last Post: 2005-01-09, 17:31
  3. Replies: 6
    Last Post: 2004-09-17, 14:04
  4. Replies: 12
    Last Post: 2003-10-25, 12:15
  5. SMS time stamp format with time zone parameter?
    By turunhe in forum General Messaging
    Replies: 1
    Last Post: 2002-06-11, 07:00

Posting Permissions

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