Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (306)
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] 2 3 4
1  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-21 02:48:43
I would not suggest looping through the tiles, looking for collisions. In all honesty, I am unfamiliar with this library. However, I would imagine that there are ways to check for tiles at a specific point in space. There is no reason to check for EVERY tile, only the near ones.


I don't think I'll be of very much help from here on out, I have never used that library. Good Luck Smiley
2  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 04:26:22
Perhaps I misunderstood your questions. I thought you were talking about moving your player until it hit something, not just standing still.

However, my method would still work.

But yes, you could have a "canMoveLeft" boolean that would not let the player move left if there was a block right to the left of the player.
3  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 04:09:12
The "i" is unimportant, it's just force of habit. All this does is make sure that you keep moving in the direction of the speed until you hit something.
4  Game Development / Newbie & Debugging Questions / Re: Threads for long computations? on: 2013-05-20 01:37:19
It's hard to believe it's so simple :p
I'll give it a shot, thanks
5  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 01:36:21
Let's say that xspeed is an integer. If it is negative, this means x gets smaller and the character moves to the left. Otherwise, the character moves to the left.

Here is the pseudo code:
1  
2  
3  
4  
5  
6  
7  
if(xspeed != 0){
         for(int i = 0; i < Math.abs(xSpeed); i++){
            if(the character will not collide with anything){
               x += Math.signum(xspeed);//the Math.signnum() method will return -1 if xspeed < 0, or 1 if it is not
           }
         }
      }
6  Game Development / Newbie & Debugging Questions / Threads for long computations? on: 2013-05-20 01:17:42
I want to just play around with AI for a bit now. I want to see if I can make a relatively decent chess AI. It will probably not work, but whatever.

In any case, when I make a game, I have it work through a series of "ticks," that is every 60th of a second the game "ticks," runs through all of it's code, then will tick again later.

Usually my computations are very small, so it runs just fine. However, what if I want to do 5 seconds worth of computations before the computer moves? I would want the game to continue "ticking" 60 times a second, except be running it's computations in the background.

Now, I know about threads and whatnot, but I don't understand how to implement them into my code in this sort of situation. Could anybody point me in a direction, or give me some tips for going in such a direction?

Thanks
7  Games Center / Showcase / the sunset - LD26 game on: 2013-05-20 01:08:49
Here is a game I made for the Ludum Dare 48 hour competition about a month ago, meant to fit the theme of "minimalism".

the sunset


You play as a tiny spider who wants to exit from the depths of its cave to watch the Sun set.

It is a very short and simple game, it might take you about 10 minutes to beat.

There are many possible paths for completion, however, and many tiny hidden easter eggs hidden in the corners.

It was a lot of fun to make! You should rate it if you have an account. :p

Download / Browser Applet here:
http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=21305

Please leave feedback!
8  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 00:58:42
2. After I figure out when my player is next to a certain tile, how could i prevent the player from moving onto that tile? Would there be a simple way to determine if the tile is to the left of the character, and making a variable like isAbleToMoveLeft set to false if its near a tile where it can not move left.Maybe something like this?
1  
2  
3  
if(collisionTile.x < player.x){
     isAbleToMoveLeft = false;
}


2. What I did is I had a for-loop that would add 1 (or subtract 1) from the player's x coordinate for each value in the xspeed. It would keep adding until it hit something, and I did something similar for the y coordinate. That is one simple method of solving it, although I'm sure there are much better ways. (You should only check for collision with tiles in the immediate vicinity, however. You don't want to have to check too many tiles too often.)
9  Game Development / Newbie & Debugging Questions / Re: Uploading applets onto GameJolt? on: 2013-04-26 00:56:20
Ah yes! The package! I completely forgot to include the package!

Yes, I included the package directory and it worked!

(Funnily enough, I did Google this and nobody ever seems to have discussed this)

Thanks
10  Game Development / Newbie & Debugging Questions / Re: Uploading applets onto GameJolt? on: 2013-04-26 00:46:03
Right, let's say that class is called GameApplet

Would I input "GameApplet," or "GameApplet.class," or "GameApplet.java," or what?
11  Game Development / Newbie & Debugging Questions / Re: Uploading applets onto GameJolt? on: 2013-04-26 00:27:49
But it's an applet... Main class?
12  Game Development / Newbie & Debugging Questions / Re: What is wrong??? on: 2013-04-26 00:27:27
FIFY                                                     

Fair enough :p
13  Game Development / Newbie & Debugging Questions / Uploading applets onto GameJolt? on: 2013-04-26 00:23:38
Has anybody ever uploaded a Java Applet onto gamejolt.com?

I am having some trouble doing so. Namely, what sort of .Jar do you upload (runnable?) and what class do you input into the class field?

If you have, I would like to know how you did it.

Thanks
14  Game Development / Newbie & Debugging Questions / Re: What is wrong??? on: 2013-04-26 00:13:03
25 / 100

You think this number is .25, really it is 0.

That is because the computer sees 25 is an integer (int) and 100 is an integer and therefore, 25/100 must be an integer.

Obviously, this is not how math works, but this is how java thinks about it. However, if either 25 or 100 is a double (double precision number), then you will get the answer you want. You can just do this by writing 25.0 instead of 25 or 100.0 instead of 100.

I made a little list of code and what it should output.

System.out.println(25/100); ---> 0
System.out.println(25/20); ---> 1
System.out.println(25.0/100); ---> 0.25
15  Java Game APIs & Engines / OpenGL Development / Re: Change draw color on: 2013-03-31 20:59:31
I'll do that for now, but is there really no other way to do it? Seems as though it should be simpler than that.

Thanks though, it does work!
16  Java Game APIs & Engines / OpenGL Development / Change draw color on: 2013-03-31 19:16:51
I'm making a 3D tetris game to get used to working with OpenGL. When I draw the scene (with my draw() method) I first draw all the tetris cubes on the scene. They are textured cubes of different colors. Then after I draw these cubes, I draw "gridlines," which are lines drawn over the scene to show the "grid."

I want these lines to be drawn in white. Here is what my code looks like:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public void draw(){
      glPushMatrix();
     
      //translate the scene
     glTranslated(-GAME_WIDTH/2 + 0.5, -GAME_DEPTH/2, -30);
     
      //draw all the tetris cubes
     for(TetrisCube tc : cubes){
         if(tc.x > -1 && tc.x < GAME_WIDTH
               && tc.y > -1 && tc.y < GAME_HEIGHT
               && tc.z > -1 && tc.z < GAME_DEPTH)
            tc.draw();
      }
     
      //set the color of the gridlines to white (doesn't work)
     glColor3f(1f, 1f, 1f);
     
      //draw all the gridlines
     for(DrawLine dl : gridLines){
         dl.draw();
      }
     
      glPopMatrix();
   }


However, the lines are not white. Instead, they are the color of the last block drawn, which might be red, blue, etc.
This is a little weird, because the guides I've read online have suggested that this would work. I probably don't understand what the glColor3f() really does, but I don't know what to use instead. How would I solve this problem? Thanks.
17  Game Development / Newbie & Debugging Questions / Re: How to make maps in a simple 2D game? on: 2013-02-26 05:00:44
What a lot of people do for simple tile-based games is they store levels as images where each pixel corresponds to one tile.

Colors are stores in images as integers, with a component for the red, green, and blue values of the colors (more here http://en.wikipedia.org/wiki/RGB_color_model)

You can make these images in something simple like MS Paint or GIMP or Paint.NET. For example, a floor tile could be represented as a white pixel, while a wall tile could be a black pixel. A health pickup could be red, an enemy could be green, and so on. You can load this image into your game and have the computer make an array of ints, where you then say, "Okay, if this pixel here is white, put a floor tile in the game world at these coordinates. If it's black, make a wall" and so on.

What's nice about this is that you can pretty easily edit levels on the fly by just opening up the paint program.

Here's a method I made for one of my games to get the int[][] of colors out of the original image:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
//this is what's supposed to load the RGB values from the .png into my map[][] array
  public int[][] loadRGBMap(String directory){  
      int[][] map;
     
      BufferedImage img = ResourceLoader.loadImage(directory);

      int w = img.getWidth();
      int h = img.getHeight();
      int[] pixels = new int[w * h];
      img.getRGB(0, 0, w, h, pixels, 0, w);
     
      map = new int[w][h];
      levelMap = new boolean[w][h];
      //this channels the 1 dimensional pixel[] into the two dimensional map[][]
     for(int row = 0; row < h; row++){
         for(int col = 0; col < w; col++){
            map[col][row] = pixels[row*w+col];
         }
      }
     
      return map;
   }


"directory" is just where the map is stored, ie "levels/level1.png"
"ResourceLoader" happens to be my own class, but all it does it load a BufferedImage

Hopefully that should get you started
18  Java Game APIs & Engines / OpenGL Development / Generally agreed upon "mouse rotation" code? on: 2013-02-25 00:33:50
Often in 3D applications, like graphing programs and modelling programs, you'll be able to click somewhere on the screen and drag your mouse around, and the whole scene will rotate around the origin accordingly. I was wondering, what's the agreed upon math behind this? Has anyone done anything like this before? How should you translate the dragging on the mouse on the screen into rotation around the origin?

Thanks
19  Game Development / Newbie & Debugging Questions / Write my own personal library? on: 2013-02-15 05:52:51
I'm starting to plan out my next major gaming project in my head.

One of the things I know the game will need is pretty involved level design. I'm going to be using dozens and dozens of different entities with different initial settings and such.

What this means is that MS Paint won't cut it anymore. I want to make my own level editor to easily create and "export" levels.

I'm thinking that I want both my level editor application and my actual game to read from some of the same classes, so I don't have to copy and paste code every time I change a line of code, which I just know will end in some frustrating bugs.

Does anybody else have experience with something like this? What's the best way to go about it?

Thanks
20  Game Development / Game Play & Game Design / Re: Pixel art? on: 2013-02-12 07:52:23
Believe it or not, I use Game Maker 8 to do my graphics. It has a lot of tools, it makes everything easy, and you can easily export stuff to strips, transparency, etc. There are only rare occasions when I get mad at it D:

I thought I was the only one who did that! Although I don't code in GM anymore, I still love its sprite editor. Also, the animation strips make life so easy.
21  Discussions / General Discussions / Re: Files between Java and C# on: 2013-01-14 05:44:54
Yeah... That's kinda the response I was expecting to get.

Okay, thanks!
22  Discussions / General Discussions / Files between Java and C# on: 2013-01-14 04:01:51
This is not gaming related. For various reasons, I need to get some data from a Java application to a C# application. I have very little C# experience and am learning that now. By "data," I mean a list of about a thousand doubles. What is the best file type to save this as that can be reopened in a C# application? Text files? Wouldn't that take up a little too much space? Although if it's only about 5 or so times the space I wouldn't mind so much.

This is very nebulous at the moment. What file type would you use for this task and why?

Thanks
23  Games Center / Showcase / Re: Space Spiders on: 2013-01-14 02:09:59
Nice game, very polished Smiley
How are you generating the paths/tiles?

Thanks! The level's aren't "generated" so much as "designed." I toyed with the idea of random level generation, but I realized that manually designing them is way easier and would produce better results. My method of loading levels is not particularly unique. I would make a .PNG of the level plan, with each pixel being a tile. For example, black pixels were empty spaces, white pixels were floor tiles, red tiles were hearts, brown tiles were standard spiders and so on. After I made all of the levels like this in MS Paint, I loaded them up as BufferedImages and got the array of colors, then loaded the levels accordingly.
24  Games Center / Showcase / Re: Space Spiders on: 2013-01-13 14:58:22
It is a very nice game.

When someone quits the game, make sure that you kill all the music and sound threads by closing them so they don't continue playing when you quit. Other than that, it is pretty solid and a bit challenging in the later levels.

Ah jeez, I never noticed that! Thanks, should be all fixed now.
25  Games Center / Showcase / Re: Space Spiders on: 2013-01-13 14:52:05
I know the game is finished but here are some things I would change
  • WASD support on main-menu.
  • Shadow under the character that changes dynamically when jumping (you can just use a shrinking black circle).
  • Make the game harder but remove losing life when enemies are not killed.
  • Perhaps some abilities, like a psionic shield that blocks X bullets (with a new ammunition system for it, maybe cooldown based).

Q: How did you make the planets?

Yes, the game is not perfectly polished. At a certain point I just wanted to finish it! But yes all of your criticism is valid. I'll think these things through much harder with my next game.

Also, the planets were pretty flipping hard to execute, not gonna lie. They were something I knew I wanted from the beginning, but had a hard time implementing.

First things's first, I got the texture of the planets' surfaces online from real images of Mercator projections of the planet (except for Pluto, which had almost no resolution, and Uranus, who's color was too homogenous). Then I load all the colors from this image into an array of colors. Then, through a magic equation that I will discuss in a second, I calculate all the vertex points of the tiny quadrilaterals, then feed those points into an array of polygons and then draw all the polygons.

That magic equation I was talking about does not produce a real sphere, just a shape that looks like one when when the top is observed. The equation behind the coordinates of a sphere are long and very expensive. Instead, I just constructed my own through trial and error and variable-tweaking. I think what I did is define the x and y coordinates using the imaginary angle from the center of the planet and the column. I think I added some sine curvature in a few places to make is seem more rounded through cheap means.

TL;DR - trial and error
26  Games Center / Showcase / Space Spiders on: 2013-01-13 04:59:32


Download: http://www.mediafire.com/?ioil66pc3qifnhj

Hello! After a long time, my first real game in Java is complete!
I really couldn't have done it without this fantastic forum, which answered all of my stupid questions!
I just kept adding features so I could learn more about making a game in Java2D.

The game is a mix of Temple Run and Mega Man, two games that I thought would blend pretty well.

If you like arcade games, give it a go! It's only 2MB! :p
27  Game Development / Newbie & Debugging Questions / Re: File loads in eclipse but not in a runnable .jar [unsolved] on: 2013-01-09 06:44:32
YYYYYYYYYYYEEEEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSS!

The working code, for those interested:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public static void playMidi(Song song){
      String filename = "/music/"+song.name+".mid";
      URL tempURL = MusicPlayer.class.getResource(filename);
     
      try {
         midiPlayer = MidiSystem.getSequencer();
         midiPlayer.setSequence(MidiSystem.getSequence(tempURL));
         midiPlayer.open();
         midiPlayer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
         midiPlayer.start();
         
         currentSong = song;
        } catch (MidiUnavailableException ex) {
           System.err.println("Midi Unavailable! "+ex.toString());
        } catch (InvalidMidiDataException ex) {
           System.err.println("Midi Invalid! "+ex.toString());
        } catch (IOException ex) {
           System.err.println("File Not Found! "+ex.toString());
        }
   }


I realized that the "MusicPlayer.class.getResource" was the way to go. I dunno why those other methods weren't working, but they weren't, so that's that. I was looking over my working texture loading code I wrote months ago and saw that "getResource()" worked there so I tried it here and it's glorious.


Thank you to all to all who responded! Couldn't have done it without you! What a confusing mess, truly one for the ages.
28  Game Development / Newbie & Debugging Questions / Re: File loads in eclipse but not in a runnable .jar [unsolved] on: 2013-01-09 06:06:46
I cannot make it like the image you've shown, I can't put a package in a package. Maybe my version of eclipse is just old.

However, when I do this:


and make the filename this:
1  
      String filename = "src/music/"+song.name+".mid";


It still says the URL is null
29  Game Development / Newbie & Debugging Questions / Re: File loads in eclipse but not in a runnable .jar [unsolved] on: 2013-01-09 06:00:12
I've done all of those, except for the class folder. But when I do that, I get this:

So I'm not sure that's the problem
30  Game Development / Newbie & Debugging Questions / Re: File loads in eclipse but not in a runnable .jar [unsolved] on: 2013-01-09 05:49:25
Err... didn't work. Somebody commented about saving it in the root of the project? I'm not sure what this means and I wasn't able to figure it out with google, probably because I wasn't using the right key words. Is this music folder in the root?
Pages: [1] 2 3 4
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
mrbenebob (4 views)
2013-06-19 14:55:23

BrassApparatus (12 views)
2013-06-19 08:52:37

NegativeZero (17 views)
2013-06-19 03:31:52

NegativeZero (19 views)
2013-06-19 03:24:09

Jesse_Attard (22 views)
2013-06-18 22:03:02

HeroesGraveDev (62 views)
2013-06-15 23:35:23

Vermeer (61 views)
2013-06-14 20:08:06

davedes (61 views)
2013-06-14 16:03:55

alaslipknot (56 views)
2013-06-13 07:56:31

Roquen (77 views)
2013-06-12 04:12:32
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
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!