Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Moveing problem in 2D Game  (Read 753 times)
0 Members and 1 Guest are viewing this topic.
Offline kns5498

Senior Newbie





« Posted 2013-03-04 13:10:35 »

(Sorry, I'm bad English. Please So you understand me.  but, what corrected tell me.)
(미안해, 내가 영어를 잘못해. 그래서 너희들이 이해해줘 부탁해. 하지만 고쳐야 할 것이 있다면 나에게 말해줘)

Hi! I'm making the 2D Game. Making Game start to know a little.
안녕! 나는 2D게임을 만들고 있는 중이야. 게임 만드는 것이 처음이라 많이 모르니 많이 알려줘

Problem is move problem in making game. Look at the Image.
문제는 내가 만드는 게임에 이동에 대해서야 밑에 그림을 봐





In the Image, Virus Card should go to point out green color.
이 그림에 Virus 라는 카드가 갈 곳을 초록색 부분으로 가리키고 있어.




but, It is top, bottom or in very side that can't go to point out green color.
(In other words, Virus Card can't go in write background .)
하지만 이 카드가 맨 위, 맨 밑, 맨 옆에 있으면 가지 못하는 초록색 부분을 가리키게 되버려

So, Green color(place) don't visible  according to Virus Card of X value or Y value at write background, I'd make what Virus Card don't go Write background and only black background.
그래서 이 부분에 저 Virus 카드의 X,Y값에 따라 초록색 부분이 못나오게 하고, 그 부분으로는 갈 수 없게 만들고 싶어.

But, I'm short a little knowing.  I’m not sure (about) what to do. Good idea tell me. plaese.
하지만 아직 내 실력으로는 부족해서, 어떻게 해야 할지 모르겠어, 좋은 방법 있으면 알려줘.

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  
//Setting code skip

public class Windows {  
   static JPanel move_N;
   static JPanel move_S;
   static JPanel move_E;
   static JPanel move_W;
   static JPanel Virus;  
   GamePlay GP = new GamePlay();

   //Setting code skip
 
   static class GamePlay{
      public void main(String arg[]){
         
      }      
      public void play(){
         move_N.setLocation(Virus.getX(), Virus.getY()-95); //top side
        move_S.setLocation(Virus.getX(), Virus.getY()+95); //botton side
        move_E.setLocation(Virus.getX()+95, Virus.getY()); //right side
        move_W.setLocation(Virus.getX()-95, Virus.getY()); //left side
        move_N.setVisible(true);
         move_S.setVisible(true);
         move_E.setVisible(true);
         move_W.setVisible(true);
         Virus.setVisible(true);        
      }
      public void moveEvent() {        
            move_N.addMouseListener(new MouseAdapter() {            
               public void mouseClicked(MouseEvent e) {                  
                  move_N.setLocation(0, 0);  //top side
                 move_S.setLocation(0, 0); //botton side
                 move_E.setLocation(0, 0); //right side
                 move_W.setLocation(0, 0); //left side
                 move_S.setVisible(false);
                  move_E.setVisible(false);
                  move_W.setVisible(false);
                  Virus.setLocation(Virus.getX(), Virus.getY()-95);
                  Virus.setVisible(true);
                  return;
               }
            });      
         }
     
   }
   
   private void initialize() {      
     
      move_N = new JPanel();
      //Setting code skip

      move_E = new JPanel();
      //Setting code skip

      move_W = new JPanel();
      //Setting code skip

      move_S = new JPanel();      
      //Setting code skip
     
      Virus = new JPanel();
      //Setting code skip
     Virus.addMouseListener(new MouseAdapter() {        
         public void mouseClicked(MouseEvent arg0) {            
               GP.play();
               GP.moveEvent();
         }
      });
     
               
   }
}
Offline MindOfCorruption97

Senior Newbie





« Reply #1 - Posted 2013-03-05 03:32:10 »

미안해, 나가 한국말로 잘 못해요.
(Sorry, I can't speak korean that well)

프로그래밍 해 봤나?
(Have you programmed before?)

프로느래밍 해면, 몇 번?
(If you have, how many times?)

Chaos is Beatiful...
For without Chaos the world will never spin...
Offline ReBirth
« Reply #2 - Posted 2013-03-05 03:47:34 »

1) please correct the code tag
2) I won't talk about using JPanel for each game objects (especially when they are just tile) Grin but you can check for black area with
1  
isVisible()
method.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kns5498

Senior Newbie





« Reply #3 - Posted 2013-03-05 04:31:00 »

a few times. and making game make first time.
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #4 - Posted 2013-03-05 08:42:36 »

바이러스 카드가 녹색 광장을 찾을 수없는 문제인가요?
(Is your problem that the virus card can't find the green square?)
Got it off Google Translate  Cool

Smiley
Offline ReBirth
« Reply #5 - Posted 2013-03-05 08:45:54 »

Quote
So, Green color(place) don't visible  according to Virus Card of X value or Y value at write background, I'd make what Virus Card don't go Write background and only black background.
그래서 이 부분에 저 Virus 카드의 X,Y값에 따라 초록색 부분이 못나오게 하고, 그 부분으로는 갈 수 없게 만들고 싶어.
I think the prob is the virus walks in green tiles (like usual tile based game) but can only land to black tile (assuming the white is pit or hole).

Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #6 - Posted 2013-03-05 08:47:01 »

So it can only land on a black square? But when?
EDIT: I think I understand. You want to land on the green square, but it lands on the black instead.
편집 : 나는 이해할 것 같아요. 당신은 녹색 광장에 착륙하려는 대신 검은 색에이 땅.

That is easily fixed. (Please correct me if I am wrong  Grin)

You would have a class called Square. That class would then be made into BlackSquare etc.
In your Square Class, you would have a variable like x, y. You would then have a class for Virus. You would then have a class/method to check if Virus.x is equal to BlackSquare.x etc.
I have made something to the extent here.
[Korean]
그 쉽게 고정됩니다. (내가 잘못 오전 있으면을 수정하십시오)
  당신은 스퀘어라는 클래스를해야한다. 그 클래스는 BlackSquare 등을 만들 수 것입니다
귀하의 광장 클래스에서 X, Y와 같은 변수를해야한다. 그런 다음 바이러스에 대한 수업을해야한다. Virus.x이 BlackSquare.x 등으로 동일 경우 다음 클래스 / 방법 확인하는 것이다
여기서 범위 무언가를 만들었습니다. (영어 링크)
(이것은 전체 설명입니다)
[/Korean]

Smiley
Offline kns5498

Senior Newbie





« Reply #7 - Posted 2013-03-05 11:24:10 »

You are Thanks! i understand your to talk about.

But I think my mistake. I don't talk you of explained non-detail. Sorry.

However, I'm a help to made check method by masteryoom.


now I talk detail.

Black Ground(Square) is the image that JLabel(called background) using icon.

And White Ground is same image.

Virus.X or Virus.Y need to the reason why Black Ground is the image.

I'm necessary to find plxel value(width,height) of Black Ground image.

if I make bottom code, It busy the program?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
static class GamePlay{
 public void moveEvent(){
   // forward Event (when player mouse clicked forward green place)
  move_N.addMouseListener(new MouseAdapter() {            
      public void mouseClicked(MouseEvent e) {
         if(!(Virus.getY()<=123)){ // Virus Card is't the top, when forward not white background
           Virus.setLocation(Virus.getX(), Virus.getY()-95); // Virus forward
           Virus.setVisible(true); // respring
        }
 }
}


I think it to busy processing of program.

So, how to do?

And I think the same as Green Color place problem.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (12 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!