New answers tagged c#
0
In some ways, your question is analogous to trying to run a Super Nintendo game on the original NES. If you have limited OS features, you should probably not try to develop using a high-overhead, modern framework (designed for modern OS features.) I wonder why you want to use .NET at all.
Regardless, your question made for a fun little research project, ...
0
I fixed the same issue by changing the COM port to COM9 or less. If the COM port number is 10 or greater, it won't work.
-1
XNA is the one of the best in C#.
Here is the link for the XNA Tutorials:
http://gamedev.tutsplus.com/articles/how-to-learn/how-to-learn-xna/
2
I've got a big, somewhat controversial discussion over here about why Game Components are "bad".
The most annoying thing about GameComponent, for me, is that it looks really important. It looks like a first-class part of the XNA API - like Vector3 or SoundEffect - but they're actually not (everything in the Game assembly is technically optional).
So many ...
0
A cross product gives you the perpendicular line. Both the negative and the positive vector represent the same perpendicular line. You'll have to change your order of operations to get the positive vector. Eg. DIR cross UP and UP cross DIR will give the same perpendicular line but might change the sign of the vector. (It's too early to do matrix computations ...
0
http://monogame.codeplex.com/discussions/390201
In this thread the user is struggling with getting the mouse-position(Mouse.SetPosition) to work. Unfortunately it is a bug within MonoGame so it is going to have to take some internal editing. Please look at the code/instructions he has posted within the thread so you can solve your error. It seems like this ...
0
It would be easier and faster to just remove the fixture on collision, instead of looping and checking for a string you set earlier.
I would update the OnCollision function as follows:
bool Player_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
//If category group 1
if (fixtureB.CollisionCategories == ...
1
Body.Dispose(bodyhere) is what you are looking for. It removes the body as well as all attached features. If you do not want to move Body.Dispose you can use World.RemoveBody(bodyhere) which removes the body after the current step. I would recommend you use the latter though.
0
Well, there are two ways of doing this:
Draw the entire Water object to a render target, then draw the final water target scaled and on the position you want. (this is the simplest way).
Draw the Water in a constrained area. For this you'll need do to something like this:
Create the Water by specifying a Rectangle as target in the constructor.
Every ...
-3
I don't know. Other then that, what you can do it simply construct a cache of these files, of which you can draw meshes on and tell xna to read them. This may be sorta slow but I actually think Minecraft does it. It constantly reads and writes data files, doubt you game is gonna be slowed down.
0
I've been using LuaInterface from c#/XNA. Mostly thus far I've been using it for entity creation (I too am using an entity-component system). That's been working pretty well. I can't speak to the speed as entity-creation is a comparatively rare event, though soon I intend to script collision handling, etc. I suspect it should be fast enough, I understand ...
1
Since I researched this in the past, I will post some code I had converted previously that may help you. This is basically the bare minimum of what you can do to achieve this effect. You will most likely want to add damping, and effects such as braking etc. It also works on a system where you only have two tires, one in front and one in back.
The code ...
0
Doom itself had little to nothing to do with the command line. They actually had APIs to do graphics back then, much of the use written ones use the method Stephan explained. I've also seen command line graphics done in C++ though, but it had to do with lots of code. None of this is possible in C#.
Anyway if you want to do graphics why bother with the ...
2
Games like Doom ran in 16 bit real mode under DOS. In this environment, there were system calls, called interrupts, that you could call to switch the display into several graphics modes.
The most popular at the time was mode 13h. It was called this, because you called interrupt 10h (h specify that this is a base 16 number), with register al loaded with 13h, ...
1
Problem solved with:
world.ContactManager.PreSolve += new PreSolveDelegate(PreSolve);
3
If you are using Visual Studio, you can download VS Anywhere. You can have many person typing codes simultaneously, and it doesn't lag much. Though it's kinda buggy sometimes. I'm using it with my friends all the time!
Here's the link , enjoy :)
http://visualstudiogallery.msdn.microsoft.com/99466148-ae68-4bd5-b66b-08bae7423a03
4
You're looking for a source control solution. These are a common part of the industry. Large Open Source projects often have dozens (and in a few cases hundreds or thousands) of individual developers spread over the entire world.
Solutions like GitHub, BitBucket, CodePlex, SourceForge, and more offer these services for free (often only if you make your ...
3
The normal answer to work on different files rather than trying to edit the same one. Anything big enough to involve multiple people will also involve multiple files.
2
In the overload of SpriteBatch.Draw that you are using, which you call like so:
SpriteRect = new Rectangle((int)Position.X, (int)Position.Y,
mSpriteTexture.Width, mSpriteTexture.Height);
theSpriteBatch.Draw(mSpriteTexture, Position,SpriteRect, Color.White, 0.0f,
Vector2.UnitX, 1f, SpriteEffects.None, 0);
You are passing SpriteRect into the method ...
1
Jesse Emond is correct. As for how to orient your code correctly; My best suggestion to solve your problem is to take a more class-oriented approach, even if just by a little bit. Rather than maintain a list of each enemy's position, maintain a list of enemies, each of which has a position. That way you could add other attributes to enemies too. Most ...
1
In C#, there are two situations that might happen when you copy something, for example Vector2 position = positions[0];:
If the object is a struct, it will copy the entire object. float is a structure, int is a structure, double is a structure. Basically, this quote from msdn sums it well: Structs are copied on assignment. When a struct is assigned to a ...
2
you change value of the variables - ep1, ep2, ep3, but you dont change objects coords.
For moving from right side to left side you can try anything like this (also you can use foreah):
for (int i=0; i<3; i++)
{
if (enemyPosition[i].X > 0)
{
enemyPosition[i].X--;
}
}
P.S. Sorry for my bad English.
4
There is a great number of text editors which allow several users to simultaneously edit the text. "Simultaneously" in this case means that when you open a document and someone else is/are editing it, you see those someone else's cursors, and what changes they make -- in real time. Obviously, you can make your own changes too, and they will be broadcast to ...
9
This is really hard to pull off, because real concurrent editing (on the same files) can be rather tricky.
I'd focus on some source code versioning system like SVN, Mercurial, or Git.
If you're using Visual Studio, the best option would be using their Team Foundation Server or - with the addon being in beta right now - Git.
Setting up a Git repository ...
2
You are trying to use a stack like a list. A stack has no random access. By that, I mean you can only take 'pop' off the stack what you just 'pushed'. Think of a stack of plates. You can only access the plate that you just put on the top of the stack.
Also, stack data structure is almost certainly something you do not wish to use for your purpose (updating ...
2
There are two problems. One, you are setting the velocity directly yet applying it as a force by taking into account the ridged body mass. Two, your "slowing down" is exactly the same as you are speeding up, you are not inverting the speed adjustment.
Though I am unsure why (if the object has a ridged body) you are performing this by hand instead of with ...
1
To sum up the comments:
Use the following strategy for the arrival behavior. This paper has more information.
target_offset = target - position
distance = length (target_offset)
ramped_speed = max_speed * (distance / slowing_distance)
clipped_speed = minimum (ramped_speed, max_speed)
desired_velocity = (clipped_speed / distance) * target_offset
steering = ...
1
3D Graphic with XNA Game Studio 4.0 has a chapter dedicated to this topic. It includes a complete process for generating the terrain and layering it with a variety of textures.
As luck would have it, that chapter is the sample provided by Packt on the book's page:
In this chapter, we will focus on building a full 3D environment. We will start by
...
0
To do what you want you need to use combine the char line of sight with the visibility of the tile.
Line of sight
You will use some algorithm to determine which tiles are visible or not at a given time.
There are several algorithms for that, research one suitable for your game type.
Each tile will have three states:
Visibility states
Unknow. This is ...
0
int mapx = (tileOnX + x);
int mapy = (tileOnY + y);
depthOffset = 0.7f - ((mapx + (mapy * tileWidth)) / maxdepth);
I forgot to add on the incrementing x & y values from the for-loop :/.
2
If you look inside each project file on github you can see the constants defined for each platform. I've extracted them here:
Android - TRACE;ANDROID;GLES;OPENGL
Linux - LINUX;OPENGL
MacOS - MONOMAC;OPENGL
Ouya - TRACE;ANDROID;GLES;OPENGL;OUYA
PSMobile - DEBUG;PSM
Windows - DEBUG;TRACE;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION
Windows8 - ...
0
It's not the fault of SpriteBatch. It's much more likely to be the fault of your Resources object. By the way, keeping track of resources is the job of the Game class. I would be skeptical that you have good reason to also assign a GraphicsDevice into your custom object. Afterall, Game already has one, and it ought to be a singleton.
Do you call ...
4
There are plenty roles in Gamedev. business, each role splits at least into a dozen, if you want to work at some company as a game developer here are some roles you can pick:
Artists: http://en.wikipedia.org/wiki/Game_art_design
GUI Artists, concept artists, general 2d artists, 3d artists, 3d sculpters, 3d animators,
pixel artists..
Game ...
1
You should know that this is hard coding, which you already know.
1- It's not enough just knowing how to code. There are mathematical subjects like trigonometry and algebra that are really useful and necessary when developing games (specially 3D ones). A little background on elementary physics is a good plus. In case you need guidance, there are books like: ...
3
1.
For a very simple game where you don't make a whole engine but just program the game as you please, this is enough, if you are able to learn things as you go along and the required math too (linear algebra comes to mind). For more complex games you either need to collaborate with artists and other content producers (3d-modelling if it's a 3d game), or if ...
2
If I understand you correctly, the coordinates you are getting from Mouse.GetState() always fall within the bounds of the screen (ie: 0 < x < 1680 and 0 < y < 1050).
This is normal.
The transformation matrix you are using is taking coordinates in "world space" and putting them in "client space" (which is the space that SpriteBatch then uses to ...
6
If you look at the Farseer Physics Engine 3.3.1 Testbed XNA code, you'll find an example called OneSidedPlatformTest. Inside this test is the code required to create Fixtures that act in the manner you're requesting.
Essentially, you override the PreSolve function in the following way:
protected override void PreSolve(Contact contact, ref Manifold ...
2
You need a variable that stores the position that was clicked ( the target of the object. ) This position could be set when you check the rest of your input like this
MouseState mouseState = Mouse.GetState();
if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed)
{
// This will give the ...
-2
Could this be causing your issues?
if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed)
You are saying here:
If the left mouse button was released AND is being pressed currently;
This seems like contradicting actions, mouse buttons are usually pressed first, then released to signify a ...
8
Using a while loop inside your game loop is a basic no-no. Think about how the code is being executed and you'll realize why it just teleported or was frozen and then teleported. (hint: how much of that code do you think is run before the next time your graphics are updated?)
You want to have a target position, then on each iteration of your game loop check ...
0
Vertices is in Farseer, in the namespace FarseerPhysics.Common:
using FarseerPhysics.Common;
1
Which part gets colored and how can I control it?
All of it and you can't unless you make your own shader.
I have a rounded block and my goal is to have the center filled with a certain color chosen by that parameter.
Tinting does not to solve this problem. What you want is making which was covered pretty thoroughly here.
1
In addition, the ball jumps weird when it touches two platforms at the
same time. Is there a possibility to avoid that weird jumping?
Nope your going to get that behavior with 2 platforms. You should combine them together into 1 shape. If the shape is more complex you can create a polygon that encompasses the entire area.
Anyways friction is going ...
1
So after much working I found out this is a bug with Unity. It happens in their Deferred Lighting -> RenderingToTexture pipeline. What's happening is they are cutting it to only show the first pass.
I'll be filing a bug report to Unity, and hopefully this gets fixed soon. As a simple work around I'm just setting the portal camera to forward rendering path, ...
2
Are you just adding force to the ball? If you need elastic collisions don't do this.
Farseer body has property called restitution, it controls ratio of the speed before and after collision.
1
If you want to save effort, use TCP. TCP does a lot of things automatically for you, including:
retransmission (unacknowledged packets are automatically resent),
reordering (packets received out of order are buffered until they can be processed in correct order),
flow control (the maximum transmission rate is automatically adjusted up and down to maximize ...
2
What you would do in this case, is draw a colored rectangle behind this texture first, and then draw this texture on top of the colored texture. This is assuming the center portion of your graphic is transparent.
SpriteBatch.Draw(BlankTexture, new Rectangle(Area, Of, Your, Texture), null, YourColor, 0, Vector2.Zero, SpriteEffects.None, 1);
...
0
Honestly, this is a solution in search of a problem. I can't see any benefits towards doing such a thing, and it doesn't seem like you can think of any either. Best just to take existing solutions and run with those. (and chances are "a new way of doing collision detection" will suck, when pretty damn smart people like the chipmunk physics and box2d devs are ...
0
That isn't about position sending performance. That's about server-client style. If you use input based movement (network), that means server decide your new position (authoritative server) and server tells your new position to you and other clients. If you use like position based movement, that means client decide his new position and tells that to server ...
-1
I have read some article about positioning and somebody says "use inputs for movement
update" and others says "use position posting".
Did they also provide reasons?
Using "input posting" increases program complexity because now with every input you need to post position and also update position on the client whereas with "position posting" you only ...
Top 50 recent answers are included

