Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Game static enemy question

  1. #1
    Member
    Join Date
    Jan 2013
    Posts
    31
    My Mood
    Confused
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Game static enemy question

    So, we are making a 2D game in java and here's a question:
    Any idea as to how i could go about it?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game static enemy question

    What is a "static enemy"?
    Are you talking about the static modifier for java variables and methods?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Game static enemy question

    Quote Originally Posted by hemla View Post
    So, we are making a 2D game in java and here's a question: To add a static enemy that causes damage to the player on contact.
    Any idea as to how i could go about it?
    I'm not 100% clear on the question, but if you're talking about creating an object and assigning it to a static variable, I've a simple answer: don't. Limit your use of static anythings to the bare minimum and only where it should be used. This isn't one such situation.

  4. #4
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Game static enemy question

    If you're talking about something like, say, cactus (object, that stands always on place, but is dangerous), than you have, firstly, to implement a collision manager (a thing, which you will use to detect collisions between objects). Than, on collision, you reduce player's health.
    Btw, if the collision manager is already embedded to your engine, than you can just use it, without implementing one by yourself.

Similar Threads

  1. Replies: 4
    Last Post: November 15th, 2012, 12:09 AM
  2. Call without being static? [Question]
    By beennn in forum Java Theory & Questions
    Replies: 4
    Last Post: October 31st, 2012, 03:24 PM
  3. collision between player and enemy
    By hwoarang69 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 24th, 2012, 08:43 AM
  4. Replies: 1
    Last Post: April 3rd, 2012, 06:32 AM
  5. Replies: 10
    Last Post: September 6th, 2010, 04:48 PM