Tag Info

Hot answers tagged

4

in your keyPressed and keyReleased you can use a Map to map the KeyEvent.VK_* to GameInput make a new enum with the actions you want to be controllable enum GameInput{ FORWARD, LEFT, RIGHT, BACK,PAUZE,... } and in Controller you have a Map that you use: public void keyPressed(KeyEvent e) { game.setKeyDown(keyMap.get(e.getKeyCode())); } public void ...


4

It would be nice if I could retrieve the values from memory after the the shader has calculated them but it doesn't seem possible - or advisable But, it IS possible, and I would advise it: https://www.opengl.org/wiki/Transform_Feedback


3

You need to set to NPC a new target once in a while (e.g. each 5sec) and move it towards the target each tick little by little. Then it will be smooth. To avoid sharp turns upon setting a new target, you can mix target positions between old and new target for a second or two. Additionally, you might want to Google for "Steering behavior"


3

It seems to me that you will need to perform some sort of Frequency analysis on the audio file in question. You could either pre-process the file on level load (using the data to queue up your level actions), or perform the analysis in real-time. Either way, you'll want to divide your audio waveform into sections, each comprised of N samples, and then ...


3

It depends where the bottle neck is. If you IO bound (the game is always waiting on network IO) then yes compressing will help. If your game is CPU or memory bound then it will just run slower. You should compress before encrypting because cipher text is less compressible as a result of trying to remove patterns that could be used to reverse engineer the ...


2

I see the following reasons to encrypt data: Protect your users' actual sensitive data by adding to the amount of encrypted traffic. If hackers have to wade through not sensitive game assets, they're much less likely to find a user's actual sensitive data. Protect your servers. Using asymmetric key encryption (like TLS, what people still commonly refer to ...


2

The most effective way to improve collision check speed is to decrease the number of entities that needs to be checked against. Spatial partitioning such as octree helps but you can make further improvements. Suppose if currently you have one big list of collidables contains objects and bullets and in each collision check step you are looping through all ...


2

I don't know what RawImage exactly is here, but once you access pixel data of a Volatile or BufferedImage in Java you lose hardware acceleration. So even if these images were stored in vram before you called renderImage, they will no longer be once you access the underlying pixel array.


2

When you really want to get good performance, implement it in hardware using pixel shaders. The graphic cards GPU is optimized for performing the same operation on lots and lots of values in parallel, so it does so really quick. When you don't want to learn GPU programming, there are many libraries available which implement many common blend effects in ...


1

A rotation is essentially that for each sample in the resulting grid, find out which texels in your original texture that your filter footprint covers and interpolate them accordingly. This will be a lossy process, and if done repeatedly will quickly obliterate all interesting information in the image. If you only look at the nearest texel, you'll get a box ...


1

You could use an ArrayList to store all your stars in. When collision is detected you remove star from array so the star is no longer updated. So : create : ArrayList <Star> stars= new ArrayList<Star>(); add the stars : stars.add (new Star (param1, param2)); update : for (int i = 0; i < stars.size(); i++) { ...


1

Im not sure this works 100% but here is an idea to get you started. Let your square have x,y as center and r as its current rotation value. Let dx and dy be the displacement from center to one corner of the square when r is 0; On rotate-moving the square on the said corner: First get the corner's position: cx = x + rotated(dx, r); cy = y + rotated(dy, ...


1

Check out this blog entry on fixing your timestep. Essentially the advice here is to use a loop where you draw as much as you can until a fixed threshold of time has passed, then update. Here is the recommended game loop; double t = 0.0; double dt = 0.01; double currentTime = hires_time_in_seconds(); double accumulator = 0.0; State previous; State ...


1

Your canCollideWith method should be so that s1.canCollideWith(s2) == s2.canCollideWith(s1)I think. If not it means that collision will differ according to your array order. And if both return the same results you can test that only once. Then in your code, you give two differents definitions of your canCollideWith method canCollideWith(Sprite) and ...


1

I had forgotten to ask for a depth buffer when creating my window: Before: Display.create(new PixelFormat(4,0,0,4)); After Display.create(new PixelFormat(4,24,0,4));


1

Encrypting the data each player receives makes cheating and ripping of assets a bit harder, but not impossible. The data needs to be decrypted by your game client anyway, so the encryption algorithm and key must exist on the users machine. That means the users have everything they need to decode the network traffic. So you only add a layer of security ...


1

I have seen two ways of achieving this, one is to let the UserData of the Box2D Body hold the Sprite. body.setUserData(mySprite); And in the update you retrieve that and apply position and rotation to the Sprite according to the Body's transform; Sprite sprite = (Sprite)body.getUserData(); Vector2 position = body.getPosition(); // Center body is center ...


1

You can use the setUserData method to attach an Object to the box2D body (like for example a Sprite or an Actor): body.setUserData(sprite); Accordingly you can get your Sprite back like this: (Sprite) body.getUserData(); Note that you need to cast to Sprite.


1

This may not be the answer but, instead of using sprite.rotate(float angle); use: sprite.setRotation(float angle); Hope this helps! :D


1

The getRGB() method picks all channels, even alpha. You can extract color and alpha channels with something like: Color col = new Color(pixels[pixelIndex]); System.out.println(col.getRed()); System.out.println(col.getGreen()); System.out.println(col.getBlue()); System.out.println(col.getAlpha()); Depending on the image format (ABGR, ARGB), retrievieng ...


1

You want linear interpolation using the alpha channel of the incoming (source) pixel. This goes by different names in different APIs (mix (...) in OpenGL, lerp (...) in D3D). No matter what you call it, it boils down to the following: public static int alpha_blend(int c1, int c2) { int a1 = (c1 & 0xff000000) >>> 24; //int a2 = (c2 ...


1

It looks like you are using a matrix to rotate the image when it is drawn. This does not change the position values you have stored in your class, but it does affect how the image is drawn. If you want to know where the 4 corners of the image are drawn you will have to keep track of them yourself. Same is true of the bounding box. If the bounding box is to ...


1

Use a timer (delay, countdown, whatever you want to call it). Each time a menu movement is applied, reset the timer. Do not allow another movement until the timer has expired. Unlike the event-based approach, this still allows you to hold a key and move through a menu, but only at a limited speed. An implementation might look like: double m_LastMove = 0; ...


1

Assuming the board view is from directly above, for simple rectangular boards, you can do pretty well by interpolating from the four corners of the active playing area.


1

I don't know java, but it seems to me that the Command pattern would help you. It is a behavirol pattern by the Gang of Four wich encapsulates your information to be executed, in your case this information is user input. I'm copying/pasting wikipedia here import java.util.List; import java.util.ArrayList; /* The Command interface */ public interface ...


1

Yes, they are required to sign in with a Google Plus account. It's possible to use the leaderboard without requiring users to sign in. You won't be able to connect players without them having accounts. The service is free because it allows Google to collect data on its users (play trends, in app payments, social sharing, etc.), thus it requires the users to ...


1

TextField has a method called getText(), it may never be null but may return an empty string. txtUsername = new TextField("", mSkin); txtUsername.setMessageText("test"); txtUsername.setPosition(30, 30); mStage.addActor(txtUsername); String test = txtUsername.getText(); System.out.println(test); ...


1

Why are you moving the viewport? You should only really touch it when the screen resizes. because you move the viewport everything outside it will not be drawn. instead adjust the view matrix to move the "camera" to where the player is this allows you to have larger levels as well.


1

The basic cause of the problem was that my value for screenY (2D location of mouseclick on Y-axis) was incorrect and so passing it to any valid picking ray function returned invalid results. My old working project got the mouse position values from the org.lwjgl.input.Mouse class whereas the new project is using java.awt.event.MouseListener. The lwjgl ...


1

Your map[][] is static so the three objects (layers) will access the same map (and overwrite it). You should make it nonstatic to allow each object to have it's own. Secondly the fileParser() method is private so you will have to either make it public or call it inside the class.



Only top voted, non community-wiki answers of a minimum length are eligible