Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  [SOLVED by RobinB]How to check if an object is not itself?  (Read 2494 times)
0 Members and 1 Guest are viewing this topic.
Online wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #30 - Posted 2013-07-25 00:44:09 »

EVERYONE!
LOL
I can't believe no one said this... And I am surprised I even thought about this for more than 2 seconds.
ALL YOU HAVE TO DO IS:
1  
2  
if(!zombie.equals(this))
    do crap;

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #31 - Posted 2013-07-25 01:03:59 »

No one said that because there's no reason you would ever need to do that...
Online wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #32 - Posted 2013-07-25 01:18:42 »

If you look at the title, that is a reason  Grin

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

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #33 - Posted 2013-07-25 01:23:29 »

If you look at the title, that is a reason  Grin

Yes, but if I ask "How do I make a game without a game loop?", are you going to tell me how to do that, or are you going to tell me that I shouldn't be doing it that way?

Online wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #34 - Posted 2013-07-25 01:25:25 »

If you look at the title, that is a reason  Grin

Yes, but if I ask "How do I make a game without a game loop?", are you going to tell me how to do that, or are you going to tell me that I shouldn't be doing it that way?

I think you meant

Quote
or are you going to tell me why I shouldn't be doing it that way?

Why shouldn't I do it? Inefficient? What?

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #35 - Posted 2013-07-25 01:32:08 »

-snip-
Why shouldn't I do it? Inefficient? What?
(Assuming you're referring to your collision code:)
You're checking every possible collision twice!

(If you're referring to your solution:)
"!=" works fine, as long as it's the same object. If it's not the same object... you have a problem.
!.equals() is a method which usually involves a few if() statements, and so will take more proccessing power then !=, which is only checking if both pointers are the same. However, the difference is tiny, and is not going to be something you need to change.

But either way, the collision detection should be done outside of the zombie class, which is what most people were telling you.

Online wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #36 - Posted 2013-07-25 02:40:25 »

Ok, should I have a Collisions class? Just go through every single object and check?
I'm going to try it, but tell me if I am approaching it the wrong way.

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #37 - Posted 2013-07-25 02:43:32 »

Someone has already posted:

Look at this:
(This does not go inside the zombie class ofcourse)

1  
2  
3  
4  
5  
6  
7  
for(int zom = 0; zom < getWorld().getZombies().size(); zom++) {
    for(int zom2 = zom+1; zom2 < getWorld().getZombies().size(); zom2++) {
        Zombie zombie1 = getWorld().getZombies().get(zom);
        Zombie zombie2 = getWorld().getZombies().get(zom2);
        //Collision stuff
   }
}

                                           

Pages: 1 [2]
  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.

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

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

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

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (55 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
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!