Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: While loop on: 2012-01-06 18:25:51

1  
2  
3  
4  
5  
public static final int GAME_STARTING = 1;
public static final int GAME_PLAYING = 2;
public static final int GAME_OVER = 3;

private int gameState = GAME_STARTING;


Then set that variable whenever you transition from one game state to another.
I don't get it..? Example if i put gameState = GAME_PLAYING in the graphics part i showed and put when pressing R gameState = GAME_PLAYING, it doesnt work?
2  Game Development / Newbie & Debugging Questions / While loop on: 2012-01-06 17:55:25
I have an applet. I'm trying to add restart possibility to my game. I have currently two classes. Window and Snake.
Windows class's draw:

  
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
 public void paint(Graphics g) {
        super.paint(g);

        if (inGame)
        {
            g.drawImage(apple, apple_x, apple_y, this);

            for (int z = 0; z < dots; z++) {
                if (z == 0)
                    g.drawImage(head, x[z], y[z], this);
                else g.drawImage(cube, x[z], y[z], this);
               
               
            }
           
           g.setColor(Color.YELLOW);
           g.drawString("Points " + points, 5, 15);
           
          Toolkit.getDefaultToolkit().sync();
          g.dispose();      
         
       }else{
        gameOver(g);
       }
       
    }


In the beginning I make int variable counter that equals to 1. Where I put the code that is while (counter < 2){}? When you die, it sets counter to 3 and in KeyEvent when i press R it makes counter 1 again.

Currently, when i start it only grey box shows up.

Also, how can i play this applet on mobile phone?

EDIT: Sry for the spoiler, didnt know what it looks like since my mozilla has been buggin lately, and didnt know about the code thing. Thanks (:
3  Games Center / Archived Projects / Snake on: 2012-01-06 16:21:19
This is just a normal snake game what all of you have played. Just made it to try out stuff. Please, if you find anysort of bugs, post them here.


You control a snake. Your job is to collect "apples". You get one point each time you collect a red "apple" and grow. You die if you collide with yourself or go outside room.

Controls:
Arrowkeys

And if anyone want this to be webstart, please tell me how to do it. Currently it's only downloadable.

Download
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (12 views)
2014-04-15 18:08:23

BurntPizza (11 views)
2014-04-15 03:46:01

UprightPath (24 views)
2014-04-14 17:39:50

UprightPath (10 views)
2014-04-14 17:35:47

Porlus (27 views)
2014-04-14 15:48:38

tom_mai78101 (49 views)
2014-04-10 04:04:31

BurntPizza (108 views)
2014-04-08 23:06:04

tom_mai78101 (208 views)
2014-04-05 13:34:39

trollwarrior1 (176 views)
2014-04-04 12:06:45

CJLetsGame (182 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!