# destructivArts

Member

77

205 Neutral

• Rank
Member

1. ## Xna 3d coordinates problem

Changing the order worked but it still is skewed. My view matrix is: view = Matrix.CreateLookAt(pos, target, up); and the Projection matrix is view = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)Game.Window.ClientBounds.Width / (float)Game.Window.ClientBounds.Height, 1, 100); Edit: Ok, well changing the order worked but that wasn't why it was skewed. I was defining the vertices in an array of VertexPositionColor and I was overwriting the Object at index 1. ie. [CODE] vert[0] = new VertexPositionColor(variables); vert[1] = new VertexPositionColor(variables); vert[1] = new VertexPositionColor(variables); [/CODE] So thank you for your help, worked perfectly
2. ## Xna 3d coordinates problem

I'm going through a book, and the example it gave me seems like is should work, but when I try and implement it, it falls short. My Camera class takes three vectors in to generate View and Projection matrices. I'm giving it a position vector of (0,0,5), a target vector of Vector.Zero and a top vector (which way is up) of Vector.Up. My Three vertices are placed at (0,1,0), (-1,-1,0), (1,-1,0). It seems like it should work because the vertices are centered around the origin, and thats where I'm telling the camera to look but when I run the game, the only way to get the camera to see the vertices is to set its position to (0,0,-5) and even then the triangle is skewed. Not sure what's wrong here. Any suggestions would be helpful. Just to make sure I've given you guys everything (I don't think these are important as the problem seems to be related to the coordinates, not the ability of the game to draw them): I'm using a VertexBuffer and a BasicEffect. My render code is as follows: [CODE] effect.World = Matrix.Identity; effect.View = camera.view; effect.Projection = camera.projection; effect.VertexColorEnabled = true; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserPrimitives<VertexPositionColor> (PrimitiveType.TriangleStrip, verts, 0, 1); } [/CODE]

4. ## Reviews with Perspective

Go look at the other one, this was a mistake. Sorry guys (Mods if you wanna delete this, thats cool) (Delete this one ;) ) Peter
5. ## where to go now?

Here's some ideas: [url="http://lazyfoo.net/articles/article01/index.php"]Progression[/url]
6. ## Java tips

I took a class exactly like that. I signed up for the class and then over the summer taught myself the curriculum. So when I got to class, I was able to finish the projects the teacher assigned us while she was still teaching the new lesson. (ie. Today we're going to learn how to create a calculator program. To do that we need functions. She teaches, I type.) And while everyone else was working on the project, I was looking up stuff to make games with. If the class you're in is an AP track course you won't learn a whole lot more than the basics of java. Books and the internet are your best friends. I used Learn Java in 21 days (I didn't finish in 21 days, but it's still a good reference), and http://math.hws.edu/javanotes/. For game related programming tips I read Core Techniques and Algorithms in Game Programming. The code's in C++ but theres more in pseudo code and the C++ code is easy to read. Hope this helps, Peter
7. ## Updating the Player in a Quad Tree

Ok, I'll keep that in mind. One other question: I've implemented an ObservableInput object that calls this update function every frame: [CODE] public void updateInput(MouseHandler m, KeyHandler k){ //Mouse mousePos = m.getMousePos(); //Keyboard keys = k.getKeyStates(); } [/CODE] For some reason it's not calling the update function for it's observers. I don't know if this has anything to do with it but I'm setting the Entities as observers when they are placed in a data list of a node. I'm removing them when they have to be shifted, and adding them again when they are placed. I know the ObservableInput object sees them, so I don't know why it's not updating. Just to be thorough, heres the entity update function. [CODE] public void update(Observable obs, Object obj){ } [/CODE] And the players: [CODE] @Override public void update(Observable o, Object obj){ System.out.println("1"); if(o instanceof ObservableInput){ ObservableInput obs = (ObservableInput)o; buttonState = obs.getButtonState(); mousePos = obs.getMousePos(); keys = obs.getKeyState(); } } [/CODE] I'll keep looking in the meantime, Thanks again for all the help! Peter
8. ## Updating the Player in a Quad Tree

Thank you, I looked up the Observer/Observable, and I won't actually have to change much to implement it. As to your concern about putting too much into a base class, can't I just create children classes for each kind of entity I need? All I would have to do is put empty functions into the entity class so that its children could use them. (Entity already takes care of animation updates, rendering, and collision detection.) Thanks again for the help! Peter
9. ## Updating the Player in a Quad Tree

I'm writing my game in Java, but this seems pretty language independent. I have a quad tree set up to organize all my game entities. All game entities are children of an entity class, and that is what the quad tree sees all its data as. Almost all entities simply get a list of nearby entities for their update function. The player, however, needs this in addition to the keyboard info and mouse info. (I think in typing this I've figured out the solution but I'll ask anyways.) How do I make the tree recognize that it is a Player object and know that it is ok to pass the keyboard and mouse states to it? I've thought of two ways to solve the problem, I'm just wondering which is most effective (or if there's a better way all together). 1.) When I loop through each nodes data, check if each data object's class equals the player class. Create a new player object equal to this data object, update it, and then replace the original with the new one. Example: [CODE] if(data[i].getClass() == new Player().getClass()){ Player p = (Player)data[i]; p.update(keyboard, mouse); data[i] = p; } [/CODE] 2.) (And this is the way I think is best right now.) Create an update function in the Entity class that takes in the keyboard and mouse, which only its Player child class will ever call. In the Player class I just override it, and put in the player update code. Then all I have to do is check if the data's class is the same as Player (as I did above). I'm still new at this, so I'm just looking for input. If there's a better way, please let me know. Thanks, Peter
10. ## Making Screen follow the player?

Here's what I've done: Create a camera object that follows the player. Every frame, subtract all your active objects x and y coordinates from the camera's, and set those values into each objects local position variable. If either value is negative or outside the cameras view, dont draw it. Otherwise draw the objects at their local position. Then you just have to base all mouse clicks off local positions and you already have it calculated. I don't know if I explained this well enough so heres an example: Lets say you have an enemy at a global position of 35,40; The camera's top left corner is at 0,100 and has dimensions of 100,100; You would draw the enemy on screen based on the calculation: int locX = entX - camX; >> locX = 35-0 = 35 int locY = camY - entY; >> locY = 100-40 = 60 so you would draw the entity at 35,60. Drawing things in this way accomplishes a lot. You know what is visible so you don't draw things that don't need to be. You don't have to reposition everything in the world every frame. You also have things local positions for mouse events. Hope this helps, Peter

Thanks again for the advice. I'm not to the point yet where I am doing stand alone builds of the game yet, and I'm running it from within Netbeans. Is it possible to alter the amount of memory available to Netbeans? Also I split the background apart into pieces. They're now 2000 x 1500 px and as I'm loading them I'm getting the same error as before. If the problem is the game is loading too many images at once, is there a way to check if an image is finished loading before continuing? Thanks again, Peter