New answers tagged

0

You want to create a flat plane in 3D for this, set texture sampling to point sampling and use Matrix.CreateLookAt for the view matrix. I suggest you read up on what the world, view and projection matrices are and what they do.


0

This is the best solution I found to this problem: I splitted the table model to two separate models. One contains only the table "bed" (not sure if the name is right - I mean the table top / plate). The other model has all the rest, which includes some geometry drawn over the table top (this is a kind of a billiard table actually, so it has some ...


0

I found that rendering dynamic Entity-textures in XNA such as cubes or "planes" needs alot of HLSL knowledge, how to throw in shaders and more. I scrapped my XNA project and started with Java OpenGL "LWJGL". ThinMatrix had a good tutorial series with a quick runtrough of the glsl shader system. with "dynamic" I meant rendering and changing the ...


0

XNA has a Vector3.Forward, transform that with your cameras viewmatrix and if necessary set your y component to zero and normalize. Generally if this gives you trouble you should refresh your basic understanding of linear algebra.


1

Yes, make a boolean variable at the start in Game1. Like this: if (ballStart) { ball.update(); } Next, go to where you get the input from the user and change the boolean to be true once the key is pressed. eg. if (player1keyboardState.IsKeyDown(Keys.W)) { paddle1.direction.Y = -1; ballStart = true; } Hope this helps.


0

This is possible. As for how to do it, there are many ways. The simplest is probably to use a boolean variable. When the input is read, set that variable to true. Have a while loop use that boolean flag as its condition. When you press the button, the flag is set to true, and the loop happens. When you want to end the loop, set the flag to false again. ...


1

I suspect there is an error in your update or draw loop (note, both have a gametime parameter- but you should only update game logic in the Update loop). To demonstrate I made this demo: using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using System; using System.Diagnostics; namespace TimeStepDemo ...


0

My best guess is that you have some rounding errors. You aren't actually showing the movement code for the bullets so it's really hard to tell. Edit: Looking at the code, it should(tm) work. It definitely works fine to do things like this in the games I've written with XNA. The thing that bothers me is that your game doesn't seem to be running at all when ...


1

You need to create two different instances of the class. I suggest you not to check for input inside your class but in your game loop, so you can handle events for both instances. Pseudocode below: Pong::Paddle player1(texture1, bounds1); Pong::Paddle player2(texture2, bounds2); while(running){ if(keyDown == W) player1.setYDirection(-1); else ...


1

A possible way to solve this problem is to draw your shapes on the table texture, and then apply that modified texture to the table geometry. This would allow you to keep the shapes at the exact same level as the table, and removes the need for extra geometry to handle them.


2

There is nothing wrong with your algorithm, it finds the shortest path. Want you want you can do with a extra step after your path is found. Usually its called something like 'SmoothPath' first compress the path: you're only interested in the important points, the important ones are the ones where the direction changes: in this example the startPoint, the ...


0

Admittedly, this is an educated guess, so keep that in mind; WPF being the parent domain in this case means that all subprocesses like the XNA game are issued handles from that domain. I don't really know enough about the architecture behind WPF to adequately explain what it would be doing to cause the slowdown. However, as a possible fix, try automatically ...


0

I managed this stuff in love-2d: Here how i've done anim.started=false anim.curFrame=0 anim.accum = 0 function anim:update(dt) if anim.started then anim.accum = anim.accum+dt if anim.accum > anim.frameTime then anim.accum = anim.accum-anim.frameTime if anim.aType=="loop"then ...


0

Add a timer to keep track of your elapsed time. Take a look at the following: float Timer; const float FRAMES_PER_SECOND = 20; const float TIMER = 1 / FRAMES_PER_SECOND; void Init() { Timer = TIMER; } public void Update(GameTime gametime) { float elapsed = (float)gametime.ElapsedGameTime.TotalSeconds; Timer -= elapsed; if (Timer <= ...


0

I'm a VB person, so I don't know the C syntax, isn't there a For Each loop you can use instead of using your k variable? For each will loop all, it doesn't care how many.


1

From your code: for (k = 0; k < bullets.Count; k++) { for (k = 0; k < meteors.Count; k++) { if (rocket.rectangle.Intersects(meteors[k].rectangle)) { meteors[k].isVisible = false; } } } You use the same iterator in both for loops. It also looks as though you are reusing that (global) iterator from ...


0

This answer sort of tries to solve the question in a different way than you ask, but is useful in the context of games development, especially since your code appears to be working and finding a short path. Is there any place you store X & Y coordinates in nodes ? because you could apply interpolation by using a catmull rom spline by taking all the ...


1

Best thing you could do here, is just convert your Rectangle variables into a read-only property. This way you only need to update your position, and your Rectangle will always be up to date: class Bullet { public Rectangle rectangle { get { return new Rectangle((int)position.X, (int)position.y, 10, 5); } } class Meteor { public ...


0

Looks like you are only updating the position vector. When you are checking for intersection the rectangles haven't moved. You could change the rectangles x,y values as well but you have to change your spriteBatch.Draw call and omit the position. You might be tempted to skip the position vector entirely and only use the rectangles position. I don't think ...


2

The typical approach one - and the one taken to an extreme end by the "ECS" pattern that's hyped these days - is to have your module itself manage the components. That is, UIModule shouldn't have to iterate through the scene to find all UIComponent instances. Instead, the module should just have a list of the components it cares about. It can easily then ...



Top 50 recent answers are included