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 
|
|
|
|
|
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.
|
|
|
|
|
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); } } } |
|
|
|
|
|
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=21305Please 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.)
|
|
|
|
|
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
|
|
|
|
|
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(); glTranslated(-GAME_WIDTH/2 + 0.5, -GAME_DEPTH/2, -30); 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(); } glColor3f(1f, 1f, 1f); 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
| 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]; 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.
|
|
|
|
|
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  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/?ioil66pc3qifnhjHello! 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.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|