Tag Info

New answers tagged

2

I had to solve this issue a long time ago, and all I did was do: One normal collision check. One where I shifted everything up one "world-height" (aka screen height) Shift down Shift left one "world-width" (screen width) Shift right Up and Right Up and Left Down and Right Down and Left eg: if(x + width > test.x && x < test.x + test.width ...


0

Your code wasn't formatted and structured well at all (bunch of if, else is never pleasant to read), so I decided to re-write everything and give you an example of how you are supposed to code in C#. To check if you are structuring your code well or not, you can check 2 things. 1) Your Game class needs to be less than 50-80 lines of code. 2) How easy would ...


2

When you resize your game resolution you need to update every single rectangle in your game (every button, etc) and multiply it by a proper scale, so that the "hitboxes" would work, which would be a lot of work. So, a smarter way of achieving the same result is simply by multiplying your mouse position by a Vector2 scale = new Vector2(originalWidth / width, ...


2

Viewports and Clipping (Direct3D 9) is a good overview that, while specific to D3D9, is relevant to all APIs. The viewport defines an additional transformation that occurs before rasterization: Direct3D uses the viewport location and dimensions to scale the vertices to fit a rendered scene into the appropriate location on the target surface. Internally, ...


1

I don't think you need XNA any more. Just double click on Content.mgcb to open the content editor. Right click on Content -> Add -> New item -> Spritefont description, give it a name, e.g. "testfont" Load your spritefont in game: var font = Content.Load<SpriteFont>("testfont"); Use it! spriteBatch.DrawString(font, "hello", new Vector2(10, 10), ...


2

For arbitrary shapes The basic algorithm goes like this: // Gets the distance from a point to a shape made of line segments. float GetDistance(Shape shape, Vector2 point): min_dist = float.max; foreach LineSegment line in shape: dist = GetDistance(line, point); min_dist = min(min_dist, dist); return min_dist; // Gets the ...


0

So, after @Jon helped me understand HLSL and render targets, I could understand more tutorials on the internet and I found my answers in the following links, if anyone is interested: First I read some of the Riemer's tutorials of HLSL to understand its basics. Second I read RB Whitaker's HLSL/Effect tutorials to get some more information. Third I read the ...


3

There are a couple ways. This way shows how you can do it at runtime by grabbing out all the vertices to build the BoundingBox around the model. The first answer on this page is super old but the basic idea applies to use a custom processor for your model in the content pipeline so you can compute the BoundingBox and store it in the Tag property of the ...


1

It seems you may have misunderstood the purpose of Tiled or tilemapping in general, so maybe I could clarify a bit for you. In simple terms, a tilemap is an array values that you use to construct your stage from an image (the tileset). It basically tells your code which part of the image to draw on the game screen. This way, you can reutilize your assets ...


0

Basically: Render the player's shadows to a render target. Render the shape to a render target. For each pixel, determine if it both (A) contains a shape pixel and (B) contains a player shadow pixel.


1

You could sum it up like such: Pre-game install: You can't assume they are there. Post-game install: You can assume (hope) that the XNA 4.0 Redistributable installed correctly and the assemblies reside in their respected locations. If the scripting that the user will be doing is tested and run solely in game, then I would think that this is a safe route ...



Top 50 recent answers are included