Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
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: [SOLVED] Slick2D and JDeveloper 11G on: 2011-08-16 17:57:39
Hey guys I just wanted to let you know that I wrote a blog post/tutorial on how to set up a basic game with Slick2D and JDeveloper. Check it out here and let me know what you think.
2  Game Development / Newbie & Debugging Questions / Re: Slick2D and JDeveloper 11G on: 2011-08-15 19:27:54
Ok guys I have finally got it working  Cool

I tried a test game at work with the latest Slick download and just placing the .dll's at my project root level and was able to get a Hello World game running (go figure). So what I ended up doing was downloading the latest Slick on my laptop (computer I develop on), placed the .dll's at \(project root)\lib (which I created, thanks for the suggestion ra4king), and under my Java Options I put

-Djava.library.path=lib

So far it's working just like it should, and now I will know to first check the latest version of Slick before changing IDE's.

Thanks guys for helping me out with this one (it was incredibly frustrating for awhile)!
3  Game Development / Newbie & Debugging Questions / Re: Slick2D and JDeveloper 11G on: 2011-08-14 01:37:07
I'm pretty sure it's in that -Djava.library.path also, but I'm a little slow today, what do you mean by the "usual quoting, escaping, etc."?
4  Game Development / Newbie & Debugging Questions / Re: Slick2D and JDeveloper 11G on: 2011-08-13 22:21:28
Well that's the kicker, I don't have any classes named "Files" and my main class is called "Game". That and the fact that the error window that pops up is titled "Java Virtual Machine Launcher" makes me think it is something in my JVM Options (Located under Project Properties > Run/Debug/Profile).

And as far as the -Djava.library.path stuff goes, I was told to do that from the Documentation on the coke and code site (for NetBeans) and so that's why I was using it for JDev, because I figured that type of thing would be the same across the different IDE's.
5  Game Development / Newbie & Debugging Questions / [SOLVED] Slick2D and JDeveloper 11G on: 2011-08-13 21:57:52
Hey guys I'm having a tough time with this one and have been unable to find much through Googling and researching, so I thought I would just ask you guys. I've been using NetBeans to develop my games in (using Slick2D) and I'm trying to switch over to JDeveloper (because that's the IDE we use at work) and I can't seem to get even a test game up and running.

I have no problems setting up the Slick library and linking the classpath to it (in Project Properties). I am even able to set the runtime Java Options to (in my case) -Djava.library.path="C:\Program Files (x86)\Java\slick", just like it is in my NetBeans projects. However, every time I try to run an application (Slick application that is, regular ones work just fine) I get a windowed error message that says "Could not find the main class: Files. Program will exit" with "Java Virtual Machine Launcher" as the window's title.

I'm thinking that it has something to do with an incorrectly typed path somewhere (the idea being that the "Files" from the error is part of the \Program Files (x86)\Java path, but I've checked all my paths in the project properties that have "Files" in it and they all are fine.

Has anyone else tried using JDev with Slick2D and been successful and if so, do you have any ideas on how to fix my problem?

Thanks guys.
6  Game Development / Game Mechanics / Re: Tile-based Collision Detection Where Sprite is bigger than Tiles on: 2011-08-03 19:09:28
Oh ok I see. I'll probably end up doing just 1 or two tiles away for mine. I'm going to try and code this up tonight after work and hopefully I can get it working. Thanks for your help thus far!
7  Game Development / Shared Code / Re: Simplified Advanced Collision Detection (SAT) on: 2011-08-03 18:17:38
Well done sir, I have always had trouble understanding SAT and this presentation makes it a lot easier to understand. Thumbs up for you. Smiley
8  Game Development / Game Mechanics / Re: Tile-based Collision Detection Where Sprite is bigger than Tiles on: 2011-08-03 15:43:28
Ok I think I get it now, I can basically make a copy of the player's rect, apply the intended movement to it, then check collision for that rect, and if there was no collision then set the player's actual rect to the values of the temp rect.

I do have one question though. Why do you check for collision 4 tiles around the object/player instead of just the immediate neighboring tiles that surround the object/player?
9  Game Development / Game Mechanics / Re: Tile-based Collision Detection Where Sprite is bigger than Tiles on: 2011-08-03 15:19:53
Aha, I see what you're doing. You've basically made a bounding box that's bigger than the object (player in my case) by 4 pixels all around and you're looping through all of the box's edge pixels ( or is it 4 tiles all around the object instead? ) to check for intersection with a collide-able tile.

Do you mind if I ask you how you resolve your collisions, specifically what you do with you player to prevent them from passing through the collide-able object?
10  Game Development / Game Mechanics / Tile-based Collision Detection Where Sprite is bigger than Tiles on: 2011-08-03 15:06:28
Hey guys, like the title says, I'm having a tough time getting my collision detection to work properly. My game is a sidescrolling platformer and I'm wanting to use a tiled-based collision scheme, where each tile is either passable or impassable. I already know how to assign each tile a rectangle, but I'm not sure how to iterate over the tiles surrounding the player because my player's bounding box is twice as wide and 4 times as high as one tile (16 x 16 vs. 32 x 64). My actual sprite's dimensions are 64 x 64 (not that it matters).

Does anyone have any experience with this kind of a collision detection setup?
11  Games Center / Archived Projects / Re: Introducing Prospectus on: 2011-08-01 04:04:49
Hey thanks guys, I'm having a great time making this game, and I'm really looking forward to seeing it come together more and more. I'm nearly done with the port and I'm excited about the next phases of the game.

Thanks for reading and showing an interest in my development progress!
12  Games Center / Archived Projects / Introducing Prospectus on: 2011-07-28 20:04:34
Hey guys I've been hanging around this site for awhile but I've never really posted because I've been an XNA guy for the last few years. Now I have a Java programming job and I figured it would be good for me to switch to making Java games.

I would like to mention my work in progress, Prospectus. It is a 2D adventure game, much like a mixture of Zelda and Terraria. I have the first demo of it available here (in XNA). Note: I started this project in XNA and I'm in the process of porting it to Java/Slick2D. I also keep a blog about my progress in making Prospectus where I upload some code, give tips and advice, and feature some gameplay videos.

Feel free to check it out and please let me know what you think!
13  Game Development / Newbie & Debugging Questions / Re: Tilemap not drawing after implementing LoadFromFile on: 2011-03-29 18:19:44
Oh my gosh! Thank you so much! I can't believe it was something that simple. Lips Sealed
I guess I should have thought to look there as well as in my code. Thanks very much for your help, now I can move on to bigger and better things!

Were you able to move around Addictman?

Now whenever I System.out the camera x and y it still updates those when I use the arrow keys but it does not redraw the map. Very perplexing to me.
14  Game Development / Newbie & Debugging Questions / Re: Tilemap not drawing after implementing LoadFromFile on: 2011-03-29 17:49:58
Yes, well, it's not throwing the exception so I'm assuming that they aren't null. I tried moving the drawImage() call outside of the try{} block and it still didn't work
15  Game Development / Newbie & Debugging Questions / Re: Tilemap not drawing after implementing LoadFromFile on: 2011-03-29 16:23:38
Sure, well it prints out that line for every cell in the map (which it should) and here is some of the output:

Image for index: 0 is sun.awt.image.ToolkitImage@bbe0f0a
Image for index: 0 is sun.awt.image.ToolkitImage@bbe0f0a
Image for index: 0 is sun.awt.image.ToolkitImage@bbe0f0a
Image for index: 2 is sun.awt.image.ToolkitImage@513bd574
Image for index: 1 is sun.awt.image.ToolkitImage@6acd5f8b
Image for index: 1 is sun.awt.image.ToolkitImage@6acd5f8b
Image for index: 1 is sun.awt.image.ToolkitImage@6acd5f8b
Image for index: 1 is sun.awt.image.ToolkitImage@6acd5f8b
Image for index: 0 is sun.awt.image.ToolkitImage@bbe0f0a
Image for index: 0 is sun.awt.image.ToolkitImage@bbe0f0a

I also put a System.out.println("Got here"); after my call to g.DrawImage(); in the try{} block and it was outputting infinitely (which it should because I'm always calling the draw method from main).

I also added in a System.out for the x and y of camera and it is x = 0 and y = 0 at the beginning and is updating when I press my arrow keys (like it should be)
16  Game Development / Newbie & Debugging Questions / Re: Tilemap not drawing after implementing LoadFromFile on: 2011-03-29 15:45:30
Ok I changed the LoadTextures() to what you suggested and I'm still getting the black screen in a window and the console output is:
Loading: "images/grass0.png"
Loaded image: sun.awt.image.ToolkitImage@bbe0f0a
Loading: "images/grass1.png"
Loaded image: sun.awt.image.ToolkitImage@6acd5f8b
Loading: "images/grass2.png"
Loaded image: sun.awt.image.ToolkitImage@513bd574
Loading: "images/dirt0.png"
Loaded image: sun.awt.image.ToolkitImage@2f3adc56
Loading: "images/dirt1.png"
Loaded image: sun.awt.image.ToolkitImage@4157aa53
Loading: "images/dirt2.png"
Loaded image: sun.awt.image.ToolkitImage@626f50a8
Loading: "images/dirt3.png"
Loaded image: sun.awt.image.ToolkitImage@7a187814

which makes me think that the images loaded fine.
I even added block in my Draw() that says
1  
2  
3  
if (image == null){
   System.out.println("Image is null");
}

Which did not show up in the output.

And I even removed the call to set the background to black (in my main class) which did make the window go back to that greyish color.

I am very confused by this bug
17  Game Development / Newbie & Debugging Questions / Re: Tilemap not drawing after implementing LoadFromFile on: 2011-03-29 15:20:45
You'd be best to add some debug telling you what that string resolves to, and whether it's actually accessible. Also you might consider using ImageIO.read() instead of the ImageIcon().getImage();

Kev

The only output that I'm getting is a window with the black background that set in my main java class constructor. If I remove that line of code, all I get is a window with the generic grey canvas that java makes

Man, I've added and removed so many debug lines it's disgusting. Let me tell you a few things that I know based on a bunch of System.out.println() - type debugging:
The textureArray that is passed to LoadTextures() contains all six of the textures filenames.
The tilemap layout matches the layout from the text file.
The image is null when the g.DrawImage() is called.


What's the advantage of using ImageIO.read() instead of ImageIcon().getImage()?

18  Game Development / Newbie & Debugging Questions / Tilemap not drawing after implementing LoadFromFile [SOLVED] on: 2011-03-29 14:05:35
Hey everyone this is my first post and I must say that I like the community that I have seen here and look forward to contributing to other people's success.

I'm making a 2D tile-based (small scale) rpg and cannot for the life of me figure out why my tilemap is not displaying. I just implemented loading maps from files and I know that before this the map was loading and displaying just fine I believe I have narrowed the possibilities down to my images being null when I go to draw them but I cannot seem to figure out why that is. Here is the code for my entire tilemap class with the null image

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  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
import java.util.*;
import java.awt.*;

import java.io.File;

import javax.swing.*;

public class TileMap{

  ArrayList<Image> textures = new ArrayList<Image>();
 
  int[][] map;
 
  static int tileWidth = 32;
  static int tileHeight = 32;
 
  static int tileMapWidth;
  static int tileMapHeight;
 
  public TileMap(){}    
   public TileMap(int width, int height){
      map = new int[height][width];
      for (int x = 0; x < width; x++)
          for (int y = 0; y < height; y++)
              map[y][x] = -1;

      tileMapWidth = map[0].length;
      tileMapHeight = map.length;
   }  
  public TileMap(int[][] newMap){
      this.map = newMap.clone();
 
      tileMapWidth = map[0].length;
      tileMapHeight = map.length;
  }  
 
  public static TileMap LoadFromFile(String fileName){

    TileMap tileMap;
    ArrayList<ArrayList<Integer>> tempLayout = new ArrayList<ArrayList<Integer>>();
    ArrayList<String> textureList = new ArrayList<String>();
    Scanner input;
    File file;
   
    try{
        file = new File(fileName);
        input = new Scanner(file);
    }catch(Exception e){
        file = null;
        System.out.println("File is null");
        input = null;
        System.out.println("Input is null");
    }
 
    boolean readingTextures = false;
    boolean readingLayout = false;
           
    while(input.hasNext()){
        String line = input.nextLine().trim();
       
        if (line.isEmpty())
            continue;
       
        if (line.contains("[Textures]")){
          readingTextures = true;
          readingLayout = false;
        }
        else if (line.contains("[Layout]")){
          readingLayout = true;
          readingTextures = false;
        }
        else if (readingTextures){
          textureList.add(line);
        }
        else if (readingLayout){
          ArrayList row = new ArrayList();
         
          String[] cells = line.split(" ");
         
          for (String c : cells){
            if (!c.isEmpty())
                row.add(Integer.parseInt(c));
          }
          tempLayout.add(row);
        }          
    }
   
    int width = tempLayout.get(1).size();
    int height = tempLayout.size();
   
    System.out.println(width);
    System.out.println(height);
   
    tileMap = new TileMap(width, height);
   
    for (int y = 0; y < height; y++){
        for (int x = 0; x < width; x++){
            try{
                tileMap.setCellIndex(x, y, tempLayout.get(y).get(x));
            }catch(NullPointerException e){
                System.out.println("SetCellIndex() has returned a NullPointerException");
            }
        }
    }
   
    String[] textureArray = new String[textureList.size()];
    for (int i = 0; i < textureList.size(); i++){
        textureArray[i] = textureList.get(i);
    }
   
    tileMap.LoadTextures(textureArray);

    return tileMap;    
  }  
  public void LoadTextures(String ... fileNames){
      for (int i = 0; i < fileNames.length; i++){
          try{
            textures.add(new ImageIcon(Game.SRC_PATH + fileNames[i]).getImage());
          }catch(Exception e){
            System.out.println("File not added.");
          }
      }
     
  }
 
  public int getCellIndex(int x, int y){
    return map[y][x];
  }  
  public void setCellIndex(int x, int y, int cellIndex){
    map[y][x] = cellIndex;
  }
 
  public static int getWidthInPixels(){
    return tileMapWidth * tileWidth;
  }  
  public static int getHeightInPixels(){
    return tileMapHeight * tileHeight;
  }
 
  public void Draw(Graphics2D g, Camera camera){
                 
      int tileMapWidth = map[0].length;
      int tileMapHeight = map.length;
   
      for (int x = 0; x < tileMapWidth; x++){
          for (int y = 0; y < tileMapHeight; y++){
              int index = map[y][x];
             
              if (index == -1)
                  continue;
             
/////////////////////// NULL IMAGE RIGHT HERE \\\\\\\\\\\\\\\\\\\\\\\\\
             Image image = textures.get(index);
                                         
              try{
                g.drawImage(image,
                            x * tileWidth - (int)camera.Position.X,
                            y * tileHeight - (int)camera.Position.Y,
                            Color.WHITE,
                            null);
              }catch(NullPointerException n){
                System.out.println("Draw Image threw a NullPointerException");
              }
          }
      }
  }
}


If anyone can help me spot the problem I would be very greatful. I thank you for taking the time to read over my code and here is a link to my entire project (zip file) with images and the tilemap text file.
https://docs.google.com/leaf?id=0B-7lPg3Z0pepZTU5NDNlNTAtOGNiMS00ZGExLWIxZjAtNWYxZGJlMjQyYTRj&hl=en&authkey=CIW-nLMK

Thanks everyone!
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.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
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!