Tag Info

New answers tagged

0

It's a good idea to keep your static terrain in a single buffer. Updating it for small changes is totally reasonable. However for something like an animation I think you're going to need to diversify your terrain system. Objects like doors, levers, and other objects that need to be animated should not be drawn with the same buffer as the terrain buffer. ...


1

Do not use full screen quads for your light volumes. A simple way is to draw a sphere for each light, in the position that the light occupies and of the same radius. This way, only the fragments actually affected by the light will be affected and your fragment shader will not be executed for the entire screen surface.


0

I'd like it to be at least vaguely human-editable I would take this to be your first requirement. Storing it in the colour data of a bitmap is probably not going to help here so I'd go with something else. For a 2D tile based game it might be worth investing some time to learn how to use an existing tile based map editor like Tiled. I'm currently ...


0

Just store it in JSON. Storing it in the colors of a bitmap seems like you're being tricky for no real reason.


2

A possible problem is in your SetInStartPosition(). For setting the Y position it should be position.Y = screenBounds.Height - texture.Height... not screenBounds.Width - texture.Width...


0

Instead of disposing the contentmanager entirely; do ContentManager.Unload() This clears the contentmanager's content, freeing up resources and leaving it ready to load new content when it suits you. See: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.content.contentmanager.unload.aspx I use this method myself in a game where the player ...


1

If you work out your matrix math, you'll see that the resulting w component of a vector/matrix multiplication depends on what's in the 4th column of the matrix. If the last column is [0 0 0 1] (which it typically is for most translation/orientation matrices), then the w component will be whatever the w component of the vector was. However for a typical ...


0

Ok, found it. It sits in shader inputs, here is the shader that works: float4x4 Projection; Texture2D FontTexture; sampler TextureSampler = sampler_state { texture = <FontTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp; }; struct VertexShaderInput { float4 ...


0

You could use Texture2D.SetData to modify a section of the texture. Fill the section with array of Color. Using your example code: the array should be the dimension of (crate.width*crate.height) filled with Color.Transparent. The target rectangle is new Rectangle(0,300,crate.width, crate.height). See: https://msdn.microsoft.com/en-us/library/ff434430.aspx


1

I think you solved your problem already, but for any future visitors to the site here it is as well. The problem that you were having was that you never called Graphics.ApplyChanges() after you changed your graphics settings. This resulted in the screen not actually being updated, and the smaller screen after exiting is due to an odd orientation bug. ...


0

You can now do this without installing anything extra. In a brand new MonoGame project you should have a Content.mgcb file. That should bring up the MonoGame Pipeline app. You can right click on the Content node in the tree and add a new item. Select `SpriteFont Description'. That will get compiled correctly and you should be able to load it in your code.


2

I've recently been implemented something like this in the MonoGame.Extended library. Creating a letterbox / pillarbox viewport in MonoGame is actually kinda tricky. I'll do my best to provide a good answer here. There's basically 3 parts to it. The first is creating a scaling matrix to pass into the SpriteBatch.Begin call. The variables represent your ...


3

It's probably multiplying the colours. That's pretty typical for a parameter like this. Each colour channel is interpreted as a value from 0 to 1, then multiplied with the corresponding colour channel of the tint colour. So: _______________ times red (1, 0, 0) = white (1, 1, 1) = red (1, 0, 0) grey (0.5, 0.5, 0.5) = ...


3

So you're not using a modelling program- thus you'll have to provide the cube/texture information yourself from code. Let's start out simple with one textured triangle. VertexPositionTextures contains Vertex (location of points in space) and texture (where does that point match to a point on an image). Keep in mind that the location for the texture is on a ...


1

Honeybunch supplied quite a bit of information on creating waves. It's something I can definitely use, but not exactly what I was looking for. I'm posting an answer to my own question because I figured out how to do it. For future reference: Before rendering anything, I render the water to a rendertarget (let's call it RT_WaterHeight) using a custom shader. ...


1

Wave generation isn't a simple task. The easy way is expensive. Right now you're rendering your water as a plane, why not just render all of your textures onto a more complex mesh? You could, with an algorithm, take your water plane and re-buffer it to take on a new shape every frame. It's messy and very intensive but it can work. Here are some resources ...


3

To turn off antialiasing, all you have to do is change your sampler state to SamplerState.PointClamp in your spriteBatch.Begin() call. Here's a short code example: spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, null)); // Draw text here using DrawString spriteBatch.End(); ...


0

Using a rendertarget may be a solution if you only have that one sprite. If your game requires a lot of those rotated, scaled sprites, you might want to look into a pixelshader. You might calculate the occurence of a color within your intended pixel size (your spritepixels may be 3x3 screen pixels) and color the resulting screen pixels accordingly.


0

Ok it's actually really simple to achieve. First of all as u mentioned, ur engine direction describes the path of movement. This makes it comfortable to work with. First of all, always store a vector of the direction ur moving. Next u must have a vector of the lookat of ur engine. So for now when u start moving, let's say right, the both the direction ...


0

for (int x = 0; x < Tilemap.MAP_WIDTH; x++) { for (int y = 0; y < Tilemap.MAP_HEIGHT; y++) { if (tm.tile[x, y].bounds.Intersects(playerBounds)) { if (tm.tile[x, y].getSolid()) { foundCols++; } else ...


0

It is not just a rectangle/rectangle test. It is also a dot product test to determine which side of the slope line the other object is on. For this you will need to initialize the 2 end points of your slope. This becomes a line segment and the corners of your slope's collision rect. So your slope and rect both share point A & B. The algorithm gos like ...


0

Try adding effect.Alpha = 1f; The alpha channel was probably premultiplied (check the texture properties in your content section).


0

Managed to fix this by using Viewports when drawing the Rectangles / Cameras GraphicsDevice.Viewport = new Viewport(_level); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, _camera.ViewMatrix); DrawLevelTiles(); spriteBatch.End(); GraphicsDevice.Viewport = ...


1

I think you might be overcomplicating things - why not just set the "origin" of the hook to new Vector2(0, hookTexture.Height / 2) If you simply draw it like this: spriteBatch.Draw(hookTexture, position, null, Color.White, rotation, new Vector2(0, hookTexture.Height / 2), 1.0f, SpriteEffects.None, 0.0f); That way the hook is drawn and rotated around ...


2

One way to do this, is to draw your text 2 times in a different color at specific offsets. For example: public static void DrawText(SpriteBatch spritebatch, SpriteFont font, string text, Color backColor, Color frontColor, float scale, Vector2 position) { Vector2 origin = Vector2.Zero; spriteBatch.DrawString(font, text, position + ...



Top 50 recent answers are included