Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (76 views)
2013-05-17 21:29:12

alaslipknot (87 views)
2013-05-16 21:24:48

gouessej (117 views)
2013-05-16 00:53:38

gouessej (112 views)
2013-05-16 00:17:58

theagentd (123 views)
2013-05-15 15:01:13

theagentd (112 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (177 views)
2013-05-12 15:36:09

UnluckyDevil (185 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.153 seconds with 21 queries.