Tag Info

New answers tagged

0

Lacking an OpenGL compiler I forgot a semicolon. So this "v_TexCoordinate = a_TexCoordinate" + should be this: "v_TexCoordinate = a_TexCoordinate;" +


0

just a guess, but does the removal of the player after first bullet, or removal of first bullet, stop the timer that calculates the movement of the bullet? is some timer no longer calculating time in flight the same after collision detection then removal of target? If it is moving, but never gets a few cycles to calculate its move, it will be stationary, ...


0

Your projectiles probably have some sort of movement vector. If it doesn't change in middle of flight, you can invert it and make your enemy move at inverted vector. For example if bullet vector is [0.5, 0.5], enemy has to charge at [-0.5, -0.5]. Make your creature run until it hits something or for n seconds. OR Let your projectile store coords where it ...


0

You don't actually need trig for this, you are over thinking it! I think what you are trying to do is move the enemy 1 unit towards the player. To do that, the first thing you need is a normalized vector from the enemy to the player. Then, you just add that vector to the enemy's position. You can even multiply that normalized vector by the enemies moving ...


0

I have no direct experience with Shogi, but: 1) You should check that your implementation isn't unnecessarily slow - as noted in gcp's answer, it sounds like it should work. How many positions do you evaluate per second? In C++ for a simple game, you can get around 10^7 moves per second. If you have complex heuristics and/or complex game rules, you still ...


3

Shogi is well researched, so you should be able to find research papers detailing different methods of implementing pruning or reduction heuristics for Shogi. I can't offer specific advice since I've never implemented a Shogi engine, but I did implement one for Bughouse/Crazyhouse, which has similar rules (captured pieces can be dropped). My advice would be ...


0

Edit: Moved from comments; didn't originally feel like a complete answer. May not be still... Time-step: A typical problem with collisions is when bodies move beyond each other, instantly, in the same frame; i.e. "teleport". No collision is detected because the objects moved past, not through, the other. Floating-point error is unavoidable and will always ...


0

I was not using the shader after I loaded it. Added GL.UseProgram(mShader.ShaderProgramID); After shader loading code.


0

What you are currently referring to as FRUSTUM_WIDTH, FRUSTUM_HEIGHT is actually the world width and height for the camera. This means that, across your application window, 8 world units in width and 12 world units in height will be displayed. Since you are not changing the size of your Sprite, it will have the texture's width and height, so it will be ...


0

You draw with GL.BindVertexArray(mVertexArrayObjectIDs[1]); GL.DrawElements(PrimitiveType.TriangleFan, 4, DrawElementsType.UnsignedInt, 0); however the indices you use are for PrimitiveType.Triangles Replace that with GL.BindVertexArray(mVertexArrayObjectIDs[1]); GL.DrawElements(PrimitiveType.Triangles, 6, DrawElementsType.UnsignedInt, 0);


0

The way I am doing it with my game is as follows: I have a very generic abstract Item class that is the basis for all types of items. This is what it looks like: public abstract class Item { public enum Type { weapon; } public abstract Type getItemType(); public abstract String getName(); public abstract String ...


0

Well honestly, in a personal project, whatever works for your needs is good enough. In a professional game, if you were working with a team of other programmers and designers you'd want it to be data driven so designers could tweak numbers and such. There's no clear cut answer though, it really is kind of a personal preference of the people involved, and to ...


1

//At the apex of the jump, Ruben's velocity.y is ~0 if (Math.abs(ruben.velocity.y) < 1) //If Ruben's velocity.y gets close to 0... { ruben.velocity.y = 0; //stop him Ruben.setState(Ruben.RUBEN_STATE_IDLE); } //velocity.y = +1 //jumping //velocity.y = 0 //no more jump left; begin falling (except the if activates) //velocity.y = -1 //falling Edit - ...


2

Do some manual tracing to determine where in the water the ship is... it could be as simple as checking the Y or Z coordinate being below 0 if your world is all water with the water table at level 0. Anyway, if the ship is in water, every timestep, push it upward with a force/impulse. The deeper in the water it is, the stronger the push. This should work ...


0

So, you want the angle of velocity relative to the x-axis? That'd be atan(V3.y/V3.x) and atan(V4.y/V4.x) for Q3 and Q4, respectively. Though, since the balls are almost aligned along the y-axis in relation to each other, it looks like maybe you're looking for the angle of V3/V4 relative to the surface at the point of impact, even when that doesn't line up ...


0

I will assume you are using a DragListener or something similar to achieve the "panning" effect. This is the method I have that keeps the camera within its bounds: private void keepCameraInBounds () { Camera c = this.getCamera(); Vector3 camPos = c.position; float HW = c.viewportWidth / 2, HH = c.viewportHeight / 2; camPos.x ...


0

maby this can help you http://en.wikipedia.org/wiki/Coefficient_of_restitution there is a break down of the entire problem


0

Here is an Intersects(A,B) method implementation taken from C# Rectangle.cs public bool Intersects(Rectangle a, Rectangle b) { return (b.X < a.X + a.Width) && (a.X < (b.X + b.Width)) && (b.Y < a.Y + a.Height) && (a.Y < b.Y + b.Height); }


3

This should do the trick. Split coords using "whitespace" Foreach resulting array Split the pairs to x y Parse strings to int Create point Add to list String coords = "0,0 0,1 5,2 7,4 10,5" String coordsArray[] = coords.split("\\s+") // Results "0,0","0,1","5,2","7,4","10,5" List<Point> points = new ArrayList<Point>(); for(String s : ...


2

You have to return true from touchDown. Documentation says: The GestureListener can signal whether it consumed the event or wants it to be passed on to the next InputProcessor by returning either true or false respectively from its methods. So, if you return false from touchDown, that is the first even raised in all cases, it stops event handling. If ...


1

In Bob's update method you do nothing with his velocity. He has no way of actually moving, with the code you have shown. You should do something along the lines of this before you reset the bounds: position.add(velocity.x * deltaTime, velocity.y * deltaTime);


0

Store the x points, y points and any other polygon related data elsewhere. Then in the render function you can save the data to a local scope set of variables (or an array or List if you want) and apply the transformations using good old mathematical operators. Then you can draw the polygon using this new data.


0

Setting the glClearColor, as Josh Petrie said, is only necessary to do every frame if you do not know if another part of your program is changing it. Although, usually you would be drawing your own background, which would cover the entire background, so the color should not matter. (Of course, you still need to clear the screen every frame to prevent ...


1

In LibGDX Doc Gdx.gl.glClearColor(0, 0, 0, 1); and batch.setProjectionMatrix(camera.combined); is setting in render() method at a time. I use this definitions in create() method at once, and it is running perfect. So why should i use this definitions in render() method? is't it a performance loss? The clear color is part of your OpenGL ...


0

Edit: As usual, I've not paid attention and answered a GL question with DirectX code; sorry... Although the API differs, the idea is very much the same. It will technically qualify as a performance loss, but it may be unavoidable. Ideally, you only want to notify the video card of changes to "whatever is current". Since you are in complete control of the ...


0

You need to unbind your texture object after using it for drawing certain shape. // In Texture class add void unbind() { glBindTexture(0); } public void drawTex(Texture t, int x, int y, int width, int height) { t.bind(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(x,y); glTexCoord2f(1,0); ...


1

The best solution is to re-create project with libGDX setup tool and copy all source code and asses into it from old project. .project file is file that contains information about project Eclipse should know. Do you use Gradle? If so, do you import project into Eclipse as Gradle Project (right) or as Eclipse Project (wrong)? And it's pretty bad idea to use ...


0

How can I design classes that are not too naive based on the game? The trick is to: Make a rough design (as you've done). Implement it (as you're doing). Test it. Adjust 1 and 2 as required, carry out 3, then rinse and repeat until it feels right. If you feel it can be improved, improve it until you do not feel the need to improve it any more. ...


1

I thought this was a good solution for a similar problem, from a question (and answer) by me here on SO. Abilities here are essentially AI if they are tickable. I have a runnable that just runs through all Actors and their abilities and tries to tick() them. interface for manipulating abilities: public interface ActorAbility { // doesn't work, but ...


0

BufferStrategy will often use VolatileImage for the buffer. Part of the use case of volatile image is that its backing buffer may be lost without warning. This require you to rerender to the volatileImage. What you can do as an optimization is test both contentsLost and contentsRestored inside the inner while loop and repeat the loop using continue if ...


1

You can create a Cell and fill that with a tile from the TileMapTileSet, then set that cell at (x, y) coordinates in a particular Layer. For example, the following code sets the tile at (32, 64) in a layer to tile 42 from tile set tileset_name; TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("some_layer_name"); Cell cell = new Cell(); ...


2

You could try to render the font to a texture, and lay that texture onto an deformed strip of triangles. But maybe somebody knows an easier way, idk


0

When Microsoft created the XNA framework (I know you're using Java, but the math is the same), they created a built in method to create a Quaternion from an axis and angle. The method they used (and you can "reflect" their managed code to verify it, see below) is the same as your first snippet: public static Quaternion CreateFromAxisAngle(Vector3 axis, ...


1

I managed to implement a pause funcionality that works perfectly well in my game, based on this tutorial: Create a volatile boolean variable in StartingClass private volatile boolean isPaused = false; Inside the run() method, use wait() surrounded by a try-catch. // GAME IS PAUSED try { if (isPaused) { synchronized (this) { ...


18

You're moving the circle by one pixel per frame. It should not come as a big surprise that, if your rendering loop runs at 30 FPS, your circle will move 30 at pixels per second. You basically have three possible ways to deal with this issue: Just pick one frame rate and stick to it. That's what a lot of old-school games did — they'd run at a fixed ...


8

Your code is currently running each time a frame renders. If the frame rate is higher or lower than your specified frame rate, your results would change as the updates don't have the same timing. To solve this, you should refer to Delta Timing. The purpose of Delta Timing is to eliminate the effects of lag on computers that try to handle complex ...


5

That's because you limit your frame rate, but you only do one update per frame. So let's assume the game runs at the target 60 fps, you get 60 logic updates per second. If the frame rate drops to 15 fps, you'd only have 15 logic updates per second. Instead, try accumulating the frame time passed so far and then update your game logic once for every given ...


2

Collision detection like this can be tricky. However - I do see a way around your problems. First, you definitely want to round off your "collision" position. In most cases, decimal numbers will cause collision problems when you're working with pixels (which are measured in whole numbers, usually). Here are two methods I thought up, in image form: (sorry ...


0

After a lot of research and continuing development using Slick2D, I have decided that the only way to do this in libGDX would be a fundamental re-write. After some tests, it also turns out that this is a Good Thing. The solution I have tried is to hold the data for the graphics in arrays, use TreeSet indexes to be able to quickly locate which items should ...


1

The easiest way to side-step this is: x = (int)x; y = (int)y; or x = round(x); y = round(y); Are either of these acceptable, visually? Edit: Diagram of modified SuperDoggy "Method 1" using floats: Precise overlap amount given by colliders Since you have so many cases, it may be helpful to make a helper for jiggling the rect: class CollisionHelper ...


0

Basically objects should define by themselves what happens to them when collision happens and the parent object owning colliding objects should check the collisions and notify the objects colliding each other by calling the collision handler routines. If your game is simple, you may not even need a specific collision checking interface. For example when ...


0

If you say that y starts at bottom, I'm going to assume that +y moves upward on the screen. If this is the case, the rectangle would build "upward". So x,y of the rectangle would be in the bottom left corner, and the bounds of the rectangle would extend upward and to the right. x + width; y + height To find the location of each corner, just need to add the ...


1

As I understand it, now you are making some transforms and pass the matrix as a uniform which is the same for all meshes. What you should do, is send different matrices for each mesh, which could be for example members of the mesh class. Then send the uniforms before rendering each mesh. Something like this: void Update(){ mesh1.transform = ...


1

First, although I would side with option 1 ("more OO"), both options are fine in practice; since normal boards are small. BUT, this sounds like the classical application for the observer pattern. The idea here is that your UI has it's state, which is initially derived from the initial state of the board. The UI registers a change handler on the game's model ...


0

I changed the code used to update things in the physics engine to this (just removing, recreating, then reading the rigidbody) (PhysicsEngine is a separate helper class containing the dynamicsWorld, anything beginning with an m_ is a private variable of the collider class): physicsEngine.removeRigidBody(m_rigidbody); m_transform = new Transform(); ...


1

A nice way to implement what you are trying to achieve would be to use a SequenceAction and built in libgdx actions : tooltip.addAction(Actions.sequence( Actions.show(), Actions.fadeIn(1f), Actions.delay(4.5f), Actions.fadeOut(1f), Actions.hide()) ) Actions.show() basically call setVisible(true) on your actor and Action.hide() call ...


0

I don't see any new Spring calls in the code you posted, if the springs are being instanciated in the getSpring method then you need to ask yourself if you always have to return a new instance. With Vector2 for example, it comes with a set method, so you can have a temporary (or many) instance in your class that you work with when doing vector math, so you ...


0

public void getInput(int delta) { if(Keyboard.isKeyDown(Keyboard.KEY_A)) camX-=1; } Is usually: float camX; float speedPerWholeSecond = 1; public void getInput(float fractionalElapsedSeconds) { if(Keyboard.isKeyDown(Keyboard.KEY_A)) camX -= (speedPerWholeSecond * fractionalElapsedSeconds); } This calculation is made FrameRate ...


0

Other information, the default constructor for the mat4 class is putting all the values to 0 This is incorrect. Your default matrix should be the identity matrix instead; i.e: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1


0

If you just want to create a "SettingsActivity" and a kind of main menu for your game : why not, you may save time indeed. You can start as much custom activities as you want from an Android LibGDX project. The libgdx launcher class usually generated in templates project is just an activity. So it's technically possible to start other activities and Android ...



Top 50 recent answers are included