Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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] 2 3
1  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-19 19:46:56
I have understand the general sense but pop of the queue is done every time move is called , so if  my enemy speed is 1 and a tile is longer when i call moveChar the second time the target is the third tile but enemy is still in the first...
2  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-19 15:06:05
So breadth first work and the path is correct but i've problem to move enemy following path ....
I follow this tutorial : http://www.tonypa.pri.ee/tbw/tut22.html
But it don't convince me ... because if moveChar is called every Frame , and we assume that path have 6 tile and every tile is 20 pixel and my enemy's speed is 2pixel  after 6 frame path array is empty but the enemy is moved only for 12pixel , not only if in the third tile for example enemy must climb up on a stairs , he is moved for only 6 pixel and so he cannot be in the right tile(the stairs tile)....
3  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-16 15:13:51
yes .... it control when move the sprite right or left if it is out of edge... every Tile have some states for example walkable (true or false) ladder (true or false) ecc ecc ..
4  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-16 14:17:00
Not so difficult, guy Cheesy.... I have a simple tile based game , and there is no jump the only thing to consider is the gravity , so  enemy mustn't fly and for increase his y cordinate he must climb a stair...
So I've look to a tutorial about Breath First ... but it is for a tile based game without gravity and is very expensive calculate a path every gameloop's cycle...
5  Discussions / General Discussions / PathFinding with gravity on: 2013-09-12 16:50:57
Hi ,
it's the first time that I must handle this argument ... so I have seen some tutorial about pathfinding , but nothing with gravity ... Some links??
6  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-09-10 22:03:29
Nono , it was just for curiosity , Thanks Several  Grin
7  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-09-02 16:40:55
Hi , casually I have find a bug in this code I don't know why but  if I set the a too little size the problem return!
So i post an image for example :
Size 120 , 120  http://imageshack.us/photo/my-images/825/ne6c.png/
Size 100 , 100  http://imageshack.us/photo/my-images/819/1i1o.png/
so smaller size = more large gap
8  Game Development / Newbie & Debugging Questions / Re: AddKeylistener() Kevin Glass' code problem on: 2013-08-27 21:16:15
Yes now work .... Thanks at all ...
9  Game Development / Newbie & Debugging Questions / Re: AddKeylistener() Kevin Glass' code problem on: 2013-08-26 19:16:13
No it's ok ... I have find the problem the code work only if i click  into a windows... I don't know why...
10  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-08-26 18:18:29
Yeah ! Work ! Thanks  Grin
11  Game Development / Newbie & Debugging Questions / Re: AddKeylistener() Kevin Glass' code problem on: 2013-08-26 18:15:05
Thanks a lot !
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  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferStrategy;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JPanel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author FEDERICA
 */

public class GameView extends Canvas {
    private BufferStrategy strategy;
    private boolean gameRunning=true;
    private Room room = new Room();
    private RunnerEntity runner;
   
public GameView(){
    //System.out.println("hey");
   JFrame container= new JFrame("Loderunner");
    JPanel panel= (JPanel) container.getContentPane();
    panel.setPreferredSize(new Dimension(460,460));
    panel.setMinimumSize(new Dimension(460,460));
    panel.setLayout(null);
    setBounds(0,0,460,460);
    panel.add(this);
    setIgnoreRepaint(true);
    requestFocus();
    addKeyListener(new KeyHandle());
    container.pack();
    container.setVisible(true);
    container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    createBufferStrategy(2);
    strategy=getBufferStrategy();
    loadLevel("level.txt");
}

public Room getRoomGame(){
    return room;
}

public void loadLevel (String ref){
    try{
       
       File file = new File(ref);
            Scanner load = new Scanner(file);
       for(int i=0;i<20;i++){
       for(int j=0;j<20;j++){
            int n= load.nextInt();
                 if(n==0) room.getList().add(new Block("tileset_green.png",j*23,i*23));
                 if(n==1) room.getList2().add(new Block("tileset_ladder.png",j*23,i*23));
            if(n==2) runner= new RunnerEntity("runner.png",j*23,i*23-13);//for now
                }
       }
    }catch(FileNotFoundException e){ System.out.println("Error");}
}

public void draw(Graphics2D g){
   room.draw(g);
   runner.draw(g);
}

public void move(){
    runner.move();
}

public void gameLoop(){
    while(true){
        Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0,0,460,460);
        move();
        draw(g);
        g.dispose();
        strategy.show();
        try{Thread.sleep(10); } catch (Exception e) {}
    }
}

public static void main (String args[]){
    GameView g = new GameView();
    g.gameLoop();
}

private class KeyHandle extends KeyAdapter {
   
    public void KeyPressed(KeyEvent e){
    System.out.println("hey");
    if(e.getKeyCode()==KeyEvent.VK_G){
        System.out.println("hey");
        runner.setRunning(true);
        runner.setDX(1);
    }
       
    }
   
    public void KeyReleased(KeyEvent e){
   
    if(e.getKeyCode()==KeyEvent.VK_LEFT){
        runner.setRunning(false);
        runner.setDX(0);
    }
    }
       
    }
   
}
12  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-08-26 18:06:32
According to IDE the method setResizable(false)  dosn't exist for a jpanel...
13  Game Development / Newbie & Debugging Questions / Re: AddKeylistener() Kevin Glass' code problem on: 2013-08-26 18:04:20
GameView extends Canvas like in the tutorial ...  so i try with container and panel but nothing.... No one print of System.out.println() .....  Shocked
14  Game Development / Newbie & Debugging Questions / AddKeylistener() Kevin Glass' code problem on: 2013-08-26 17:30:46
Hi !
I believe that you hate me in this community  Grin so whats the problem ?? Pratically I don't know why  the keylistener doesn't work ..
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public GameView(){
    //System.out.println("hey");
   JFrame container= new JFrame("Loderunner");
    JPanel panel= (JPanel) container.getContentPane();
    panel.setPreferredSize(new Dimension(460,460));
    panel.setMinimumSize(new Dimension(460,460));
    panel.setLayout(null);
    setBounds(0,0,460,460);
    panel.add(this);
    setIgnoreRepaint(true);
    requestFocus();
    addKeyListener(new KeyHandle());
    container.pack();
    container.setVisible(true);
    container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    createBufferStrategy(2);
    strategy=getBufferStrategy();
    loadLevel("level.txt");
}

This class is in GameView class
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
private class KeyHandle extends KeyAdapter {
   
    public void KeyPressed(KeyEvent e){
    System.out.println("hey");
    if(e.getKeyCode()==KeyEvent.VK_LEFT){
        System.out.println("hey");
        runner.setRunning(true);
        runner.setDX(1);
    }
       
    }
   
    public void KeyReleased(KeyEvent e){
   
    if(e.getKeyCode()==KeyEvent.VK_LEFT){
        runner.setRunning(false);
        runner.setDX(0);
    }
    }
       
    }
   
}

I put some System.out.println but if i press left they print nothing , so i believe that the problem is in the costructor ...
15  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-08-26 17:11:26
Thanks for answer , take patience... Now the window have right dimension , but I can resize it , and I don't want this ...
This is my code ...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
JFrame container= new JFrame("Loderunner");
    JPanel panel= (JPanel) container.getContentPane();
    panel.setPreferredSize(new Dimension(460,460));
    panel.setMinimumSize(new Dimension(460,460));
    panel.setLayout(null);
    setBounds(0,0,460,460);
    panel.add(this);
    setIgnoreRepaint(true);
    requestFocus();
    addKeyListener(new KeyHandle());
    container.pack();
    container.setVisible(true);
    container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    createBufferStrategy(2);
    strategy=getBufferStrategy();
    loadLevel("level.txt");
}

What I must do??
P.S. What's is the wrong tutorial ?? because I have other problem with kevin glass' code ...
16  Game Development / Newbie & Debugging Questions / Re: Painting problem again on: 2013-08-26 08:28:35
So, with setResizable(true) actually work , but I don't want that the frame is Resizable ... and I take this code from space invaders 101 by Kevin Glass....How is possible that it is  wrong??
Also here in a jgo tutorial : http://www.java-gaming.org/topics/basic-game/21919/view.html
17  Game Development / Newbie & Debugging Questions / Painting problem again on: 2013-08-25 22:11:55
Hi! I don't know if I've some system's problem or other ....
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public GameView(){
    JFrame container= new JFrame("Loderunner");
    JPanel panel= (JPanel) container.getContentPane();
    panel.setPreferredSize(new Dimension(460,460));
    panel.setLayout(null);
    setBounds(0,0,460,460);
    panel.add(this);
    setIgnoreRepaint(true);
    container.pack();
    container.setResizable(false);
    container.setVisible(true);
    container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    requestFocus();
    createBufferStrategy(2);
    strategy=getBufferStrategy();
    loadLevel("level.txt");
}

and this is the game loop
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public void gameLoop(){
    while(true){
        Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
        g.setColor(Color.BLACK);
        g.fillRect(0,0,460,460);
        //draw(g);
       g.dispose();
        strategy.show();
    }
}

http://imageshack.us/photo/my-images/23/rqs3.png/ in this link there is the screenshot of my pc so you can see that java don't paint a  part of window
18  Game Development / Newbie & Debugging Questions / Re: paintComponent() good standars' programming on: 2013-08-21 22:46:48
Quote
The idea is to separate your game's logic from painting the game,
Yes this is the logic's advice.. so thank at all ... Grin
19  Game Development / Newbie & Debugging Questions / paintComponent() good standars' programming on: 2013-08-21 09:02:29
Hi ,
This is my question , for example I would create a game , and would paint when I win a match a screen with "You win" , generally I, for do this, use a boolean variable in paintComponent method :
1  
2  
3  
public void paintComponent(Graphics g){
      if(game_is_running) // paint the game state
     else // paint the screen with the string "you have win "

With this approach all work , but I've read on web that into paintComponent must not use boolean variable  because paintComponent must paint only the game state.... So I don't know how...
20  Game Development / Newbie & Debugging Questions / Re: Width and Height of a Jpanel on: 2013-08-14 17:37:19
No , I set the screen like 180X180 and i ve an image 20X20 pixel , I move the image on the screen ... when x of image is 160 = panelsize(180)-widthofobject(20) i set x=160 so in this way  the image should stay in the window... Instead  overstep the window...
21  Game Development / Newbie & Debugging Questions / Re: Width and Height of a Jpanel on: 2013-08-14 17:18:07
Someone could help me ??
22  Game Development / Newbie & Debugging Questions / Width and Height of a Jpanel on: 2013-08-13 21:00:10
Hi , i've a problem with the collision  with Panel borders ....
I post a  part of code for every class :
in main class:
1  
2  
3  
4  
 
GamePanel_1 g = new GamePanel_1();
add(g);
pack();

in Panel class:
1  
2  
3  
 
public static Dimension size= new Dimension(180,180);
setPreferredSize(size);

in a other class:
1  
2  
3  
4  
5  
if(x>160){
collide=true;
isrunning=false;
x=160;
}

160 is a number calculate like the width of the panel set with setpreferredsize minus the width of my image (20 pixel), the problem is that is like if the panel  haven't the size that I've set and so the collision don't work well
23  Game Development / Newbie & Debugging Questions / Re: Repaint() don't call PaintComponent() on: 2013-08-09 22:30:30
Oh man , yes  Grin...
No i use Textpad nothing IDE ..
24  Game Development / Newbie & Debugging Questions / Repaint() don't call PaintComponent() on: 2013-08-09 20:34:48
Hi , post simple code , i have put in PaintComponent() a System.out.println() to see if enter in the  code when i call repaint() and the answer is no , so repaint don't call PaintComponent() why??:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
import javax.net.ssl.KeyManager;
import javax.swing.JFrame;
import java.awt.GridLayout;

public class Frame extends JFrame{



    public Frame(){
       GamePanel g = new GamePanel();
       add(g);
       setTitle("Frame");
       setSize(200,200);
       setResizable(false);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setVisible(true);
    }

    public static void main(String[] args) {
        Frame F= new Frame();
    }
}


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  
27  
28  
29  
30  
31  
32  
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class GamePanel  extends JPanel implements Runnable{

public static Thread thread;


public GamePanel(){
    setBackground(Color.WHITE);
    thread=new Thread(this);
    thread.start();
}

public void PaintComponent(Graphics g){
   System.out.println("into");
   g.setColor(new Color(100,100,100));
   g.fillRect(0,0,100,100);
}

public void run(){
   while(true){
   repaint();
   try{
   thread.sleep(1000);
   }catch(InterruptedException e){}
   }
}


}
25  Game Development / Shared Code / Re: Connect4 my first something on: 2013-08-02 21:15:46
Quote
He's just very polite, knows how to speak English, is a nice person and really deserved to be one of the moderators Wink
Here's some love for Jimmt:  Kiss  Tongue
Hey guys ! I don't discredit Jimmt ...
So it's all ok ...  Grin
26  Game Development / Shared Code / Re: Connect4 my first something on: 2013-08-01 09:15:28
Ok ,
I am only astonished about Jimmt , so I know that was almost impossibible enter in a software house especially for a italians , but so i have lost every hope...
27  Game Development / Shared Code / Re: Connect4 my first something on: 2013-07-31 20:19:46
Yes , I know , but the advantage is relevant .... It's normal that when I was 15-year don' t have start with this is all in english, and  I know only " the pen is on the table".
28  Game Development / Shared Code / Re: Connect4 my first something on: 2013-07-31 19:27:43
For english people are all easier , they know english and could study good tutorial ....
So is terrible , pratically ... Is impossible for me and my friend find job in europe if you are all  so ...
For example almost nobody of my course is able to do a game ...
29  Game Development / Shared Code / Re: Connect4 my first something on: 2013-07-31 18:14:49
Quote
I'm a high school sophmore
What a f**k Huh You are so young and is a JGO Wizard  ... Italian school are really terrible... Emo
30  Discussions / General Discussions / Re: Models programming on: 2013-07-31 18:08:46
I know basically like work Java I ' ve study on the book of Tannembauw at university , and thread i think that are more near with MIC-3 and pipeline system..
However i decided to try with tread to read something tutorial in italian my language .. In english i became crazy  Grin
Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!