Tag Info

New answers tagged

0

In the SpriteEffect source, the world matrix is actually float4x4 MatrixTransform


0

I believe you are running into the same issue as below. It is fixed in the development branch. MonoGame 3.2 installer installs Windows (DX) framework assembly into WindowsGL You can check by following these steps. Install MonoGame 3.2, then inspect Assemblies/WindowsGL/MonoGame.Framework.dll in ildasm. The assembly manifest is referencing SharpDX ...


1

Thanks @JoshPetrie for getting me on the right track. I know XNA is basically dead but I could not find a good sample to do something that should be simple. Below I've posted all relevant code to perform an aperture close or open effect. Before you run, add a sprite called Background to your project. The result of the code should be an aperture closing and ...


0

So there is a DirectX library called the DirectX Tool Kit which is a porting of the underlying XNA code written by people who were members of the XNA team. Below is the code relevant to you question. SpriteBatch.cpp PrepareForRendering() // Set the transform matrix. XMMATRIX transformMatrix = (mRotation == DXGI_MODE_ROTATION_UNSPECIFIED) ...


3

A point p is inside a circle at c with radius r when (p.x - c.x)^2 + (p.y - c.y)^2 < r^2 is true. Using this equation you can color any points inside a circle one color (such as "transparent") and anything outside the circle a different color (such as "black"). You can even fade the edges of the circle, if you are so inclined. You can write a custom ...


3

The reason you wouldn't put the initialize logic in the constructor is because Initialize is the first point where you can be sure that GraphicsDevice is set up. Recall that, while your constructor for your Game-derived class may create GraphicsDeviceManager, the graphics device itself is only created when Game.Run() is called (an instance method, so it ...


0

XNA implicitly supports what you're doing via it's GameComponent classes. Taking advantage of these will solve your issue, but then you're shoehorned into using their design approach. The Game class -- which your main object loop inherits from -- has a handy property called Content, which is a reference to a ContentManager instance. This is all set up for ...


0

I've found a solution: public void Draw(SpriteBatch spriteBatch) { //Interpreting tiles as bounds //Sub-ing and add-ing 128 just to get more tiles than visible, //so the world feels like more alive // 16 - is tile size // 128 / 16 = 8 more tiles int startX = (va.area.Left - 128) / 16; int endX = ...


0

Looking over the code you should be able to : switch (CurrentGameState) { case gameState.mainMenu: MediaPlayer.Stop(); MediaPlayer.Play(song); break; case gameState.gamePlaying: MediaPlayer.Stop(); MediaPlayer.Play(song2); break; } I wasn't sure if calling .Stop() without music playing ...


0

Yes, you need both Windows 8 and the Windows Phone SDK, a detailed tutorial describing how to setup up MonoGame for WP8 (written by a Microsoft Employee) can be found here Edit: There is (supposedly) a way to install the Windows Phone SDK on Windows 7 ( described here ) but it is not officially supported by Microsoft and therefore not guaranteed to work.


-1

Unreal Engine 4 offers full next-gen engine source code written in C++ for $19/month per person. It's rendering capabilities are better than Unity3D or UE3 and you have a special visual scripting system called Blueprints. You can write your own C++ classes, reuse them in game or Blueprints.


-2

Unity3D is a great engine to use, it has a drag and drop entity component system yet it can be manipulated from .NET code, Boo or UnityScript(form of javascript). http://unity3d.com/


0

So you are on the right track but using not understanding what some of the parts of your code do. GameTime.TotalGameTime Property Game time since the start of the game. GameTime.ElapsedGameTime Elapsed game time since the last update. MiningElapsed is currently set to the number of seconds since your game started. As a result its always going to ...


1

The problem with arrays is that they can not resize dynamically. When you exceed the initial capacity, you need to allocate a new array and copy the whole array over. When you want to remove an entry in the middle, you need to move all entries after it down by one. These are both very expensive operations when your array is large. The List class is an ...


1

A health/damage mining system would be much more flexible and should be easier to implement than a fixed, time-based system. Basically, assign each block a health value, and your pickaxe a "mining damage" value, and whenever the pick strikes the block, you subtract its damage from the health of the block. When the block's health goes to zero or below, the ...


4

I found I had to do the following to set the FPS limit free. In your Game class, do the following: graphics = new GraphicsDeviceManager(this); // I have this stored as a member variable graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = false; Note that an unlimited FPS can cause unpredictability in physic engines, and network games. A ...


1

The FPS is capped at 60 because of the default value of true on Game.IsFixedTimeStep. If you set this value to false it should allow your FPS to go to whatever you need it to. Game.IsFixedTimeStep on MSDN


4

There are many different variables that come into play regarding this. If two faces are next to each other that use different textures, light levels, colors, etc.. you more than likely won't be able to join them together anyhow (nearly anything's possible with enough work, but it'd probably be FAR too much work). If, however, you have a lot of cube faces ...


0

I have figured it out. Turns out, my logic was correct, however the imported mesh had it's normals messed up for whatever reason. Maybe I used incorrect settings when exporting FBX file from Max. I have calculated my own normals so now everything is correct. Triangle temp = new Triangle(); temp.Vertices[0] = ...


0

I have managed to get my application working with the first approach I was attempting to use. It appears that the way I am disposing of the GameScene is the cause of the issue. It seems as though it is also disposing of the SceneManager functionality which the GameScene is derived from as I noticed that none of my update and draw calls in both SceneManager ...


1

You want to get real familiar with a handy-dandy 3D math operation called Dot Product. Pretty much all 3D graphics libraries include this 3D math function; for example http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector3.dot.aspx The dot product can be used for a number of things, but every use boils down to: when you take the dot product ...


2

The XNA SpriteFont class uses the SpriteBatch and Texture2Ds to back it. Just as when you render any other Texture2D if you use vectors with non whole numbers XNA samples the overlapping source pixels leasing to the unexpected behavior you are experiencing. To avoid the issue make sure the the you use whole numbers when assigning the location so that the ...


2

I don't have a specific example for an Isometric camera, but it sounds like you are asking about the basic camera system in general. The camera I use in my games is somewhat simple and is illustrated in the figure below: The Camera class contains the following member variables: Vector2 position; Vector2 viewport; Rectangle worldRectangle; Converting ...


1

public static Texture2D ConvertToTexture(System.Drawing.Bitmap b, GraphicsDevice graphicsDevice) { Texture2D tx = null; using (MemoryStream s = new MemoryStream()) { b.Save(s, System.Drawing.Imaging.ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); tx = Texture2D.FromStream(graphicsDevice, s); ...


2

for (int i = 0; i < total; i++) { particles.Add(GenerateNewParticle()); } This is being called once per particleEngine.EmitterLocation assignment. This means you're creating 100 particles in the same location every frame. Try this: for (int i = 0; i < total; i++) { particles.Add(GenerateNewParticle()); ...


5

First of all please read Array versus List: When to use which? for coverage of this issue from a general perspective. Now to focus on your case, I would recommend a list if: You don't know how many enemies you will have in advance (and don't want to worry about handling resizing) You would like to remove enemies from the middle (and don't want to worry ...


2

SharpDX is a DirectX wrapper, not an XNA one. XNA's GetData methods are higher-level abstractions on top of the underlying DirectX functionality. If you're using the D3D9 interface, you probably want a variant of LockRectangle. If you're using D3D11 you probably want some variant of MapSubresource (or the similar method for D3D10). Note that in D3D9 the ...


0

While not properly portable (it is only for Windows and Linux). MonoGame has an event for text input that uses properly buffered keyboard input. MonoGame.Framework/GameWindow.cs /// Use this event to retrieve text for objects like textbox's. /// This event is not raised by noncharacter keys. /// This event also supports key repeat. /// For ...


2

MonoGame intentionally uses the same namespaces as XNA as required to make it a drop in replacement. For Example look at the MonoGame VS2010 Template using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; The using Microsoft.Xna.Framework.Input uses MonoGame if Monogame is included as a reference; ...


1

It seems I have managed to resolve the issue by using the overloaded Texture2D.GetData (int level, Rectangle? rect, T[] data, int startIndex, int elementCount) method. Texture2D texture = level.Tiles[x, y].Texture; Rectangle source = level.Tiles[x, y].Source; Color[] colorData = new Color[source.Width * source.Height]; texture.GetData(0, source, colorData, ...


0

If you look at the first line inside the foreach for the matches, you're reducing the item by 1. Without knowing your item/recipe structure I can offer this. Your recipe should know the quantity of each item it needs. So when it makes a match it should be doing something along the lines of this. match.ItemCount -= recipe.ItemQuantity(match). This way the ...


1

Just build the XNB file on your personal machine, and use that file in your project. Remove the .spritefont file from your content project. Then add the built XNB file to your game project, in an appropriate directory (generally "Content") and set its properties (select it and press F4) to "Copy if newer". This is off the top of my head. So look at the ...


0

Fixing the table helped a lot, but the main issue I had was I was assigning the wrong AO values to the NegZ and PosZ face vertices. This meant that when I tried to fix things, other things broke as I tried to compensate for the unknown variable of the Z axis being rotated. The table in the original post is updated, but basically the side cases shouldn't ...


1

DrawUserIndexedPrimitives() takes your vertices and indices from RAM, sends them to buffers on the GPU, then draws them. That means the data is sent to the gpu every time you call this function. DrawIndexedPrimitives() requires you to create and set both a vertex and index buffer before calling it, and the data will stay on the gpu until those buffers are ...


2

Some high level details on storage in XNA can be found on this MSDN page. The paragraph with the most relevance to your question would be: User storage is in the My Documents folder of the user who is currently logged in, in the SavedGames folder. A subfolder is created for each game according to the titleName passed to the BeginOpenContainer method. ...


2

Yes, you can add (Drawable)GameComponents at any time. When you add them before Game.Initialize (eg: in your game constructor), they will have their Initialize method called when Game.Initialize is called. If you add them after Initialize is called on your game class, then they will have their Initialize method called when they are added to the ...


1

It took quite a while but I've found the solution and am posting it here for anyone else who has the same issue. The draw code remains the same. Pixel Shader: // Texture sprite sheet. uniform extern texture ScreenTexture; sampler screen : register(s0) = sampler_state { Texture = <ScreenTexture>; MinFilter = POINT; // Stops pixels bleeding ...


3

Real-life gunsights have the exact same problem. There are several ways you can deal with it: Do nothing. Just have the bullets fly from the gun in the direction the player is facing, and accept that they won't hit exactly where the player is looking at, but rather some distance below and maybe off to one side. This is a reasonable choice for characters ...


0

After a good nights rest, I have worked out the solution. By moving the problem logic : for (int intlc = 0; intlc < Items.Count; intlc++) { if (Items[intlc] != null) { if (Items[intlc].invhover) { if (ms.LeftButton == ButtonState.Pressed && ...


1

In a first person camera, you can move the camera forward by adding the camera.direction values, scaled by speed * delta values, to the camera position. This moves the camera forward in the direction that the camera is facing. To move the camera forward on just the X and Z planes, you add camera.direction.x and camera.direction.z to the position. Create a ...


1

If you are doing a classic 2d platformer (which you [the OP] are not [this answer is directed at people who are doing it]) then you could use something like DragonBones (open source). Even in your situation, you could make some considerations and implement something like this. If you must have the tool look perfect from a lot of angles and can't compromise ...


2

You've discovered the equation for constant linear acceleration. This equation is used in situations of uniform acceleration to determine final position and velocity. Essentially you start with your acceleration and integrate with respect to time to get the equation for velocity and integrate that for the equation for position. a = a //Acceleration v = ...


1

Ok, it was my View property of the Camera class that was causing it. Really tired today, ugh. Here is the updated code: public Matrix View { get { return Matrix.CreateTranslation(new Vector3(GraphicsDevice.Viewport.Width * 0.5f, GraphicsDevice.Viewport.Height * 0.5f, 0)); } }


0

I assume your noise is outputting height values for the terrain - the style shouldn't matter, as that's applied after the noise is done with. Add a lower octave of noise and add (or otherwise combine) them together. The lower the octave (larger amplitude and lower frequency) the larger/longer the features it creates, so to add hills you need to add that sort ...


0

I'd highly suggest you look into implementing a Quadtree. This would allow you to run a query to fetch all the objects in your viewport, as opposed to checking every single entity before a draw. Have a look at the following sample query code: List<Entity> entitiesOnScreen; entitiesOnScreen = QuadTree.GetObjects(Viewport.Rectangle); foreach ...


0

1) You don't need to calculate the visible objects in a single frame, you may use a bit bigger viewport, and calcultate only 500 objects per frame, if you have 20000 objects and your framerate is 50fps, in 40 frames you will have the right list, and it will take 0.8 secs 2) if your objects are not very complex or are static, sometimes is faster to put them ...


0

You would likely have to switch over to the 3D (lower level) rendering and then use instancing which offloads most of the work to the GPU. http://www.float4x4.net/index.php/2011/07/hardware-instancing-for-pc-in-xna-4-with-textures/


1

The error indicates that if you are using textures that are not powers of 2 (128x128, 256x256, etc), that you must set the SamplerState parameter of SpriteBatch.Begin to SamplerState.LinearClamp instead of SamplerState.LinearWrap. Judging from your code it looks like Grass and Stone are powers of 2, but the Person is not. To fix the problem you'll need to ...


0

If you've been looking at steering behaviours you've probably seen this page which is by the guy who first came up with steering behaviours. If you want to know about the general background of how steering behaviours work that's the best place to start. The steering behaviours were implemented by the same chap in a library called OpenSteer which was ported ...


4

Since your AI is steering based it's pretty simple. You need to weigh your forces based on how important they are. The closer you get to obstacles the more important they should be, otherwise chasing should be the most important. There are a couple different ways to implement it, but I always found having some "max force" worked best where you iterate over ...



Top 50 recent answers are included