Search Results

Search found 1457 results on 59 pages for 'bullet physics'.

Page 9/59 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Best depth sorting method for a Top Down 2D game using a 3D physics engine

    - by Alic44
    I've spent many days googling this and still have issues with my game engine I'd like to ask about, which I haven't seen addressed before. I think the problem is that my game is an unusual combination of a completely 2D graphical approach using XNA's SpriteBatch, and a completely 3D engine (the amazing BEPU physics engine) with rotation mostly disabled. In essence, my question is similar to this one (the part about "faux 3D"), but the difference is that in my game, the player as well as every other creature is represented by 3D objects, and they can all jump, pick up other objects, and throw them around. What this means is that sorting by one value, such as a Z position (how far north/south a character is on the screen) won't work, because as soon as a smaller creature jumps on top of a larger creature, or a box, and walks backwards, the moment its z value is less than that other creature, it will appear to be behind the object it is actually standing on. I actually originally solved this problem by splitting every object in the game into physics boxes which MUST have a Y height equal to their Z depth. I then based the depth sorting value on the object's y position (how high it is off the ground) PLUS its z position (how far north or south it is on the screen). The problem with this approach is that it requires all moving objects in the game to be split graphically into chunks which match up with a physical box which has its y dimension equal to its z dimension. Which is stupid. So, I got inspired last night to rewrite with a fresh approach. My new method is a little more complex, but I think a little more sane: every object which needs to be sorted by depth in the game exposes the interface IDepthDrawable and is added to a list owned by the DepthDrawer object. IDepthDrawable contains: public interface IDepthDrawable { Rectangle Bounds { get; } //possibly change this to a class if struct copying of the xna Rectangle type becomes an issue DepthDrawShape DepthShape { get; } void Draw(SpriteBatch spriteBatch); } The Bounds Rectangle of each IDepthDrawable object represents the 2D Axis-Aligned Bounding Box it will take up when drawn to the screen. Anything that doesn't intersect the screen will be culled at this stage and the remaining on-screen IDepthDrawables will be Bounds tested for intersections with each other. This is where I get a little less sure of what I'm doing. Each group of collisions will be added to a list or other collection, and each list will sort itself based on its DepthShape property, which will have access to the object-to-be-drawn's physics information. For starting out, lets assume everything in the game is an axis aligned 3D Box shape. Boxes are pretty easy to sort. Something like: if (depthShape1.Back > depthShape2.Front) //if depthShape1 is in front of depthShape2. //depthShape1 goes on top. else if (depthShape1.Bottom > depthShape2.Top) //if depthShape1 is above depthShape2. //depthShape1 goes on top. //if neither of these are true, depthShape2 must be in front or above. So, by sorting draw order by several different factors from the physics engine, I believe I can get a really correct draw order. My question is, is this a good way of going about this, or is there some tried and true, tested way which is completely different and has somehow completely eluded me on the internets? And, if this does seem like a good way to remake my draw order sorting, what's the right sorting algorithm for reordering the Bounds Rectangle collision lists, and how do you deal with a Bounds Rectangle colliding with two different object which don't collide with eachother. I know these are solved problems, but I've only been programming for a year so any specific input here will be greatly appreciated. Thanks for reading this far, ye who made it -- sorry it was so long!

    Read the article

  • multithreading problem with Nvidia PhysX

    - by xcrypt
    I'm having a multithreading problem with Nvidia PhysX. the SDK requires that you call Simulate() (starts computing new physics positions within a new thread) and FetchResults(waits 'till the physics computations are done). Inbetween Simulate() and FetchResults() you may not 'compute new physics' It is proposed (in a sample) that we create a game loop as such: Logic (you may calculate physics here and other stuff) Render + Simulate() at start of Render call and FetchResults at end of Render() call However, this has given me various little errors that stack up: since you actually render the scene that was computed in the previous iteration in the game loop. I wonder if there's a way around this? I've been trying and trying, but I can't think of a solution...

    Read the article

  • SFX Played Once per Collision or Hit

    - by David Dimalanta
    I have a question about using Box2D (engine for LibGDX used to make realistic physics). I observed on the code that I've made for the physics here below: @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { // TODO Touch Up Event if(is_Next_Fruit_Touched) { BodyEditorLoader Fruit_Loader = new BodyEditorLoader(Gdx.files.internal("Shape_Physics/Fruity Physics.json")); Fruit_BD.type = BodyType.DynamicBody; Fruit_BD.position.set(x, y); FixtureDef Fruit_FD = new FixtureDef(); // --> Allows you to make the object's physics. Fruit_FD.density = 1.0f; Fruit_FD.friction = 0.7f; Fruit_FD.restitution = 0.2f; MassData mass = new MassData(); mass.mass = 5f; Fruit_Body[n] = world.createBody(Fruit_BD); Fruit_Body[n].setActive(true); // --> Let your dragon fall. Fruit_Body[n].setMassData(mass); Fruit_Body[n].setGravityScale(1.0f); System.out.println("Eggs... " + n); Fruit_Loader.attachFixture(Fruit_Body[n], Body, Fruit_FD, Fruit_IMG.getWidth()); Fruit_Origin = Fruit_Loader.getOrigin(Body, Fruit_IMG.getWidth()).cpy(); is_Next_Fruit_Touched = false; up = y; Gdx.app.log("Initial Y-coordinate", "Y at " + up); //Once it's touched, the next fruit will set to drag. if(n < 50) { n++; }else{ System.exit(0); } } return true; } Now, I'm thinking which part o line should I implement for the sound effects. My objectives to make SFX played once for every collision (Or should I say "SFX played once per collision"?) on the following: SFX played once if they hit on the objects of its kind. (e.g. apple vs. apple) SFX played once on a different sound when it hit on the ground. (e.g. apple land on the mud) Take note that I'm using Box2D for the Java programming version thanks to LibGDX via Box2D engine and I edited the physics body using Physics Body Editor before I implement it to code. I tried to check every available methods for body, fixture definition, or body definition to code for the SFX when hit but it seems only for the gravity and weight. Is there possibly available on the document for SFX played when collision happens if possible?

    Read the article

  • How do I properly use multithreading with Nvidia PhysX?

    - by xcrypt
    I'm having a multithreading problem with Nvidia PhysX. the SDK requires that you call Simulate() (starts computing new physics positions within a new thread) and FetchResults() (waits 'till the physics computations are done). Inbetween Simulate() and FetchResults() you may not "compute new physics". It is proposed (in a sample) that we create a game loop as such: Logic (you may calculate physics here and other stuff) Render + Simulate() at start of Render call and FetchResults at end of Render() call However, this has given me various little errors that stack up: since you actually render the scene that was computed in the previous iteration in the game loop. Does anyone have a solution to this?

    Read the article

  • What are the common character animation techniques used in tile based hack&slash games?

    - by Gorky
    I wonder what kind of animation techniques are used for creature and character animation in modern hack&slash type tile based games? Keyframing for different actions may be one option. Skeletal framing may be another. But how about the physics? Or do they use a totally hybrid system of inverse kinematics supported with a skeleton,physics and mixed with interpolated keyframing for more realistic animations? If so, how and for what reasons? I can think of many different solutions for the issues below but I wonder what's used and best suited for issues like: Walking or moving on an uneven terrain Combat interaction, combat physics and collisions Attaching rigid items to character and their iteractions ih physics world Soft body dynamics like hair, vegetation, clothes and fabric in line with animations and iteractions.

    Read the article

  • Programming jobs for a science based degree [on hold]

    - by clairharrison
    I am currently in my last year of a Masters in Physics at Uni and I am looking to go into a job that is mainly programming based. As part of my course we have learnt C++, Matlab and as a hobby I taught myself HTML, CSS, JAVA and a bit of JavaScript. After getting to this stage in my degree I've realised that its actually the programming side of Physics that I enjoy most. I've been working on a few Android apps & websites in my spare time but only things that utilize what I know in JAVA, HTML etc. Using Physics in programming is good fun but I don't want to limit myself just to Physics based jobs. I just want to know a few things: What kind of jobs can I apply for that would require the kind of skills I already posses/can work towards possessing in a year Can I compete with graduates who have had a lot more programming in their course for example Computer Science? Are there any specific extra things I need on my CV before I start applying for these jobs?

    Read the article

  • What reference point/ tutorial could I use to help me make a "Ball rolling" game in flash?

    - by user1798964
    I am a complete newbie to programming, only took high school Computer science so I kind of know what im doing, I just want to know how I can make a ball rolling game that I want to make, could anyone show me an example of a good "ball rolling game" that has good physics and everything, I have tried to use Box2D for the physics portion of the game, but I found that using that is just code and I can't figure out how to make the graphics and details of the world I want to make in my game, all I would like to do would have a game that has the collision detection and physics of box2d only apply to one ball in it and use the left and right keys to move it. sorry if I am too unclear, if anyone could show a tutorial or something to me on how to make a proper "Ball rolling" game that has good physics that would be appreciated, thank you for taking the time to read this

    Read the article

  • draw bullet at the end of the barrel

    - by Alberto
    excuse my awkwardness, i have this code: [syntax="java"] int x2 = (int) (canon.getSceneCenterCoordinates()[0] + LENGTH_SPRITE/2* Math.cos(canon.getRotation())); int y2 = (int) (canon.getSceneCenterCoordinates()[1] + LENGTH_SPRITE/2* Math.sin(canon.getRotation())); projectile = new Sprite( (float) x2, (float) y2, mProjectileTextureRegion,this.getVertexBufferObjectManager() ); mMainScene.attachChild(projectile); [/syntax] and the bullet are drawn around the cannon in circle.. but not from the end of cannon :( help!

    Read the article

  • Bite the Bullet

    <b>Jamie's Random Musings:</b> "Sometimes you just have to "bite the bullet" and do what needs to be done, rather than what you would prefer to do, or what you would really like to do. That's what happened to me with my friends' laptop over the weekend."

    Read the article

  • Intersection points of plane set forming convex hull

    - by Toji
    Mostly looking for a nudge in the right direction here. Given a set of planes (defined as a normal and distance from origin) that form a convex hull, I would like to find the intersection points that form the corners of that hull. More directly, I'm looking for a way to generate a point cloud appropriate to provide to Bullet. Bonus points if someone knows of a way I could give bullet the plane list directly, since I somewhat suspect that's what it's building on the backend anyway.

    Read the article

  • HowTo Enable jBullet DebugMode

    - by Kenneth Bray
    I would like to render the physics world of jBullet to debug some issues in my game, and I am not finding too much on enabling the debugDraw method of jBullet. Do I need to write my own debugDraw method, or is there an easier way to draw the physics models to the screen? If there is already a built in method I would prefer to use that, otherwise I guess I will start making my own functions to handle this.

    Read the article

  • why do we need advanced knowledge of mathematics & physics for programming?

    - by Sumeet
    Guys, I have been very good in mathematics and physics in my schools and colleges. Right now I am a programmer. Even in the colleges I have to engrossed my self into computers and programming things all the time. As I used to like it very much. But I have always felt the lack of advanced mathematics and physics in all the work I have done (Programs). Programming never asked me any advanced mathematics and physics knowledge in what I was very good. It always ask u some optimized loops, and different programming technologies which has never been covered in advanced mathematics and physics. Even at the time of selection in big College , such a kind of advanced knowledge is required. Time by time I got out of touch of all that facts and concepts (advanced mathematics and physics). And now after, 5 years in job I found it hard to resolve Differentiations and integrations from Trigonometry. Which sometimes make me feel like I have wasted time in those concepts because they are never used. (At that time I knew that I am going to be a programmer) If one need to be a programmer why do all this advanced knowledge is required. One can go with elementry knowledge a bit more. You never got to think like scientists and R&D person in your Schols and colleges for being a programmer? Just think and let me know your thoughts. I must be wrong somewhere in what I think , but not able to figure that out..? Regards Sumeet

    Read the article

  • Kinect Turns DaVinci Physics Application Super Cool

    - by Gopinath
    Guys at RazorFish who are well known for their Microsoft Surface impressive stuff has ported their Da Vinci Application over to Kinect device. The end result is a super cool gesture based application. Check out the embedded video demonstration below If you wondering what is Da Vince Application is all about, here are few lines from RazorFish DaVinci is a Microsoft Surface application that blurs the lines between the physical and virtual world by combining object recognition, real-world physics simulation and gestural interface design. Related:Kinect + Windows 7 = Control PC With Hand Gestures This article titled,Kinect Turns DaVinci Physics Application Super Cool, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • Physics don't apply on a unique body AndEngine

    - by Kanga
    I am developing a game in AndEngine so far I managed to create everything I wanted for my sprite that was connected to a BoxBody. I was rotating it moving it everything was great. I wanted my collision detection to be more precise so I changed from boxBody to unique irregular shaped body. I found all the vertices and I just replaced the newly created irregular shaped body with the boxbody everywhere in my code. Not only that the image of the sprite is not in place but all the physics and maths I was doing for movement and physics wont work. Please help me :(. Thanks in advance.

    Read the article

  • Circular Bullet Spread not Even

    - by SoulBeaver
    I'm creating a bullet shooter much in the style of Touhou. Right now I want to have a very simple circular shot being fired from the enemy. See this picture: As you can see, the spacing is very uneven, which isn't very good if you want to survive. The code I'm using is this: private function shoot() : void { const BULLETS_PER_WAVE : int = 72; var interval : Number = BULLETS_PER_WAVE / 360; for (var i : int = 0; i < BULLETS_PER_WAVE; ++i { var xSpeed : Number = GameConstants.BULLET_NORMAL_SPEED_X * Math.sin(i * interval); var ySpeed : Number = GameConstants.BULLET_NORMAL_SPEED_Y * Math.cos(i * interval); BulletFactory.createNormalBullet(bulletColor_, alice_.center, xSpeed, ySpeed); } canShoot_ = false; cooldownTimer_.start(); } I imagine my mistake is in the sin, cos functions, but I'm not entirely sure what's wrong.

    Read the article

  • collsion issues with quadtree [on hold]

    - by QuantumGamer
    So i implemented a Quad tree in Java for my 2D game and everything works fine except for when i run my collision detection algorithm, which checks if a object has hit another object and which side it hit.My problem is 80% of the time the collision algorithm works but sometimes the objects just go through each other. Here is my method: private void checkBulletCollision(ArrayList object) { quad.clear(); // quad is the quadtree object for(int i=0; i < object.size();i++){ if(object.get(i).getId() == ObjectId.Bullet) // inserts the object into quadtree quad.insert((Bullet)object.get(i)); } ArrayList<GameObject> returnObjects = new ArrayList<>(); // Uses Quadtree to determine to calculate how many // other bullets it can collide with for(int i=0; i < object.size(); i++){ returnObjects.clear(); if(object.get(i).getId() == ObjectId.Bullet){ quad.retrieve(returnObjects, object.get(i).getBoundsAll()); for(int k=0; k < returnObjects.size(); k++){ Bullet bullet = (Bullet) returnObjects.get(k); if(getBoundsTop().intersects(bullet.getBoundsBottom())){ vy = speed; bullet.vy = -speed; } if(getBoundsBottom().intersects(bullet.getBoundsTop())){ vy = -speed; bullet.vy = speed; } if(getBoundsLeft().intersects(bullet.getBoundsRight())){ vx =speed; bullet.vx = -speed; } if(getBoundsRight().intersects(bullet.getBoundsLeft())){ vx = -speed; bullet.vx = speed; } } } } } Any help would be appreciated. Thanks in advance.

    Read the article

  • Remove enemy when bullet hits enemy

    - by jordi12100
    For my education I have to make a basic game in HTML5 canvas. The game is a shooter game. When you can move left - right and space is shoot. When I shoot the bullets will move up. The enemy moves down. When the bullet hits the enemy the enemy has to dissapear and it will gain +1 score. But the enemy will dissapear after it comes up the screen. Demo: http://jordikroon.nl/test.html space = shoot + enemy shows up This is my code: for (i=0;i<enemyX.length;i++) { if(enemyX[i] > canvas.height) { enemyY.splice(i,1); enemyX.splice(i,1); } else { enemyY[i] += 5; moveEnemy(enemyX[i],enemyY[i]); } } for (i=0;i<bulletX.length;i++) { if(bulletY[i] < 0) { bulletY.splice(i,1); bulletX.splice(i,1); } else { bulletY[i] -= 5; moveBullet(bulletX[i],bulletY[i]); for (ib=0;ib<enemyX.length;ib++) { if(bulletX[i] + 50 < enemyX[ib] || enemyX[ib] + 50 < bulletX[i] || bulletY[i] + 50 < enemyY[ib] || enemyY[ib] + 50 < bulletY[i]) { ++score; enemyY.splice(i,1); enemyX.splice(i,1); } } } } Objects: function moveBullet(posX,posY) { //console.log(posY); ctx.arc(posX, (posY-150), 10, 0 , 2 * Math.PI, false); } function moveEnemy(posX,posY) { ctx.rect(posX, posY, 50, 50); ctx.fillStyle = '#ffffff'; ctx.fill(); }

    Read the article

  • Bullet pattern isn't behaving as expected

    - by Fibericon
    I have a boss that's supposed to continuously shoot five streams of bullets, each at a different angle. It starts off just fine, but doesn't seem to want to use its entire array of bullets. No matter how large I set the length of bulletList, the boss simply stops shooting after a couple of seconds, then pick up again shortly. Here's what I'm using to generate the pattern: Vector3 direction = new Vector3(0.5f, -1, 0); for (int r = 0; r < boss.gun.bulletList.Length; r++) { if (!boss.gun.bulletList[r].isActive) { boss.gun.bulletList[r].direction = direction; boss.gun.bulletList[r].speed = boss.gun.BulletSpeedAdjustment; boss.gun.bulletList[r].position = boss.position; boss.gun.bulletList[r].isActive = true; break; } } direction = new Vector3(-0.5f, -1, 0); //Repeat with four similar for loops, to place a bullet in each direction It doesn't seem to matter if the bulletList length is 1000 or 100000. What could be the issue here?

    Read the article

  • How to Effectively Create Bullet Patterns

    - by SoulBeaver
    I'm currently creating a top-down shooter like Touhou. The most important factor of the game is that there are many diverse patterns and ways at which bullets are generated and shot at the player, see this video: http://www.youtube.com/watch?v=4Nb5Ohbt1Sg#start=0:60;end=9:53; At the moment, I'm using a class "Pattern" which has a series of steps on moving and shooting. However, I feel this method is quite laborous as I have to create a new Pattern for each attack and perhaps new Bullet classes that will implement a certain behavior. This question received a comment suggesting I should look into BulletML for easy creation and storage of bullets with a specific pattern. It looks decent, but it led me to wonder, what other solutions do you have that I should take into consideration? Update My current design is as follows: An example of an implemented pattern: My GigasPattern first executes a teleport which moves Alice to a certain point (X, Y) on the screen. After this is completed, the pattern starts using the Mover to move the sprite around (whereas teleporting has separate effects and animation). These are of no concern, really, as they are quite simple. The Shooter also creates various Attacks, which are classes again that the Shooter can use to create various patterns of bullets, much like the one in the question I posted. Once the Mover has reached it's destination, both it and the shooter stop and return to an inactive state. The pattern completes, is removed by the AI and a new one gets chosen.

    Read the article

  • Two Different nVidia Cards, One as Graphics, One as Physics - Possible?

    - by Jasarien
    Hey guys, Soon I will have a brand new Geforce GTX 285 to replace my current 8800GT. Will it be possible to move my 8800GT to another PCIX slot, put the GTX 285 into the primary slot and use the nVidia software to make the 8800GT do physics? I have enough PCIX slots on my motherboard (4). The GTX 285 will take up 2, so the 8800GT should fit in the 3rd. If anyone knows if this is possible, I would be grateful to be educated!

    Read the article

  • LibGDX onTouch() method Array and flip method

    - by johnny-b
    How can I add this on my application. i want to use the onTouch() method from the implementation of the InputProcessor to kill the enemies on screen. how do i do that? do i have to do anything to the enemy class? also i am trying to add a Array of enemies and it keeps throwing exceptions or the bullet now is facing LEFT <--- again after I used the flip method in the bullet class. All the code is below so please anyone feel free to have a look thanks. please help Thank you M // This is the bullet class. public class Bullet extends Sprite { public static final float BULLET_HOMING = 6000; public static final float BULLET_SPEED = 300; private Vector2 velocity; private float lifetime; private Rectangle bul; public Bullet(float x, float y) { velocity = new Vector2(0, 0); setPosition(x, y); AssetLoader.bullet1.flip(true, false); AssetLoader.bullet2.flip(true, false); setSize(AssetLoader.bullet1.getWidth(), AssetLoader.bullet1.getHeight()); bul = new Rectangle(); } public void update(float delta) { float targetX = GameWorld.getBall().getX(); float targetY = GameWorld.getBall().getY(); float dx = targetX - getX(); float dy = targetY - getY(); float distToTarget = (float) Math.sqrt(dx * dx + dy * dy); dx /= distToTarget; dy /= distToTarget; dx *= BULLET_HOMING; dy *= BULLET_HOMING; velocity.x += dx * delta; velocity.y += dy * delta; float vMag = (float) Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y); velocity.x /= vMag; velocity.y /= vMag; velocity.x *= BULLET_SPEED; velocity.y *= BULLET_SPEED; bul.set(getX(), getY(), getOriginX(), getOriginY()); Vector2 v = velocity.cpy().scl(delta); setPosition(getX() + v.x, getY() + v.y); setOriginCenter(); setRotation(velocity.angle()); } public Rectangle getBounds() { return bul; } public Rectangle getBounds1() { return this.getBoundingRectangle(); } } // This is the class where i load all the images from public class AssetLoader { public static Texture texture; public static TextureRegion bg, ball1, ball2; public static Animation bulletAnimation, ballAnimation; public static Sprite bullet1, bullet2; public static void load() { texture = new Texture(Gdx.files.internal("SpriteN1.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); bg = new TextureRegion(texture, 80, 421, 395, 30); bg.flip(false, true); ball1 = new TextureRegion(texture, 0, 321, 32, 32); ball1.flip(false, true); ball2 = new TextureRegion(texture, 32, 321, 32, 32); ball2.flip(false, true); bullet1 = new Sprite(texture, 380, 350, 45, 20); bullet1.flip(false, true); bullet2 = new Sprite(texture, 425, 350, 45, 20); bullet2.flip(false, true); TextureRegion[] balls = { ball1, ball2 }; ballAnimation = new Animation(0.16f, balls); ballAnimation.setPlayMode(Animation.PlayMode.LOOP); } Sprite[] bullets = { bullet1, bullet2 }; bulletAnimation = new Animation(0.06f, aims); bulletAnimation.setPlayMode(Animation.PlayMode.LOOP); } public static void dispose() { texture.dispose(); } // This is for the rendering or drawing onto the screen/canvas. public class GameRenderer { private Bullet bullet; private Ball ball; public GameRenderer(GameWorld world) { myWorld = world; cam = new OrthographicCamera(); cam.setToOrtho(true, 480, 320); batcher = new SpriteBatch(); // Attach batcher to camera batcher.setProjectionMatrix(cam.combined); shapeRenderer = new ShapeRenderer(); shapeRenderer.setProjectionMatrix(cam.combined); // Call helper methods to initialize instance variables initGameObjects(); initAssets(); } private void initGameObjects() { ball = GameWorld.getBall(); bullet = myWorld.getBullet(); scroller = myWorld.getScroller(); } private void initAssets() { ballAnimation = AssetLoader.ballAnimation; bulletAnimation = AssetLoader.bulletAnimation; } public void render(float runTime) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT); batcher.begin(); batcher.disableBlending(); batcher.enableBlending(); batcher.draw(AssetLoader.ballAnimation.getKeyFrame(runTime), ball.getX(), ball.getY(), ball.getWidth(), ball.getHeight()); batcher.draw(AssetLoader.bulletAnimation.getKeyFrame(runTime), bullet.getX(), bullet.getY(), bullet.getOriginX(), bullet.getOriginY(), bullet.getWidth(), bullet.getHeight(), 1.0f, 1.0f, bullet.getRotation()); // End SpriteBatch batcher.end(); } } // this is to load the image etc on the screen i guess public class GameWorld { public static Ball ball; private Bullet bullet; private ScrollHandler scroller; public GameWorld() { ball = new Ball(480, 273, 32, 32); bullet = new Bullet(10, 10); scroller = new ScrollHandler(0); } public void update(float delta) { ball.update(delta); bullet.update(delta); scroller.update(delta); } public static Ball getBall() { return ball; } public ScrollHandler getScroller() { return scroller; } public Bullet getBullet() { return bullet; } } //This is the input handler class public class InputHandler implements InputProcessor { private Ball myBall; private Bullet bullet; private GameRenderer aims; // Ask for a reference to the Soldier when InputHandler is created. public InputHandler(Ball ball) { myBall = ball; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean keyDown(int keycode) { return false; } @Override public boolean keyUp(int keycode) { return false; } @Override public boolean keyTyped(char character) { return false; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { return false; } @Override public boolean mouseMoved(int screenX, int screenY) { return false; } @Override public boolean scrolled(int amount) { return false; } } i am rendering all graphics in a GameRender class and a gameworld class if you need more info please let me know I am trying to make the array work but keep finding that when an array is initialized then the bullet fips back to the original and ends up being backwards???? and if I create an array I keep getting Exceptions throw??? Thank you for any help given.

    Read the article

  • Teaching myself, as a physicist, to become a better programmer

    - by user787267
    I've always liked physics, and I've always liked coding, so when I got the offer for a PhD position doing numerical physics (details are not relevant, it's mostly parallel programming for a cluster) at a university, it was a no-brainer for me. However, as most physicists, I'm self taught. I don't have broad background knowledge about how to code in an object oriented way, or the name of that specific algorithm that optimizes the search in some kD tree. Since all my work so far has been more concerned about the physics and the scientific results, I undoubtedly have some bad habits - more so because my coding is my own, and not really teamwork. I have mostly used C since it is very straightforward and "what you write is what you get" - no need for fancy abstractions. However, I have recently switched to C++ since I'd like to learn more about the power that comes with abstraction, and it's pretty C-like (syntax-wise at least). How do I teach myself to code in a good, abstract way like a graduate in computer science? I know my code is efficient, but I want it to be elegant as well, and readable. Keep in mind that I don't have time to read several 1000-page tomes about abstract programming. I need to spend time on actual, physics related research (my supervisor would laugh at me if he knew I spent time thinking about how to program elegantly). How do I assess if my work is also good from a programmer's perspective?

    Read the article

  • Trying to make a game with C++, using lists to store bullets and enemies, but they are not erased

    - by XD_dued
    I've been trying to make a pretty simple space shooter game with C++, and I have been having a lot of trouble trying to use lists to store enemies and bullets. Basically I followed the post here almost exactly to store my bullets: SDL Bullet Movement I've done something similar to store my enemies. However, when I call bullets.erase(it++), for some reason the bullet is not erased. When the bullet movement is run for the next frame, it tries to re delete the bullet and segfaults the program. When I comment out the erase line, it runs fine, but the bullets are then never erased from the list... Is there any reason why the elements of the list aren't being deleted? I also set it up to print the number of elements in the list for every iteration, and it does not go down after deleting. Thanks! EDIT: Here's the specific code I'm using to store my enemies and having them act: std::list<Grunt*> doGrunts(std::list<Grunt*> grunts) { for(std::list<Grunt*>::iterator it = grunts.begin(); it != grunts.end();) { if((*it)->getHull() == 0) { delete * it; grunts.erase(it++); } else { (**it).doUnit(grunts, it); ++it; } } } Grunt is my enemy class, and the list grunts is a global variable. Is that my problem? When I pass the global into the function it becomes local? I assumed lists would be a reference type so thought this wouldn't be a problem. Sorry if this was a dumb question, I'm very new to C++, this is the first major thing I'm working on.

    Read the article

  • JiglibX addition to existing project questions

    - by SomeXnaChump
    Got a very simple existing project, that basically contains a lot of cubes. Now I am wanting to add a physics system to it and JiglibX seemed like the simplest one with some tutorials out there. My main problem is that the physics don't seem to be working how I imagined, I expected my tower of cubes to come crashing down, but they dont seem to do anything. I think my problem is that my cubes do not inherit DrawableGameComponent, they are managed by a world object that will update and render them. So they are at no point put into the games component list. I am not sure if this means that JiglibX will not be able to interact with them as in all the tutorials there are no explicit calls to add the Body objects to the physics system, so I can only presume that they are using a static/singleton under the hood which automatically hooks in all things, or they use the game objects component list somehow. I also noticed that in alot of the tutorials they use the following when setting up the physics system: float timeStep = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond; PhysicsSystem.CurrentPhysicsSystem.Integrate(timeStep); Would it not be better to keep a local instance of the created PhysicsSystem object and just call myPhysicsSystem.Integrate(timeStep)?

    Read the article

  • Get started with Farseer Physics 2.1.3 in Silverlight 3

    As a powerful RIA development tool, Microsoft Silverlight is being more widely used to develop data-driven business and game applications. As a famous 2D game engine, the Farseer Physics Engine supports a wide range of platforms such as Microsoft's XNA, Silverlight, WPF, and Vanilla .NET. This article aims to serve as an elementary tutorial to Silverlight 2D beginners. Three demos are given to gradually lead you into a more and more complex and practical game environment.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >