Show Posts
|
|
Pages: [1] 2
|
|
1
|
Game Development / Newbie & Debugging Questions / Re: How to know the rotation ?
|
on: 2013-04-22 04:38:49
|
|
How can you find the rotation of an object?
Do you have a class for that type of object which holds its variables such as position and speed? Do you have any Java code? Do you know any Java?
I know some ActionScript, and I know why you would think that an image has a rotation you can get from it, but Java doesn't work that way.
|
|
|
|
|
3
|
Java Game APIs & Engines / OpenGL Development / Re: Help starting 3d with libgdx
|
on: 2013-04-13 03:01:48
|
3D with OpenGL:
- Perspective instead of orthographic projection. - Depth Testing - Back face culling (most of the time) - Diffuse/Ambient Lighting (easily done with shaders) - Everything you normally have for 2D
Work out how to do these with LibGDX and you should be fine.
Completely unhelpful. There are no useful tutorials that explain using objects, moving objects on the screen, or teach how to properly use shaders. I already know what all those things are, but every "tutorial", if you could even call them that, was useless.
|
|
|
|
|
4
|
Java Game APIs & Engines / OpenGL Development / Help starting 3d with libgdx
|
on: 2013-04-12 21:02:49
|
|
Ok, I know some of you are using 3d with libgdx. Now, I've been trying to figure out opengl with libgdx, and Google has been completely useless. I have a 3d model and I've been trying to figure out how to render it and how to do basic 3d crap, but no useful tutorial exists for this type of thing. There aren't even any useful libgdx tutorials for using GL2.0 and shaders.
I need some tutorials, please.
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: Simple Math Problem
|
on: 2013-04-09 22:38:59
|
Add system.out.println statements to display the value of renderMe after the if statement, and add some in every step of your drawing function to see where things stop.
I added one in the render code and after it, they're always the same. Putting them in the various steps of the render code wouldn't show anything other than true because the render code only runs when renderMe is true. I know the way that I have everything set up and no matter how I think about this, there should be no reason for this to not be working. It's getting the position of the player, doing some simple math, checking if a few values are higher or lower than others and then changing a boolean. The fact that this isn't working is just weird to me... I didn't mean print out the value of renderMe. Put System.out.println("a"), ("b"), ("c"), etc in every step of the game to see what letter it all stops.
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: Entity Component Systems
|
on: 2013-04-05 00:37:57
|
Which one would you describe as being better? And why Annotation injections? They seem to be some kind of hacky... I've used Artemis, and it's really efficient. Just because it seems hacky doesn't make it bad. You also don't have to use any annotations in Artemis.
|
|
|
|
|
10
|
Game Development / Game Mechanics / Re: Calculating Theta... of What?
|
on: 2013-04-02 00:44:37
|
ok, so this is what I have done: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| targetX = shotMob.x + shotMob.width / 6; targetY = shotMob.y + shotMob.height / 6;
float diffX = (float) (targetX - xBullet); float diffY = (float) (targetY - yBullet); float theta = (float) Math.atan2(diffY, diffX); boolean beenSet = false;
distance = Math.sqrt(Math.pow(targetX - xBullet, 2) + Math.pow(targetY - yBullet, 2)); time = distance / shotMob.MOVESPEED;
newPos = new Point((int) (targetX + (shotMob.MOVESPEED * time) * Math.cos(theta)), (int) (yBullet + (shotMob.MOVESPEED * time * Math.sin(theta))));
distanceX = (int) ((double) newPos.x - xBullet); distanceY = (int) ((double) newPos.y - yBullet); if (!beenSet) { sep = Math.sqrt((distanceX * distanceX) + (distanceY * distanceY)); beenSet = true; System.out.println(beenSet); } |
but the same thing still happens. Is there something I am missing? Your variable names aren't clear, and your code needs to be organized. Create a fire() and update() function, instead of having it all in your update(). Your code is more complicated than it needs to be. Here, let me give you this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public void fire() { targetX = shotMob.x + shotMob.width / 6; targetY = shotMob.y + shotMob.height / 6; float diffX = (float) (targetX - xBullet); float diffY = (float) (targetY - yBullet); float theta = (float) Math.atan2(diffY, diffX); velocityX = Math.cos(theta) * shotMob.MOVESPEED; velocityY = Math.sin(theta) * shotMob.MOVESPEED; } public void update(float deltaTime) { xBullet += velocityX * (deltaTime * 1000f); yBullet += velocityY * (deltaTime * 1000f); } |
------- I'm going to take a guess and say that you probably don't have a deltaTime. If that's the case, then change the update() function to this: 1 2 3 4 5
| public void update() { xBullet += velocityX; yBullet += velocityY; } |
Then, MOVESPEED should be the distance you want the object to move every update.
|
|
|
|
|
12
|
Game Development / Game Mechanics / Re: Calculating Theta... of What?
|
on: 2013-04-02 00:26:17
|
Ah, does that increase speed by doing less trigonometric functions? If so, I'll be sure to do that when updating my code in the future (as I need to fix it as it currently sucks).
Yeah, no need to call sin() and cos() on every update. Just set it once and you'll save yourself many nanoseconds that will add up in the long run, especially if you have dozens of bullets on the screen at once..
|
|
|
|
|
13
|
Game Development / Game Mechanics / Re: Calculating Theta... of What?
|
on: 2013-04-02 00:23:12
|
Ah yes, a good example of this is in the code for my game PixelZombies. You can check out an example here https://github.com/Sammidysam/Zombies/blob/master/src/weapons/Bullet.java but the code is really bad and I apologize. But the bullet takes the arguments x (mouse click x), y (mouse click y), manx (where the person firing the bullet is located x), and many (where the person firing the bullet is located y) and then calculates the angle. Then, when moving, the code 1 2
| x += Math.cos(angle) * SPEED; y += Math.sin(angle) * SPEED; |
is called. Is this what you are looking for? You can find the game in action here if you want to see it in action to make sure it works. Yeah, this is what I was getting at. However, I usually do something like this: 1 2 3 4 5 6 7
| dx = Math.cos(angle) * SPEED; dy = Math.sin(angle) * SPEED;
x += dx; y += dy; |
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: Starting points on a game
|
on: 2013-04-02 00:07:52
|
1) First you should read through the basic tutorials on the oracle site, then I recommend you should buy a physical book from a bookstore. 2) If you're just starting, and want to learn by making a simple game, do not use any API. 3) Don't use any API if you're a beginner 4) Eclipse forever! However, it doesn't matter. If you later want to go into Android programming, using Eclipse will wake life easy.
|
|
|
|
|
18
|
Game Development / Game Mechanics / Re: Calculating Theta... of What?
|
on: 2013-04-02 00:01:28
|
works perfect, the angle is correct but now the bullet is shot, moves towards where the mob will be and then arcs up to the mob... I think this has something to do with my adding to x and y maybe incorrectly
It's probably because you're calculating new velocities each step. So, as the bullet gets closer to the target, the distance changes, and since your velocity is based on the distance, it changes as well. You should set the velocity once, and only add it the position on every other update.
|
|
|
|
|
19
|
Game Development / Game Mechanics / Re: Calculating Theta... of What?
|
on: 2013-04-01 23:45:14
|
You realize that "theta" stands for "angle", right? You are supposed to calculate the angle between the bullet's firing position and the target position. TIP: No need to call the function Math.pow(num, 2), when you can do (num*num) Theta should be a float as well. 1 2 3 4 5 6 7 8 9
| float diffX = targetX - xBullet; float diffY = targetY - yBullet;
float theta = Math.atan2(diffY, diffX);
distance = Math.sqrt(diffX * diffX + diffY * diffY); |
You see that commented line with -diffY? Depending on if you are calculating the angle from the bullet to the target, or the target to the bullet, you may get a negative number. You may also get a negative number depending on the target's position relative to the bullet, and vice versa. So, if the bullet goes the wrong way, try the -diffY one.
|
|
|
|
|
24
|
Game Development / Newbie & Debugging Questions / Re: Unexpected answer returned by Math.sin
|
on: 2013-03-22 00:41:49
|
I wouldn't do typecasting to an integer, because the result will be 0 in most of the cases and will only be non zero if the angle is exactly pi/2 or 3*pi/2. I would rather set a threshold. Like this: 1 2 3
| double a = Math.sin(Math.toRadians(angle)); if(a < 0.0001 && a > -0.00001) a = 0; |
In which case would typecasting to integer be better? In NO case would typecasting to an integer be better.
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Re: Linking strings / textures together somehow
|
on: 2013-03-21 02:48:39
|
There are many ways of doing this. You could use a HashMap<String, Texture> and work with that. Read up on hashmaps: here and here. 1 2 3 4 5 6 7
| Map<String, Texture> map = new HashMap<String, Texture>();
m1.put("Option 1", textureObject);
m1.get("Option 1"); |
Note however, that this method is probably inefficient, unnecessary, and a waste of memory. You can also use Enums to do what you want.
|
|
|
|
|
27
|
Games Center / Showcase / Re: Numerus [Android and applet]
|
on: 2013-03-19 23:00:19
|
|
I downloaded it yesterday and played against the computer on easy. I must say that the game has a nice concept and gameplay. It is definitely more difficult than the average board game, and I haven't been able to win even a single game, yet!
It's a quite promising game, and I will keep playing it.
|
|
|
|
|
28
|
Games Center / Showcase / Re: Flesh Boy alpha
|
on: 2013-03-11 20:49:51
|
For Windows, you don't need to do this: "C:\\Users\\", you can do this: "C:/Users/" and it will work for all operating systems.
Well no, it'll still only work on Windows. Getting at a user's home directory is a bit involvedYeah, I know that, my post was meant to talk about the "\\" and "/"
|
|
|
|
|
29
|
Games Center / Showcase / Re: Flesh Boy alpha
|
on: 2013-03-10 05:37:32
|
Well, there are directory problems, and sometimes some things can be platform-independent like look and feel.
Neither of those things should cause it to be platform dependent. For Windows, you don't need to do this: "C:\\Users\\", you can do this: "C:/Users/" and it will work for all operating systems. And if you don't want to use java's look and feel, simple use the system's look and feel 1 2
| UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); |
EDIT: I know Mac and Linux don't use drive letters. I was talking about the "\\" vs "/"
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|