Tag Info

New answers tagged

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


0

Ok, I found a solution to my problem: ConcurrentDictionary of string, VertexBuffer, ConcurrentDictionary of string, IndexBuffer and ConcurrentDictionary of string, Texture2D. With them, I can create each VertexBuffer and IndexBuffer for a texture name stored in a string. Then I can easily access all data I need: loading a Texture 2D, setting a name for it ...


2

Why do you want to start a new job for every single player? Create a single job that calculates the updates every minute for all players. This should be a lesser performance impact. Edit based on comments When doing this in a single job then use a single transaction for this job then no player gains an advantage as the new values are visible at the end of ...


1

Personally if it were me I would separate this for simplicity. Here's how ... Create an API call on your game server that will handle the saving of player Create a new executable that would simply make an api call to my game server every minute. Schedule that using windows task scheduler The new exe can then be configurable to call any number of things ...


1

Everytime you call this fonction you set hasBlock to false. Console.WriteLine ("has block == true"); will be executed only if the player collides with two enemies on the same frame. The solution could be to use a static or a global variable.


6

Your server would have some kind of background process (could also be implemented as a timer or a thread) which runs at regular intervals and updates all players. The process would run daily, hourly or every few minutes depending on how often you want the players farms to update and generate resources. Any online players would get notified immediately that ...


1

Here is a way to do it: Update your player's position by storing a vector of the input result, then check collisions with only the movement in y, if there's no collision, you can simply add the y movement to the player's position and do the same with the x movement. If there's a collision, check how far you can go with this x or y component, then add it and ...


0

I had this all the time when building my engine core code it means you passed something to directx that isn't correct. At a glance it appears you are passing a vertex array to a draw call .. this doesn't seem right to me although I haven't used monogame in some time (my code is sitting on the raw SharpDX API) so they may have done some wizardry to allow ...


1

You will need to mirror the origin of your sprite. Simply subtract the original origin from the width of the sprite. Something like: Vector2 origin = new Vector2(20, 10); int spriteWidth = 100; // from sourceRectangle or texture width SpriteEffects spriteEffects = SpriteEffects.None; if (flipSpriteHorizontallyAroundOrigin) {     origin.X = ...


0

I recommend you use an offset with your mirroring. this way, you can control where the symetry happens. Back when I was using XNA, I used to always consider the position of an object in the center and that certainly helped with all the flipping I needed. I used to take the 6th overload to the spriteBatch.Draw(...) method if you're interested.


0

Flipping a sprite around a given offset from its center is equivalent to first flipping the sprite normally (around its center), then offsetting the result. I haven't used XNA in a while, but you can do this by adding a translation to your drawing matrix. A somewhat hackier way to do this is to call SpriteBatch.draw with an origin and pass a scale ...


2

You're only asking for the mouse state once. You'll get the mouse state as it was at the time of initialisation. Specifically I think you'll get a copy of the mouse state at the time of initialisation, so it will appear to never change. Call Mouse.GetState() directly in your Draw function instead.


0

Try this spriteBatch.Draw(sprite, position, Color.Red);


0

Alright, so I tried pretty much everything. It didn't work. Then I resignated and tried putting everything into an XNA project instead of using MonoGame... And it worked without modification. Maybe it's because it's now compiled with PS/VS 3.0 as supposed to 4.0. Maybe because of magic. I dont know.


0

It looks like you have a view projection specifically for your lighting ... so my guess is that the GPU is culling any math outside your view frustrum ... Maybe try placing the "camera" for building your light map in a more "overview" type position or something? but surely you only want to do light math in front of your camera not for your whole scene?


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);


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


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



Top 50 recent answers are included