Daily Archives

Articles indexed Saturday November 3 2012

Page 12/13 | < Previous Page | 8 9 10 11 12 13  | Next Page >

  • Java game object pool management

    - by Kenneth Bray
    Currently I am using arrays to handle all of my game objects in the game I am making, and I know how terrible this is for performance. My question is what is the best way to handle game objects and not hurt performance? Here is how I am creating an array and then looping through it to update the objects in the array: public static ArrayList<VboCube> game_objects = new ArrayList<VboCube>(); /* add objects to the game */ while (!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { for (int i = 0; i < game_objects.size(); i++){ // draw the object game_objects.get(i).Draw(); game_objects.get(i).Update(); //world.updatePhysics(); } } I am not looking for someone to write me code for asset or object management, just point me into a better direction to get better performance. I appreciate the help you guys have provided me in the past, and I dont think I would be as far along with my project without the support on stack exchange!

    Read the article

  • Basic Use of ApplyImpulse

    - by nycynik
    I am trying to apply a force to a bunch of b2_dynamicBodys, but it seems to only work for a random number of items and then stops with an error. //create some items to move bodyDef.type = b2Body.b2_dynamicBody; for(var i = 0; i < 5; ++i) { fixDef.shape = new b2PolygonShape; fixDef.shape.SetAsBox(1,1); fixDef.friction = 1; fixDef.restitution = .1; bodyDef.position.x = Math.random() * 10; bodyDef.position.y = Math.random() * 10; bodyDef.linearDamping=1; bodyDef.angularDamping=.8; itemsArray.push(world.CreateBody(bodyDef).CreateFixture(fixDef)); // store for later } then i try to apply a force later with: angle = 20; for (var xIdx=0; xIdx<itemArray.length; xIdx++) { itemsArray[xIdx].GetBody().ApplyImpulse(new b2Vec2(50*Math.cos(angle*Math.PI/180),50*Math.sin(angle*Math.PI/180));); } the error I receive is TypeError: 'undefined' is not an object (evaluating 'c.x') Is there something wrong with saving the items for later use when I am creating them? Does anyone know what is causing this.

    Read the article

  • Efficient way of detecting a touched object in a game?

    - by Pin
    Imagine a Sims-like 2D game for a touch based mobile phone where one can interact with virtually any object in the scene. How can I efficiently detect which object is being touched by the player? In my short experience, looping through all the visible objects in the scene and checking if they're touched has so far done the job, but when there may be many many moving objects in the screen that sounds kind of inefficient isn't it? Keeping the visible moving objects list can consume time in itself as one may have to loop through all of them each frame. Other solutions I've thought are: Spatial hashing. Divide the screen as a grid and place the visible objects in the corresponding bucket. Detection of the clicked object is fast but there's additional overhead for placing the objects in the correct bucket each frame. Maintaining a quad-tree. Moving objects have to be rearranged all the time, the previous solution looks better. What is usually done in this case?

    Read the article

  • How are bullets simulated in video games?

    - by mahen23
    I have been playing games like MW2 recently and, as a programmer, I tend to ask myself how do they make the game so immersive. For example, how to they simulate bullet speed. When an NPC fires a bullet from his gun, does the bullet really travel from his gun to the given target or do they they completely ignore this part and just put a bullet hole on the target? If the bullet is really travelling from the gun to the target, at what speed is it actually travelling?

    Read the article

  • 3D game engines for XNA games

    - by Jenko
    Before I start development of an XNA game, I need to choose a 3D game engine to develop upon. Is this belief unfounded? Does XNA have basic object transformation, lighting and mesh/texture importing functionality by which you can develop a decent 3D side-scrolling game? Chances are I'm going to need a 3D engine such as Torque X to handle most of the special effects, animation and sound for me. What are the engines that you recommend building an XNA game with? What work reliably in your experience? Is XNA alone enough? do you have repositories of code that work directly with XNA to create effects and other game environments with sunlight, fog and rain?

    Read the article

< Previous Page | 8 9 10 11 12 13  | Next Page >