Tag Info

New answers tagged

0

I want to thank everyone who took their time to respond to my question. I finally came up with my own solution, which nevertheless was inspired by the suggestions here. Especially this comment from Ali.S turned out to be particularly useful: Just an idea, but you can provide your shader with another texture, representing the height of that pixel, and ...


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 ...


0

Sorry, but I can't comment yet, so, I will post as an answer. Just to be sure. I suppose you're not moving the top 2D Side Controller around, right? It controls the touchpad position and should stay in the place. If you need to move the player, move the "Player" object instead.


3

This problem is called Forward Kinematics. To solve this problem in general, I recommend creating what is called a Kinematic Chain, or Kinematic Tree. To do this, you will need knowledge of a 2D rotation matrix, or transformation matrix. A 2D 3x3 transformation matrix is defined as: H = [xx, xy, tx; yx, yy, ty; 0, 0, 1]; In this case, [xx, ...


0

For each part, it need to have an offset to the hero location. Eg, +20, +20. Its correct position when hero rotation is r is heroPosition.x + rotated(offsetX, r) and same for y. See http://en.wikipedia.org/wiki/Rotation_matrix for more info.


1

You need to move each part to 0,0 then rotate them, then move them back. Without doing this they just rotate around 20 units fron your character


4

Your main question seems to be: What would be the best way to draw frequently (really frequently, basically every frame) changing geometry with modern OpenGL? In most ways, there's no big difference between 2d and 3d OpenGL. The graphics pipeline has that one extra coordinate, Z, which won't be used as much in 2d, but that's about it. There's a few ...


0

You are not using the right variable to perform the collision time calculation. distanceXin is the distance between the two objects’ centres, whereas what you actually want is the distance between the two objects’ edges. Also, your code can be shortened and simplified a lot. Here is how I’d rewrite it: var boxCenterX = box.x + (box.width / 2); var ...


4

I can't say to be expert of this subject, and in my game project(s) I have concentrated more on 3D side, so my 2D side is pretty simple generally using things made for 3D side; and obviously, my perspective is at gaming side, so my 2D graphics is more about blitting sprites than geometry. From that perspective, 1) Squares and rectangles are pretty easy. I ...


0

a) Highlight adjacent tiles from current tile: use a modified floodfill with depth parameter to get all the nearest tiles within X depth/distance. b) allow GO to move on any of those adjacent tiles: the said floodfill should return a list of tiles, check if clicked tiled is in the list, if so, move GO. Edit: A possible implementation of said floodfill (in ...


1

You might be able to use a combination of the two approaches. You could turn off the collider of the thrown object when it's lifted, and use a simple, invisible, collider placed on the body like so: You could then fire this collider directly out from the body. It should be on the same plane as the player and the enemies, so it seems like handling hits ...


0

Here is an excellent tutorial on texturing. :)


-2

I recommend switching to LWJGL. The best thing is, all your Opengl knowledge can carry over. They have extensive forums and a decent wiki. It makes using Opengl a lot easier.


0

You cann't draw one texture on front of the plane and different on back. Use twho planes with different winding order of vertices. You need to implement 4 vertices for create plane 0,0; 0,1; 1,0; 1,1 // Scale it as you wish For front plane use counter clockwise winding order when you creating it 0,0; 1,0; 1,1; 0,0; 1,1; 0,1 For back plane use ...


0

I recommend a 3D models even though they will be super simple. You can texture all sides easily. You can also bend or morph those. Also lighting for effects or from the game table is possible if such things are required.


4

Instead of sending a packet whenever the key is held down, send a packet whenever the key state changes from pressed to released and vice versa. To account for network delays you can implement some kind of extrapolation on the server side and client side utilizing the time the packet was sent and received. For this of course you have to send the time the ...


0

Put simply, you only have the bare bones of a WinForms XNA based game. Your going to have to port your games code across from your XNA game project into your WinForms project. You'll have to create the MainLoop, and use it to call your MissileDisplay's Update and Invalidate Methods to simulate XNA's Update, and to call the GraphicsDeviceControl's Draw ...


1

The documentation shows the correct usage of the NinePatch: public NinePatch(TextureRegion region, int left, int right, int top, int bottom) left - Pixels from left edge. right - Pixels from right edge. top - Pixels from top edge. bottom - Pixels from bottom edge. Additionally you can find a tutorial ...


0

I have a simpler solution without using any physics or rigid bodies. For your character, it need to have both x,y position as position in screen and i,j as position on the grid with a flag called isMoving. When the character wants to move to i+1, j. Check if the cell at i+1, j is free. If so, set flag isMoving to true and set character i,j to i+1, j and do ...


0

Actually, there's no ready response for your problem. You can solve it in a variety of ways. If you are working with a "tile-like movement", you can simple check the next tile to see if is passable and only compute the movement if it is. It's a simple check if you have a array representing your world. Or a limited raycast if not. Also, Unity documentation ...


1

Assuming you are not going for a full out physics simulator: Your plane needs to have a position, velocity, direction(angle), acceleration and various maximum values. On each game step: velocity += acceleration * dt; velocity = clamp(velocity, 0, max_velocity); acceleration = 0; position += velocity * dt; On (de)acceleration: acceleration = ...


0

I would try using a screen buffer to draw all the walls (and possibly the characters) to. And then you can apply the perspective to all the walls at once. This should eliminate any errors you are getting because perspective is being applied to a single image rather than multiple images. You would than assemble the scene by drawing floor layer and then the ...


0

The easiest way to accomplish what you're asking is to split the objects up into different parts and animate them separately. From there you can either use a bone and joint system (similar to what Flash developers do) or, as you said, each part has its own animations.


0

You can use ctx.translate(dx,dy) to scroll the camera. Alternatively, have a camera object with x,y coordinates, and when drawing game objects, draw at object.x - camera.x.


1

In your code, movement() is being called every single update resulting in repeatedly calls completing after the first five seconds - this is not what you want. You want to call movement once and have movement repeat itself. There might be a better pattern which if someone else can show would be great, but something like the following should work and get you ...


0

You're setting your position equal to your velocity. Your velocity is very small because it's multiplied by delta time. This results in very small changes to your position, constrained to a very small area. Your object is moving, it's just not noticeable because the changes are so small. Additionally, all the small changes are not adding up because you're ...


1

If your touchables overlap, what you are "touching" is ambiguous unless you process the input by the z-order or user-defined precedence of the touchables (Code Clown's solution). You would have to handle this ordering of touch event receivers in a higher level of your code so that the touch event can be stopped by the first receiver in the hierarchy. The ...


2

You have to route the input by priority or z-order. First check HUD or GUI elements (on top) and the actual world ground at last (beneath). If a valid touch target is found/hit then you have to consume the input ond not routing it any further. Think of it as layers, for example [Touch] -> [Button] -> [Character] -> [Ground] Every touch will at ...


0

In case if everybody will be looking for something similar, I have found what I have been looking for in the youtube tutorial made by Stuart Spence "Unity3D - Unity 4.6 UI Objects Created at Runtime". Also the release of Unity 4.6 brought the functionality which I wanted. Hope it'll help somebody.


0

You can tell Unity to compress your textures on import and set this per texture and/or globally so you're free to create your assets at a higher quality. You can then play with the settings, leaving your source assets as is. They'll be compressed when you build the game.


2

Using a lower number of bits per pixel means you save filesize, loading time and texture memory. Also, sprite drawing will be faster because less data needs to be moved between graphic memory sections. When you develop a 2d game and your target devices are desktop PCs, these factors can usually be ignored as any modern PC should handle 32bit graphics with ...


1

Assuming the rope has no weight, this problem is about finding the lowest point of an ellipse (http://en.wikipedia.org/wiki/Ellipse ) where (PF1+PF2 == rope length) This image show how the ellipse is rotated. From there you can figure out the lowest point by tracing the ellipse with a binary search to find the lowest point. That's where the weight should ...


1

If it's 2D then you can simply use: rigidbody2D.gravityScale = -1;. You tagged the question 2D so this should be all you need to do. To toggle isntead of simply set you can change it to rigidbody2D.gravityScale *= -1; If it's 3D and you want the entire scene to have gravity reversed you can do: Physics.gravity = new Vector3(0, -1.0F, 0); If it's 3D and you ...


1

You should try to disable the rigidbody's useGravity property when the collision happens and use AddForce to fake your upwards gravity, pretty much like the example in AddForce documentation.


0

I have not tried any of these, but the following three solutions should work. Save the input data Instead of saving the Path2D object, save the values you have used to create the objects. As you said in the comments that you are creating the Path2D objects yourself using the API, you have the source data and you can control what to do with that. Java ...


0

You are using a constant turn rate. That is exactly what is causing the nice perfectly circular orbit. A more realistic approach for a guidance system would be to vary the turn rate directly with target proximity. This would give a spiral rather than orbit, and guarantee collision with a static target. It also gives a much more realistic flight path. The ...


0

From my short experience, these are my ideas/tips: What you are trying to do is called pixel perfect collision detection. Both player and texture should be inside a rectangle. Everytime Update function is called you should check "broad collision" to see if the two rectangles intersect (there is a Rectangle.Intersects method in XNA for rectangles) . If they ...


6

Don't move the world. Instead move the player and add a third concept called camera which follows the player. Then you can prevent the camera moving too close to the world boundaries. When rendering, subtract camera position from everything.


0

I fixed this by editing my code into this : function OnTriggerEnter2D(coll : Collider2D) { if(coll.gameObject.tag == "Key") { Destroy (coll.gameObject); keysGathered ++; } } I didn't realise it was this simple. Thank you for your time!


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 ...


0

I think you are over thinking this. Just have each object has its own update method that takes a delta time; then do obj.vy += 0.01 * dt; //gravity obj.y += obj.vy * dt; And call this for every object in each game step and your done!


1

That is not really an accurate normal map, by the way. You are just sort of assuming that the regions of the image where the luminance varies correspond with surface contours. That is frequently the case, but not necessarily - particularly in a subject this filthy, there will be a lot of dirty areas that appear to a sobel filter as contours rather than just ...


0

You want method 1 or 3 probably. 2 is generally not preferred because you need to update 2 points whenever the rect moves as oppose to 1 point in method 1 or 3.


1

It's primarily a technical issue that most companies won't use pure vector art in their games. I know many artists who make their creations in Flash or Illustrator, only to pump out a rasterized image that gets slapped on a polygon sprite. It's just a technical hurdle that most large companies aren't too keen on trying to figure out. Below is an example ...


1

"Which of these options is better from a practical point of view?" I'll interpret the word "practical" here to be distinct from "theoretically highest performance on a computer"... At two triangles per sprite, recomputing all the vertices on the host CPU will be not that expensive, & easy to think about. Or, since all the geometries are the same (two ...


1

You aren't limited to having only one MVP per VBO. So you would not in fact need to update the VBO every frame just because you stuff all of your sprites into a single VBO. What I do is store an instance ID with each vertex, which changes only on a per-model basis, and use those instance ID's to index into a uniform array of mat4's, one for each "instance."


4

What shapes are you using? If your shapes are convex (like circles, squares, rounded rectangles), you can just draw versions of different size and clip them to a triangle whose diagonal goes from upper right to lower left. I.e., zoomed in, light-to-dark: and dark-to-light: Then clip that: And then combine the two bezels: and finally draw the ...


0

You could get a bevel effect by underlaying the cells with upscaled graduated transparencies of themselves. This can also be used to get a glow effect.


-1

I see two possible solutions. One, is to use a 3D Vector even in a 2D space, and keep one of the coordinates fixed to the same number. Another one, is to create two different classes, Vector2 and Vector3, both inheriting from a base Vector class, and make your systems work with this Vector class directly, looping trough its components.


5

Use a 3D vector. For your 2D components, simply ignore the third component. The extra "cost" of an unused float is trivial in comparison to the rest of your architecture, and things like std::unordered_map<std:;string, Component*> are of far greater performance and memory concern than an occasionally-unused float anyway. You say that this would be ...



Top 50 recent answers are included