Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (606)
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 3252 times)
0 Members and 1 Guest are viewing this topic.
Offline wessles

JGO Wizard


Medals: 79
Projects: 4
Exp: 3 years


Radirius Games


« Reply #30 - Posted 2013-07-24 22: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: 143
Projects: 4
Exp: 3 years



« Reply #31 - Posted 2013-07-24 23:03:59 »

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

JGO Wizard


Medals: 79
Projects: 4
Exp: 3 years


Radirius Games


« Reply #32 - Posted 2013-07-24 23: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: 324
Projects: 11
Exp: 3 years


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


« Reply #33 - Posted 2013-07-24 23: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?

Offline wessles

JGO Wizard


Medals: 79
Projects: 4
Exp: 3 years


Radirius Games


« Reply #34 - Posted 2013-07-24 23: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: 324
Projects: 11
Exp: 3 years


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


« Reply #35 - Posted 2013-07-24 23: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.

Offline wessles

JGO Wizard


Medals: 79
Projects: 4
Exp: 3 years


Radirius Games


« Reply #36 - Posted 2013-07-25 00: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: 324
Projects: 11
Exp: 3 years


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


« Reply #37 - Posted 2013-07-25 00: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.

Elsealabs (20 views)
2014-12-28 10:39:27

CopyableCougar4 (21 views)
2014-12-28 02:10:29

BurntPizza (25 views)
2014-12-27 22:38:51

Mr.CodeIt (15 views)
2014-12-27 04:03:04

TheDudeFromCI (20 views)
2014-12-27 02:14:49

Mr.CodeIt (26 views)
2014-12-23 03:34:11

rwatson462 (60 views)
2014-12-15 09:26:44

Mr.CodeIt (48 views)
2014-12-14 19:50:38

BurntPizza (98 views)
2014-12-09 22:41:13

BurntPizza (116 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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