Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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  Game Development / Newbie & Debugging Questions / Re: Mouse over tooltips on: 2013-01-04 20:53:14
That's what I was asking, if there was anything that did tooltips already in java. Could you give me a real simple tooltip with swing? I don't know where to start looking and I know there's a lot of stuff that goes into swing programming. Or if you know of a good tutorial, let me know. Thanks
2  Game Development / Newbie & Debugging Questions / Re: Mouse over tooltips on: 2013-01-03 08:30:52
Well.... I'm glad I only have 40 or so rectangles because I understood very little of what you said  Tongue

My game is going to be a simple one, so hopefully I can slowly work up to that kind of complexity. Some day though  Cheesy

Good new is I've gotten tooltips working on a couple of elements already. I've made it so it picks the background box based on the number of lines in the text, but it still doesn't look as good as I would like. Would there be a relatively easy way to make the box fit to the tooltip? Right now I just have the tooltip box as a sprite that is pulled like the rest of the graphics in the game and I have one for a tooltip with 1, 2, 3, 4, 5, or 6 lines. It chooses the right one based on the number of \n characters in the string. Is there a better way to do it? One that I'll hopefully understand?
3  Game Development / Newbie & Debugging Questions / Re: Mouse over tooltips on: 2013-01-02 22:46:29
Efficiency? How many thousands of rectangles are you planning to do hit testing on?

So what you're saying is it doesn't matter right now?

lol, probably just 30-40 rectangles for the UI. For some reason efficiency is always on my mind when I'm programming. Just trying to build good habits for when I am doing a thousands of rectangles Smiley It never hurts to start good practices early.
4  Games Center / WIP games, tools & toy projects / Re: Tower of the Deathmaster on: 2013-01-02 21:33:35
So after a couple plays, I've determined that you can't get to level 10 unless there's something I don't know. I had everything cleared out up to level 9, I had over 1000 atk and 250 ish defense and 10K health, but the only enemy left was the soul knight which has 3400 def. As far as I can tell, there's no way to get that high of attack with what's available. Even if I could kill the soul knight, I don't see any way of going up to level 10 after he's dead.

Other than that, I really liked the game. You really need to consider your options because each decision will affect how far you can get. The difficulty curve is kind of odd. The beginning is pretty hard because you don't really know what your doing. Once you get the hang of the game, the curve continues how I would expect. But after a couple of floors, all of the enemies drop enough xp and gold to make the rest of the game pretty easy. Then the only enemy left is the soul knight which I don't know how you could kill. The difficulty curve needs to be smoothed out a bit. I think it was floor 8 or 9 there were a bunch of gold coins in one room that made you pretty hard to kill once you spent them. That along with all of the gold/xp that the monsters in that room dropped.

Another little thing: I was getting tired of going back down to the stores to spend my gold/xp. Maybe once you shop at them once you can open them up where ever.

And it doesn't really explain what it means when it says you can open a lava entrance (something like that when you rescue the dude). Unless this is for something later in the game that hasn't been implemented yet. If it is used in this part of the game, more clues on how to use it would be nice because I have no idea what it's for.
5  Game Development / Newbie & Debugging Questions / Re: Mouse over tooltips on: 2013-01-02 19:26:20
Ok, that makes more sense. I thought there was a java class that he was talking about that I didn't know about. I was kind of hoping there was because I wanted some prebuilt class to handle everything  Tongue

This is similar to what I was originally thinking needed to be done, except I was going to use the Rectangle class and use cointains(Point p) method to determine if the mouse is inside any of the areas. Would this run slower than the code you posted Peter?
6  Games Center / WIP games, tools & toy projects / Re: Tower of the Deathmaster on: 2013-01-02 08:51:06
game only loaded once. When i got stuck and tried to play again, it never loaded. is there another place I could try this out? I like the concept and want to play some more.
EDIT: had to close browser and re open for it to load again.

Pretty much the same complaints as others, but I'll list them out anyways:
  • hard to find your character each level
  • It should show how much stronger an enemy is so you know when you can go back and kill it
  • There should be a way to get stronger besides picking up the items. This would cut down on getting stuck, so you could get stronger then kill new monsters opening up more areas and keys
7  Game Development / Newbie & Debugging Questions / Re: Mouse over tooltips on: 2013-01-02 07:15:50
I think I only have one component right now that has everything in it. All of the graphics are handled as one and displayed on one canvas. I don't really know how to use your suggestion.

This is my first project, so the whole window and display functionality was copied from an example I found so I don't really understand it fully or know how I would go about changing it. I guess a better question would be for a tutorial on basic UI implementation because it's sounding like the way I did it isn't the right way.
8  Game Development / Newbie & Debugging Questions / Mouse over tooltips on: 2013-01-02 06:16:36
What would be the best way to implement mouse over tooltips? I've never done something like this, but my first thought was to have a rectangle for each mouse over area and use a mouse listener to determine which rectangle the mouse was in. I have a feeling this isn't the most efficient or easiest way to do it, but I'm not really sure how else to do it. Maybe use frames? I don't even know where to start looking on how to make something like this.

Here's what my UI looks like right now:
http://i.imgur.com/Cp7sZ.png

I would want to add mouse overs to each of the stats, inventory slots, equipment slots, HP/MP/XP bars. I would want the tooltip to have a border (probably just an image I would supply) and obviously some info on what your mouse is on.

Anyone have some examples of this? Or at least point me in the right direction? Thanks!
9  Game Development / Newbie & Debugging Questions / Re: ConcurrantModificationException on: 2013-01-02 05:54:40
What would be the advantage of using boolean isAlive over a remove list? As it is now, with the simple for loop and the remove list, the objects aren't removed in the hit() method, they are added to the remove list which is then handled in a different loop so the index doesn't change within a loop.

The reason I'm using 4 different arrayLists for all of the entities is because it's a part of brute force collision detection and I figured the less rectangles that needed to be compared, the easier it would be on the system. I just assumed this would make the game run faster, please correct me if I'm wrong.
10  Game Development / Newbie & Debugging Questions / ConcurrantModificationException on: 2012-12-31 05:41:36
Here's my 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  
   public ArrayList<PlayerCharacter> goodGuyEntities = new ArrayList<PlayerCharacter>();
   public ArrayList<BadGuy> badGuyEntities = new ArrayList<BadGuy>();
   public ArrayList<Shot> goodGuyShotEntities = new ArrayList<Shot>();
   public ArrayList<Shot> badGuyShotEntities = new ArrayList<Shot>();
   public ArrayList<Shot> removeList = new ArrayList<Shot>();

      for (PlayerCharacter character : goodGuyEntities) {
         character.update();
      }

      for (BadGuy badGuy : badGuyEntities) {
         badGuy.update();
      }

      for (Shot shot : goodGuyShotEntities) { // this is the line that eclipse said threw the exception
        shot.update();
         for (BadGuy badGuy : badGuyEntities) {
            if (shot.bounds.intersects(badGuy.bounds)) {
               shot.hit(badGuy);
            }
         }
      }

      for (Shot shot : badGuyShotEntities) {
         shot.update();
         for (PlayerCharacter character : goodGuyEntities) {
            if (shot.bounds.intersects(character.bounds)) {
               shot.hit(character);
            }
         }
      }

      for (Entity remove : removeList) {
         removeEntity(remove);
      }
   

This threw a ConcurrantModificationException and as far as I understand the exception, it's because I'm iterating through the ArrayLists and calling update() on each object in the ArrayList within the iteration. Is there any way to get around this besides using the traditional for loop:

1  
for(int i = 0; i < goodGuyShotEntities.size(); i++)

this fixes it but I don't like how it looks and is much harder to use and read.
11  Game Development / Newbie & Debugging Questions / Re: creating classes based on enum on: 2012-12-27 01:08:07
Wow, I just spent 10 minutes trying to explain what I wanted to do before I realized it would be waaaaay easier to put this stuff in each character class kind of like what sproingie suggested.

I still feel like I'll run into this issue at some point again (plus I'm really curious if its possible). So I'm going to try an articulate myself better this time.

So I have a class called WarriorWeapon1 and PriestWeapon1 that both extend Weapon. All level one weapons would be named in the same convention( <insert class name here>Weapon1 ). If I had a method called createWeapon(String className) how would you make it create the appropriate weapon? (I guess it doesn't have to be enum)
1  
2  
3  
4  
5  
public Weapon createWeapon(String className){
     String temp = className + "Weapon1";
     Weapon wpn = temp.createInstanceOf(); //this is obviously wrong, but can you use class loader or something?
    return wpn;
}


I've never used classLoader so I'm not even sure if that's what would be used. This is really hard to explain when I have no clue where to start coding this  Huh

Anyways, I know how to fix my original problem, but I still want to know if it's possible to do it that way because I think it would be useful. Hopefully that makes more sense because I don't know how to explain it better  Smiley
12  Game Development / Newbie & Debugging Questions / creating classes based on enum on: 2012-12-26 23:02:17
I want to use an enum type to determine which equipment needs to be equipped on character creation. The only way I see to do it now would be a switch statement and create the right equipment in each case:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public AllEquips(PlayerCharacter.Classes clazz){
      switch(clazz){
      case WARRIOR:
         weapon = new WarriorWeapon1();
         head = new WarriorHead1();
         break;
      case PRIEST:
         weapon = new PriestWeapon1();
         head = new PriestHead1();
         break;
      }
   }


Would there be a way to get a class based off of the enum passed, so I would be able to make (clazz)Weapon1. That way I would only need one block of code for all of the character classes instead of one for each.
13  Game Development / Game Play & Game Design / Re: Code is getting convoluted on: 2012-12-11 05:15:25
Hmmm.... I'll have to look up enums, I've never used them or seen them used. I don't even know what they are  Tongue Hopefully that can make my code a little better. I've got a lot of work ahead of me trying to clean up my code because I'm not sure if I would be able to finish the game as it is. Thanks everyone for the tips!
14  Game Development / Game Play & Game Design / Re: Code is getting convoluted on: 2012-12-11 01:10:03
I'm going to school to be a software engineer, but I'm just in my freshman year and I'm impatient and want to code now  Smiley

One thing that I haven't understood from my classes is the idea of having variables private and using getters and setters. I feel like the code is much easier to use when variables are public, then I can use them anywhere without calling all sorts of get methods. This might help to encapsulate parts of my code, but the way my game runs right now, I need to access variables from many classes to keep it functional. Using getters and setters feels like the same thing as public variables except it's harder to do what you want.

I'll definitely try refactoring some of my code and hopefully it'll get easier to use. One thing I have noticed that makes my code more complex is the use of HashMaps for quite a few things, like the storage of stats. I like them a lot, but now that I have a pretty large base on my game, I'm starting to lose track which keyword to use and where a hashmap is stored. This one is one that I really don't like using because I always forget what I'll get back:
1  
2  
//<equipmentName, <statName, stat>>
public HashMap<String, HashMap<String, Integer>> equipmentModifierStats = new HashMap<String, HashMap<String, Integer>>();

This is one of the few comments in my code because I always forget how this hashmap worked every time I need to use it.

Quote
try to keep clear in your mind what are the pattern that u are using to solve your problem
and when u are adding new code and u see or you have the sensation that it is not the correct place....
I do this every time I can't find a variable I need to use, but when I find it, I remember why I put it there (it'll only work in that spot, or makes more sense). Maybe I just need more practice in coding, because I'm trying to stick to a pattern, but I don't remember it every time I need to find something.
15  Game Development / Game Play & Game Design / Re: Code is getting convoluted on: 2012-12-10 20:28:34
I already have packages and classes and I feel like it's organized, but I still have to search through my classes to find certain methods and variables. For example, I'm in the process of drawing the equipment my player has equipped in the UI and it took me a few minutes to trace back through the player class and equipment class where I actually stored the equipment information. Also when I add more character classes(archer, wizard, etc) to my game, I'm going to have to go through quite a few java classes to add functionality for a new character class. I'm worried that it will be easy to miss places that I would need to add code for full functionality. Is this just inherent in bigger games?

I could upload my whole zip file project, but I feel it would be a lot to look through.
16  Game Development / Game Play & Game Design / Code is getting convoluted on: 2012-12-10 19:23:16
I'm working on a game and the code is quickly getting convoluted. I know it's because I don't have good coding habits, but I'm pretty new at game programming so what I have is the only solution that I can come up with. How should I go about cleaning it up? It's coming to the point that making any progress is a daunting task due to the amount of back tracing I need to do in my own code just to get the variable or desired behavior.

I'm not really sure how to clean it up because if I re-look at everything again, I'm just going to want to do it the exact same way because that's how it makes sense to me. Anyone else run into this problem? How did you get through it?
17  Game Development / Newbie & Debugging Questions / Re: Hashtable().put is throwing NPE on: 2012-10-18 17:07:58
wow, I'm retarded.... thank you
18  Game Development / Newbie & Debugging Questions / Hashtable().put is throwing NPE on: 2012-10-18 07:52:40
So I'm trying to make a simple game and I want the images loaded from the start so I want to create a hashtable that stores the Image with its name as the key. When I call ImageStore.get().getImage("image name") from my gameloop, I get an error when the ImageStore is initialized (shown as a comment in the 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  
public class ImageStore {

   private static ImageStore single = new ImageStore();

   public static Hashtable<String, Image> images = new Hashtable<String, Image>();

   private ImageStore() {

      BufferedImage sourceImage = null;

      String dirPath = "images";
      File imageDir = new File(dirPath);
      imageDir = new File(imageDir.toURI());
      String absoluteDirPath = imageDir.getPath();
      absoluteDirPath = absoluteDirPath.replace('\\', '/');
      imageDir = new File(absoluteDirPath);
      File[] imageFiles = imageDir.listFiles();

      if (imageFiles.length == 0)
         System.out.println("Directory empty");
      else {
         for (int i = 0; i < imageFiles.length; i++) {
            String ref = imageFiles[i].getName();
         
            try {
               sourceImage = ImageIO.read(imageFiles[i]);
            } catch (IOException e) {
               fail("Failed to load: " + ref);
            }
           
            GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
            Image image = gc.createCompatibleImage(sourceImage.getWidth(), sourceImage.getHeight(), Transparency.BITMASK);
           
            //both of these print values without problems, so neither argument
           //passed to the hashtable is null
           System.out.println(image.getWidth(null));
            System.out.println(ref);

            //getting a null pointer exception here
           images.put(ref, image);
         }
      }
   }


Also if I'm doing anything in a weird way in the code, let me know of the proper way (I'm new to game programming). Thanks in advance for any help.
19  Game Development / Newbie & Debugging Questions / Re: Lost with affine transform... on: 2012-10-15 01:34:17
Update: the affine transform was working, it was an issue with my code that always passed 0 degrees to the transform, so it looked like it wasn't doing anything. You're explanation was plenty clear, I just messed up some other code.

And I will change that line so I don't mess with the default transform.

Thanks everyone!
20  Game Development / Newbie & Debugging Questions / Re: Lost with affine transform... on: 2012-10-14 23:32:43
So, I got rid of the instanced AffineTransform and changed the draw method to:
1  
2  
3  
4  
public void draw(Graphics2D g, int x, int y) {
      g.setTransform(AffineTransform.getRotateInstance(Math.toRadians(angle), x, y));
      g.drawImage(image, x, y, null);
   }


it still doesn't work, could you please put that into context for me? Where exactly does that line need to go? I tried putting it in the game loop right before the entity is drawn and nothing works. Is there anything else that needs to be changed?
21  Game Development / Newbie & Debugging Questions / Lost with affine transform... on: 2012-10-14 21:13:55
I am brand new to java game programming (started learning about a week ago). So far, I've taken someone else's Space Invader tutorial and started with a skeleton and modified a few things. Right now what I have is a blank screen with the ship in the center. Aliens spawn randomly and move in a random direction (supposed to be toward the player, but that bug is for another day). I've figured out how to take mouse clicks and turn it into a shot in the direction of the mouse click, but the shots that come out are always pointing up. I want to apply AffineTransform to rotate the shot on the angle that its traveling. That is where I get lost. Between the AffineTranform API and any sort of tutorial, I can't figure out how or where to put any of it.

here's what I have so far:
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  
package shooter;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.geom.AffineTransform;

public class Sprite {
   
   //create the tranform and image used for the sprite
  private AffineTransform transform = new AffineTransform();
   private Image image;
   private double angle;
   
   //creates the sprite with a scale and angle parameter
  public Sprite (Image image, double scale, double angle){
      this.angle = angle;
      //uses the scale to make the sprite the appropriate size
     this.image = image.getScaledInstance((int)(image.getWidth(null) * scale), (int)(image.getHeight(null) * scale), Image.SCALE_DEFAULT);
   }
   
   public int getWidth() {
      return image.getWidth(null);
   }
   
   public int getHeight() {
      return image.getHeight(null);
   }  
   
   public void draw(Graphics g, int x, int y) {
      //not sure if this is how you're supposed to do this,
     //but I'm trying to move the sprite to the passed x and y
     //then rotate it
     transform.translate(x, y);
      transform.getRotateInstance(Math.toRadians(angle), image.getWidth(null)/2, image.getHeight(null)/2);
      g.drawImage(image, x, y, null);
   }
}

the transform is never actually applied to the image how i have it here because affineTranform doesn't have any way to pass and image to it... I'm so lost...  Huh

This is just the sprite part of another class called Entity which is used to create the player, aliens, and shots. Hopefully this makes enough sense that someone can help me. If you do need anything else, let me know because I want to figure this out...
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.

Riven (7 views)
2014-10-02 14:36:20

Pippogeek (41 views)
2014-09-24 16:13:29

Pippogeek (32 views)
2014-09-24 16:12:22

Pippogeek (22 views)
2014-09-24 16:12:06

Grunnt (47 views)
2014-09-23 14:38:19

radar3301 (30 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06
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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!