Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
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   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: Java 2D collision detection on: 2012-08-15 15:37:58
Ok I tried to fix this. It is a code:
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  
public void checkcoll(){
      if (MemoryCollision == null){
         System.out.println("LASD");
         if(blocks.size() != 0){
            for (int i=0; i<blocks.size();i++){
               if(hero2.hero.intersects(blocks.get(i))){
                 
                  MemoryCollision = blocks.get(i);
                 
                  if(Movement.up == true){
                     Movement.Speed = 0;
                     Movement.isCollUp = true;
                     Movement.up = false;                  
                     break;
                  }
                  if(Movement.down == true){
                     Movement.Speed = 0;
                     Movement.down = false;
                     Movement.isCollDown = true;
                     break;
                  }
                  if(Movement.left == true){
                     Movement.Speed = 0;
                     Movement.left = false;
                     Movement.isCollLeft = true;
                     
                  }
                  if(Movement.right == true){
                     Movement.Speed = 0;
                     Movement.right = false;
                     Movement.isCollRight = true;
                     break;
                  }
               }
            }
         }
      }
     
      if (MemoryCollision != null){
System.out.println("Parameters: " + MemoryCollision"); //This method showing only this the if statement don't working.
         if(!hero2.hero.intersects(MemoryCollision)){ //Here is problem, this method don't checking if character don not colliding with this 1 object.
            Movement.isCollUp = false;
            Movement.isCollDown = false;
            Movement.isCollLeft = false;
            Movement.isCollRight = false;
            MemoryCollision = null;
         }
      }
   }


So I made that when character collide with 1 of the objects, this 1 object parameters going to the memory and I stoping checking for collision. And then I only checking if character stop colliding with this object if yes then I resuming the movement that character can move if no I resuming checking that character not colliding with this object. Thanks for any help.
2  Java Game APIs & Engines / Java 2D / Re: Java 2D collision detection on: 2012-08-14 09:56:38
So where I can put this code which resuming the movement. Because I know what you mean but I don't know where I can put this code to resume the movement. I don't have any idea. For help big thanks.
3  Java Game APIs & Engines / Java 2D / Re: Java 2D collision detection on: 2012-08-13 14:22:07
I do not know to to explain you this but if you can download the project and run him and you will see whats happening when character colliding with wall. I tried many ways to make this work, and finally I found this forum.
Yeah I tried setting up speed to 0 but this don't work, character just passes through the wall slowly.
Please check the project if you can then you will see what happening. Thanks for any advice.
4  Java Game APIs & Engines / Java 2D / Re: Java 2D collision detection on: 2012-08-13 14:12:59
Main game class Game.class
http://pastebin.java-gaming.org/7508a212028

Movement.class
http://pastebin.java-gaming.org/508a1302829

Map render map.class
http://pastebin.java-gaming.org/08a1048292b

For help big thanks.
5  Java Game APIs & Engines / Java 2D / Java 2D collision detection on: 2012-08-13 12:46:55
Hi, I learning java about 5 days, and today I wanted to make a game, I stuck on collision detection in my game. If someone can take a look on source code I will be appreciate. Already I made the collsion "system" but character just only slowing the move when it colliding and do not stop as I want. Colliding system is based on Rectangles and intersects.

Its a link for source code for my game http://www.mediafire.com/download.php?wlk8dh1a4v8axfm


Ps
I'm new on this forum and If you wrote something wrong in my post or put this post in wrong place just say and I will fix this. Thanks.

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.

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

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

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

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

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

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

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

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

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

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

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

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

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
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!