Tag Info

New answers tagged

0

You seem to be only setting the clip distance.x value also where is this clip function defined maybe that can lend some light on the subject? If memory serves, reimers approach was to use a plane and effectively reflect / refract the scene off that. Then combining the reflection and reflection and refraction maps with some peturbation results in water. ...


1

form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form.WindowState = System.Windows.Forms.FormWindowState.Maximized; The MSDN documentation does a good job of listing the platforms supported for each function. form.FormBorderStyle MSDN Documentation Platforms Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 ...


1

Since this is a basic function, it should be safe, but you should look into setting up a VM or finding a friend with an XP machine so that you can specifically test for it.


0

This functionality is pretty basic for Win32 API, you are pretty safe to use it on XP (and even below). The OS support for FormBorderStyle enumeration (on .NET 3.5), for example: Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows ...


0

The font format for XNA/MonoGame still stores the required info for kerning - obviously it needs it to draw text itself! You just need to get at it and use it from your own code. In MonoGame you can directly access the gylph data (see this source file). The Gylph structure contains the kerning information you need to layout your text correctly. (MonoGame ...


4

Magnets are kinda hard to simulate, but if you are looking solely for the effect of pulling and pushing objects you can use coulomb's law and simulate an electric field. Basically there are some points in the plane with an electric charge, which is either positive or negative. Since you are not aiming to do a physics simulation and for a game you are only ...


2

As far as I know, there's no existing algorithm for this, you'll just have to create one. You're already on the right track. For each cube, check the surrounding cubes to see if converting the current cube is reasonable. For example, say we're looking at cube #5 on a hill side. (green is solid, while is air). This image will represent the X axis. You'd ...


2

What I do is ignore the built in SpriteFont's in MonoGame and roll my own. If you use a tool like BMFont to generate the texture, writing a basic font renderer is pretty easy. First you'll need to grab a BmFont XML Serializer so that you can load the font file into C#. You can find one on pastebin here. http://pastebin.com/x3Z2mDC6 Then you'll need to ...


1

I guess what you're looking for is the Marching Cubes algorithm or some variation of it. Basically, you do exactly what you described: Look at the surroundings and then pick an actual "piece" that fits in.


-1

articles generally are not liked in Stack exchange but this is my go to blog post when trying to remember this http://www.david-amador.com/2010/03/xna-2d-independent-resolution-rendering/


0

Apparently the ultimate solution here was to subtract .5 from the position of each block as it was created so that the coordinates of the visual/physics worlds would line up with the block arrays. Changing the adxz calculation probably helped remove some bugs, but it wasn't related to the actual problem.


0

adxz is not adx + adz If adx and adz where vectors, it will work. But adx and adz are the distance of the vector in that dimension, when you add them you will have the vector (adx, 0, adz). You need to calculate the distance of that resulting vector. You need to use pitagoras for calculating that. adxz = Math.sqrt(adx*adx+adz*adz);


0

Shouldn't you add the file extension to the end of the string? For example: File.ReadAllLines(@"Levels\level_"+level+".txt");


2

It really depends on your game, but three considerations you need to keep in mind are: Does the positioning in the inventory have any game-mechanical effect? When it does, you need to handle the inventory positions server-sided. When the player organizes their inventory how they see fit, logs out and back in again, their inventory will be a mess again. You ...


2

Pixel color addresing is bad, it will work on a square but not on a rectangle. Change this: colors[ x * texture.Width + y ] = borderColor; colors[ x * texture.Height + y ] = Color.Transparent; To this: colors[ x + texture.Width * y ] = borderColor; colors[ x + texture.Width * y ] = Color.Transparent; EDIT: If you are using the other method, your ...


0

If you add the level files to your project, you have to sure to change the "Copy to output" property to "Copy always" or "Copy if newer" in the page properties of each file. Realize that the compiled binaries are stored in "bin\debug" or "bin\release" and executed from there, that's why "Copy to output" property exist, and it doesn't find the files.


1

I suspect your issue lies in the way a sprite batch works in MonoGame. The performance cost is coming from using different textures for each tile. Let's take a peek into the MonoGame source code and see what's going on. If you follow the code down through SpriteBatch.End you eventually end up in the SpriteBatcher.cs class around about here: ...


0

OK, after much fiddling and reading and re-reading of my and others' code, I've figured it out. If anyone sees anywhere I could improve this or sees any issues, please do let me know. Also, I hope that this saves somebody out there from the same frustration that I dealt with, lol. As I'd discovered, it would only work right on one axis at a time. The key ...


1

If you have the rotation matrix, I think the the easier is to get the cos between the normals and forget the vertex position. The cos will be max and near 1 when the angle among the two vectors is near 0. Each normal will have a face value so get the face value of the normal nearest to Vector3.UnitY is easy. Vector3 FaceNormals = new Vector3[] { ...


1

Last time I was looking at benchmarks for this (quite some time ago), Texture2D.FromStream was actually faster than Content.Load<Texture2D>. The overwhelmingly slowest part of the process, it turns out, is transferring data from disk. When using Texture2D.FromStream, you can load a PNG or JPEG file. These file formats use image-specific data ...


0

Not a significant one, though this depends a lot on what you're trying to achieve. Keep in mind that Texture2D.FromStream() returns a default format of SurfaceFormat.Color /w non-premultiplied alpha data, whereas with the pipeline you have full control over what you want to do with the texture. The distinguishing feature between the two is flexibility as ...


0

You can calculate the orientations that the die will fall on, then test the current orientation against a pre-computed list of orientations to get the number.


1

Vertices are stored in memory using local coordinates. So no vertex has a "currentPosition," they're always positioned according to their offset from their original origin. In the "world," they are displayed according to some transformation: scale and rotation about their local origin, then translation with respect to the world origin. With the exception of ...


1

There are lots of simple functions to realize those curves. (x^2)*40 - (x/8) + 200 This one grows in a smooth curve since I used x^1.5: (x^1.5)*5 - (x/9) + 200 Play around with the values.


4

Long ago I did the math for different growth functions for an RPG (that I didnĀ“t use in the end). I was playing around with five basic growth curves, as show below. The curves are: Red: Exponential. Grows slowly at the beginning, very fast at the end. Blue: Quadratic. Average growth curve. Black: Linear. Green: Flipped quadratic. Grows more slowly with ...


0

Where did 0.035f come from? I believe your mistake comes from doing (temp%32)/32. If you take a look at it closely, you see that you get values in range 0..31, but you divide it by 32, which gives resulting values from 0 to 0.98675 (0 to 247 in RGB) Correct code would be like so: float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0 { float ...


2

You could use a logarithmic function: Example function: double increment = Math.Log(level + 1); Example output: Level 1 increment: 0.693147180559945 Level 2 increment: 1.09861228866811 Level 3 increment: 1.38629436111989 Level 4 increment: 1.6094379124341 Level 5 increment: 1.79175946922805 Level 6 increment: ...


0

Since these are possible solutions I figured why not ... HP in my experience has always been something that increases very slowly, XP required for next level tends to be the big exponential. I would go with your second example or you could try reducing the 1.17 in your pow call to something like 1.02 for a more gradual increase. You could also consider ...


2

The answer to this question here should help explain how to use the GetData function. Basically, the data is stored in the return array from the GetData call is formed by reading the 2D texture from left to right, top to bottom, transforming it as follows: AAAA BBBB => AAAABBBBCCCCDDDD CCCC DDDD To determine where a given pixel in the 1D array is, we ...


1

Though Fault's comment is correct, what I usually do is to store the rotation and translation and then recreate the view matrix when required. (Full article here). The gist of the idea is: (btw the type of camera you are creating is often referred to as an Arc-Ball camera.) public class ArcBallCamera { public ArcBallCamera(float aspectRation, ...


2

Unfortunately Monogame cannot (yet) generate XNB files so you will need to use the original content builder from XNA 4.0. You can use the libraries from https://msxna.codeplex.com/releases to install XNA on Visual Studio 2012 or 2013, so that you can use it with Windows 8.1.


1

What you want to do is test how far the rectangle can move in a direction, then change it. For example: desiredX += speedX * timeSinceLastUpdate; desiredY += speedY * timeSinceLastUpdate; desiredRect = new Rectangle(desiredX, desiredY, width, weight); intersect = Rectangle.Intersect(desiredRect, collider); collisionWidth = intersect.Width; collisionHeight ...


1

Look again at your else/ifs: regardless of key combination pressed, only ONE direction is saved, because you override them. (the last of them in code) if left/right direction is pressed collision from the other side(right/left) is always assumed. (if (direction == Direction.Right) => move player to left side regardless where he is) quick fix: add another ...


1

You can use Texture2D.GetData() to copy texture pixel data to a Color[] in XNA. Texture2D texture=Content.Load<Texture2D>("asd"); Color[] tcolor=new Color[texture.Width*texture.Height]; texture.GetData<Color>(tcolor); After you have your Color array, you can do whatever you want with it, for example you could change certain colored pixels to ...


1

Perspective shadow maps like that are usually not used to shadow the whole scene, but for a single lamp or flashlight. If you want to shadow the whole scene, You probably don't want to use perspestive shadow maps, but rather orthographic ones (I guess you want shadows from the sun?). When you are creating an othographic matrix (MSDN) you specify its ...


1

Lets see what you're trying to do : you're trying to check if 1 entity collides with N other entities, but I suppose those collide as well. Basically (if I understood you right) you`re trying to do N*N comparisons every frame, or even N. You should, first and foremost, switch your data structure. Use a quadtree, with that, you will have a complexity of ...


4

You should be using layers. That is you have a naked character sprite. On top of that you add layers for hair, armor, gear, weapons. Depending on your actual game, you might do that in generic form, or split in parts or even add skeletal system. For example in Diablo 2 character was split into parts that were combined: Here's another example of ...


3

So as a warning I'm quite rusty with regards to shaders, but lets take a look at the BasicEffect's source code and see how Microsoft did it. Overview of the shader pipeline. Most interesting bits below. For a fog shader BasicEffect utilizes the below 2 components. A vertex shader performs per-vertex processing such as transformations, skinning, vertex ...


0

I read this and thought it would be a fun exercise this morning, so I decided to write this for fun. The implementation is pretty simple, keep adding lines at the end of each other until the last line is outside of the viewable area. The following code will draw a line infinitely going right. As an added optimization, the lines on the left side of the ...


0

You need to convert your cursor position into world position: Vector2 adjustedPosition = Vector2.Transform(touchCollection[0].Position, Matrix.Invert(camera.View)); Then your direction would be: direction = adjustedPosition - toolPos;


3

Keep in mind I had this problem over 2 years ago and I have since moved onto Unity 3D. This is more of a conclusion than a solution. The main problem was that moving the bones did not move the mesh. I used Cinema 4D to model and rig the model and exported as fbx. There are many fbx export options in C4D and I tried many variants with no success. Here are ...


3

This is essentially simple trigonometry. Assuming the center of the screen is your origin (i.e. (0, 0)), then it's pretty straightforward: x = length * sin(angle); y = length * cos(angle); Just insert the proper numbers and you end up with your vertex coordinates.



Top 50 recent answers are included