xna

Drawing Isometric Tilemaps

穿精又带淫゛_ 提交于 2019-12-11 01:17:40
问题 I've been working on drawing an isometric map with C# / XNA Game Studio, and while I've gotten pretty far it doesn't look quite right and I was wondering if anybody can help. Here's the code I have for drawing the map: public void Draw(SpriteBatch theBatch, int drawX, int drawY) { if ((drawY % 2 == 0)) theBatch.Draw(tileTexture, new Rectangle((drawX * width), (drawY * length / 2), width, length), Color.White); else theBatch.Draw(tileTexture, new Rectangle(((drawX * width) + (width / 2)),

Drawing a rectangle multidimensional array

橙三吉。 提交于 2019-12-11 00:49:12
问题 I'm currently working on an inventory system however I'm having problem figuring out how I should draw it. I have an array of rectangles looking like this: Rectangle[] Inventoryslots = new Rectangle[24]; // 24 slots now I want to draw the slots like a 6*4 columns, 6 slots in width and 4 slots in height. I'm drawing them like this until I have figured out how I should draw them on y as well: for (int i = 0; i < Inventoryslots.Length; i++) { Inventoryslots[i] = new Rectangle(i * 33, 0, box

XNA 4: import FBX problem

Deadly 提交于 2019-12-11 00:45:55
问题 I have a problem with importing 3D model from FBX file. Source model contains 575 objects + 1 camera and looks like this: http://habreffect.ru/files/23d/542fa7f67/source_model.png In XNA prepared with content pipeline model contains 82 meshes, and 576 bones. So, when I draw my model, I see only part of source model. Result picture like following: http://habreffect.ru/files/28a/6e61c0215/Result_view.png My drawing code: GraphicsDevice.Clear(Color.CornflowerBlue); Matrix[] transforms = new

What is the difference between running in VS 2010 and running a builded EXE?

≯℡__Kan透↙ 提交于 2019-12-11 00:18:54
问题 As a school project we've created a C# XNA 4.0 Game that runs perfectly when run (in either Release or Debug) from Visual Studio 2010 itself. However, when it's built, the game inexplicably crashes at a certain point. The responsible code portion seems to be this: while( true ) { if( Client.readInfo ) { t.Stop(); t.Dispose(); // Save last good IP to file string toWrite = IPinput.filledIn; using( StreamWriter file = new StreamWriter( "multiplayer.dat", false ) ) { file.WriteLine( toWrite ); }

Cannot Modify Return Value because It is not a Variable

帅比萌擦擦* 提交于 2019-12-11 00:18:07
问题 Pass by Value strikes again!! player.Vector.X += player.Speed * (float)gameTime.ElapsedGameTime.TotalSeconds; does not work. Vector2 v = player.Vector; v.X -= player.Speed * (float)gameTime.ElapsedGameTime.TotalSeconds; player.Vector = v; fixes this problem. This is explained here: Can't modify XNA Vector components The answer was very well explained and works just fine, but it has been 4 years since it was posted. My question is, since its been 4 years, is there a better way to fix this

How to “round” a 2D Vector to nearest 15 degrees

六眼飞鱼酱① 提交于 2019-12-11 00:08:30
问题 I'm working on a simple game and I'm trying to simplify part of the 2D collision reaction in the game. When certain objects hit walls, I'm calculating a collision normal ( collisionPoint - objectCenter ) and reflecting based on that normal. I'm interested in rounding that normal vector to its nearest 15° but I'm not sure of a good way to go about that. My current thought is doing something like this float angle = atan2(normal.Y, normal.X) * Rad2Deg; float newAngle = ((int)(angle + 7.5f) / 15)

Storing vector XNA Animations

丶灬走出姿态 提交于 2019-12-10 23:35:41
问题 I'm working on XNA C# when I came upon this problem where I need to store easily editable animation data such that my game will be able to render and play it. It's something like this: I have a texture flying across the screen from (0,0) to (800,600) pixels. This will last 5s. How do I represent it in data and also write it such that the game is able to interpret and do the necessary in the Draw and Update methods. It's OK if I need to do some extensive coding. 回答1: A simple domain specific

HSV to RGB Stops at yellow C#

时光总嘲笑我的痴心妄想 提交于 2019-12-10 23:22:45
问题 I'm writing an HSVtoRGB method for my game framework, and when going through the hues, this happens -> http://youtu.be/ACBwR_0iMWE. Here is the code. public static Color HSVtoRGB(float hue, float saturation, float value, float alpha) { if(hue > 1 || saturation > 1 || value > 1) throw new Exception("values cannot be more than 1!"); if (hue < 0 || saturation < 0|| value < 0) throw new Exception("values cannot be less than 0!"); Color output = new Color(); if (Math.Abs(saturation) < 0.001) {

Launch Internet explorer from xna game on WP7

心不动则不痛 提交于 2019-12-10 23:21:01
问题 I'm wondering if I can start Internet Explorer from my XNA game running on Windows Phone 7? I'd like to redirect my players to my website. Best regards, 回答1: I believe that you can still use the WebBrowserTask. Use it like this: var wbt = new WebBrowserTask(); wbt.URL = "https://stackoverflow.com/"; wbt.Show(); You'll just need to add a reference to Microsoft.Phone.dll X-REF: How to launch IE7 from a Windows Phone App? 来源: https://stackoverflow.com/questions/4145836/launch-internet-explorer

Render isometric text in 2D

拈花ヽ惹草 提交于 2019-12-10 22:43:23
问题 How can I render text in the form of an isometric projection? I understand the principle but I'm not sure how to actually transform a SpriteFont programmatically to do this. Example of what I mean: I'm not even sure what I should be searching for. It seems I could accomplish this by using an isometric projection matrix and a 3D mesh font, but that seems overcomplicated considering I'm working in 2D. Any ideas? 回答1: SpriteBatch.Begin takes a Matrix parameter, transforming the sprites you draw