Search Results

Search found 3566 results on 143 pages for '2d physics'.

Page 6/143 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • forward motion car physics - gradual slow

    - by spartan2417
    Im having trouble creating realistic car movements in xna 4. Right now i have a car going forward and hitting a terminal velocity which is fine but when i release the up key i need to the car to slow down gradually and then come to a stop. Im pretty sure this is easy code but i cant seem to get it to work the code - update if (Keyboard.GetState().IsKeyDown(Keys.Up)) { double elapsedTime = gameTime.ElapsedGameTime.Milliseconds; CalcTotalForce(); Acceleration = Vector2.Divide(CalcTotalForce(), MASS); Velocity = Vector2.Add(Velocity, Vector2.Multiply(Acceleration, (float)(elapsedTime))); Position = Vector2.Add(Position, Vector2.Multiply(Velocity, (float)(elapsedTime))); } added functions public Vector2 CalcTraction() { //Traction force = vector direction * engine force return Vector2.Multiply(forwardDirection, ENGINE_FORCE); } public Vector2 CalcDrag() { //Drag force = constdrag * velocity * speed return Vector2.Multiply(Vector2.Multiply(Velocity, DRAG_CONST), Velocity.Y); } public Vector2 CalcRoll() { //roll force = const roll * velocity return Vector2.Multiply(Velocity, ROLL_CONST); } public Vector2 CalcTotalForce() { //total force = traction + (-drag) + (-rolling) return Vector2.Add(CalcTraction(), Vector2.Add(-CalcDrag(), -CalcRoll())); } anyone have any ideas?

    Read the article

  • Scaling Sound Effects and Physics with Framerate

    - by Thomas Bradsworth
    (I'm using XNA and C#) Currently, my game (a shooter) runs flawlessly with 60 FPS (which I developed around). However, if the framerate is changed, there are two major problems: Gunshot sound effects are slower Jumping gets messed up Here's how I play gunshot sounds: update(gametime) { if(leftMouseButton.down) { enqueueBulletForSend(); playGunShot(); } } Now, obviously, the frequency of playGunShot depends on the framerate. I can easily fix the issue if the FPS is higher than 60 FPS by capping the shooting rate of the gun, but what if the FPS is less than 60? At first I thought to just loop and play more gunshots per frame, but I found that this can cause audio clipping or make the bullets fire in "clumps." Now for the second issue: Here's how jumping works in my game: if(jumpKey.Down && canJump) { velocity.Y += 0.224f; } // ... (other code) ... if(!onGround) velocity.Y += GRAVITY_ACCELERATION * elapsedSeconds; position += velocity; The issue here is that at < 60 FPS, the "intermediate" velocity is lost and therefore the character jumps lower. At 60 FPS, the game adds more "intermediate" velocities, and therefore the character jumps higher. For example, at 60 FPS, the following occurs: Velocity increased to 0.224 Not on ground, so velocity decreased by X Position increased by (0.224 - X) <-- this is the "intermediate" velocity At 30 FPS, the following occurs: Velocity increased to 0.224 Not on ground, so velocity decreased by 2X Position increased by (0.224 - 2X) <-- the "intermediate" velocity was lost All help is appreciated!

    Read the article

  • Farseer Physics: Ways to create a Body?

    - by EdgarT
    I want to create something similar to this using farsser and Kinect: https://vimeo.com/33500649 This is my implementation until now: http://www.youtube.com/watch?v=GlIvJRhco4U I have the outline vertices and the triangulation of the user. And following the Texture to Polygonmsample i used this line to create the shape, where farseerObject is a list of vertices of the triangles: _compound = BodyFactory.CreateCompoundPolygon(World, farseerObject, 1f, BodyType.Dynamic); But I have to update the body each frame (like 30 fps) and this is very slow. I get just 2 or 3 fps. There's another (faster) way to create the Body from a list of triangles or the contour vertices?

    Read the article

  • Farseer Physics Samples and Krypton how to reference game

    - by Krell
    I'm sure this is totally simple and yes I am new at this. I am trying to set up Krypton inside farseer. 1. create a new Krypton engine in my sub screen aka AdvancedDemo1 : PhysicsGameScreen, IDemoScreen Via this.krypton = new KryptonEngine(this, "KryptonEffect"); The problem is the KryptonEngine(this wants reference to Game game, I cant seem to reference it from FarseerPhysicsGame : Game So how would I do that? or 2. I can put it directly in FarsserPhysicsGame but again I cant seem to figure out how to reference FarseerPhysicsGame in AdvancedDemo1. or 3. I can put it inside the public FarseerPhysicsGame() and do Componenets.Add(krypton) [which works] HOWEVER I cant figure out how to reference the compoenet once it is added. You should be able to stop reading here , but for more detail I simply took the Farseer XNA Samples went into FarseerPhysicsGame.cs and deleted all the screens and menus except AdvancedDemo1 so there is one option and I just click that to load into the advancedDemo1 and thats where I want to put the lights from krypton. Thanks. Edit: Figured out 1 solution though I am still curious about others. Solution 1 I was able to use ScreenManager.Game(not sure why it was there but Ill try to figure it out later)

    Read the article

  • Jumping Physics

    - by CogWheelz
    With simplicity, how can I make a basic jump without the weird bouncing? It jumps like 2 pixels and back Here's what I use y += velY x += velX then keypresses MAX_SPEED = 180; falling = true; if(Gdx.input.isKeyPressed(Keys.W)) {//&& !jumped && !p.falling) { p.y += 20; } if(!Gdx.input.isKeyPressed(Keys.W)) p.velY = 0; if(Gdx.input.isKeyPressed(Keys.D)) p.velX = 5; if(!Gdx.input.isKeyPressed(Keys.D) && !(Gdx.input.isKeyPressed(Keys.A))) p.velX = 0; if(Gdx.input.isKeyPressed(Keys.A)) p.velX = -5; if(!Gdx.input.isKeyPressed(Keys.A) && !(Gdx.input.isKeyPressed(Keys.D))) p.velX = 0; if(p.falling == true || p.jumping == true) { p.velY -= 2; } if(p.velY > MAX_SPEED) p.velY = MAX_SPEED; if(p.velX > MAX_SPEED) p.velX = MAX_SPEED;

    Read the article

  • LibGDX Box2D Body and Sprite AND DebugRenderer out of sync

    - by Free Lancer
    I am having a couple issues with Box2D bodies. I have a GameObject holding a Sprite and Body. I use a ShapeRenderer to draw an outline of the Body's and Sprite's bounding boxes. I also added a Box2DDebugRenderer to make sure everything's lining up properly. My problem is the Sprite and Body at first overlap perfectly, but as I turn the Body moves a bit off the sprite then comes back when the Car is facing either North or South. Here's an image of what I mean: (Not sure what that line is, first time to show up) BLUE is the Body, RED is the Sprite, PURPLE is the Box2DDebugRenderer. Also, you probably noticed a purple square in the top right corner. Well that's the Car drawn by the Box2D Debug Renderer. I thought it might be the camera but I've been playing with the Cameras for hours and nothing seems to work. All give me weird results. Here's my code: Screen: public void show() { // --------------------- SETUP ALL THE CAMERA STUFF ------------------------------ // battleStage = new Stage( 720, 480, false ); // Setup the camera. In Box2D we operate on a meter scale, pixels won't do it. So we use // an Orthographic camera with a Viewport of 24 meters in width and 16 meters in height. battleStage.setCamera( new OrthographicCamera( CAM_METER_WIDTH, CAM_METER_HEIGHT ) ); battleStage.getCamera().position.set( CAM_METER_WIDTH / 2, CAM_METER_HEIGHT / 2, 0 ); // The Box2D Debug Renderer will handle rendering all physics objects for debugging debugger = new Box2DDebugRenderer( true, true, true, true ); //debugCam = new OrthographicCamera( CAM_METER_WIDTH, CAM_METER_HEIGHT ); } public void render(float delta) { // Update the Physics World, use 1/45 for something around 45 Frames/Second for mobile devices physicsWorld.step( 1/45.0f, 8, 3 ); // 1/45 for devices // Set the Camera matrices and clear the screen Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); battleStage.getCamera().update(); // Draw game objects here battleStage.act(delta); battleStage.draw(); // Again update the Camera matrices and call the debug renderer debugCam.update(); debugger.render( physicsWorld, debugCam.combined); // Vehicle handles its own interaction with the HUD // update all Actors movements in the game Stage hudStage.act( delta ); // Draw each Actor onto the Scene at their new positions hudStage.draw(); } Car: (extends Actor) public Car( Texture texture, float posX, float posY, World world ) { super( "Car" ); mSprite = new Sprite( texture ); mSprite.setSize( WIDTH * Consts.PIXEL_METER_RATIO, HEIGHT * Consts.PIXEL_METER_RATIO ); mSprite.setOrigin( mSprite.getWidth()/2, mSprite.getHeight()/2); // set the origin to be at the center of the body mSprite.setPosition( posX * Consts.PIXEL_METER_RATIO, posY * Consts.PIXEL_METER_RATIO ); // place the car in the center of the game map FixtureDef carFixtureDef = new FixtureDef(); mBody = Physics.createBoxBody( BodyType.DynamicBody, carFixtureDef, mSprite ); } public void draw() { mSprite.setPosition( mBody.getPosition().x * Consts.PIXEL_METER_RATIO, mBody.getPosition().y * Consts.PIXEL_METER_RATIO ); mSprite.setRotation( MathUtils.radiansToDegrees * mBody.getAngle() ); // draw the sprite mSprite.draw( batch ); } Physics: (Create the Body) public static Body createBoxBody( final BodyType pBodyType, final FixtureDef pFixtureDef, Sprite pSprite ) { float pRotation = 0; float pWidth = pSprite.getWidth(); float pHeight = pSprite.getHeight(); final BodyDef boxBodyDef = new BodyDef(); boxBodyDef.type = pBodyType; boxBodyDef.position.x = pSprite.getX() / Consts.PIXEL_METER_RATIO; boxBodyDef.position.y = pSprite.getY() / Consts.PIXEL_METER_RATIO; // Temporary Box shape of the Body final PolygonShape boxPoly = new PolygonShape(); final float halfWidth = pWidth * 0.5f / Consts.PIXEL_METER_RATIO; final float halfHeight = pHeight * 0.5f / Consts.PIXEL_METER_RATIO; boxPoly.setAsBox( halfWidth, halfHeight ); // set the anchor point to be the center of the sprite pFixtureDef.shape = boxPoly; final Body boxBody = BattleScreen.getPhysicsWorld().createBody(boxBodyDef); boxBody.createFixture(pFixtureDef); } Sorry for all the code and long description but it's hard to pin down what exactly might be causing the problem.

    Read the article

  • Procedual level generation for a platformer game (tilebased) using player physics

    - by Notbad
    I have been searching for information about how to build a 2d world generator (tilebased) for a platformer game I am developing. The levels should look like dungeons with a ceiling and a floor and they will have a high probability of being just made of horizontal rooms but sometimes they can have exits to a top/down room. Here is an example of what I would like to achieve. I'm refering only to the caves part. I know level design won't be that great when generated but I think it is possible to have something good enough for people to enjoy the procedural maps (Note: Supermetrod Spoiler!): http://www.snesmaps.com/maps/SuperMetroid/SuperMetroidMapNorfair.html Well, after spending some time thinking about this I have some ideas to create the maps that I would like to share with you: 1) I have read about celular automatas and I would like to use them to carve the rooms but instead of carving just a tile at once I would like to carve full columns of tiles. Of course this carving system will have some restrictions like how many tiles must be left for the roof and the ceiling, etc... This way I could get much cleaner rooms than using the ussual automata. 2) I want some branching into the rooms. It will have little probability to happen but I definitely want it. Thinking about carving I came to the conclusion that I could be using some sort of path creation algorithm that the carving system would follow to create a path in the rooms. This could be more noticiable if we make the carving system to carve columns with the height of a corridor or with the height of a wide room (this will be added to the system as a param). This way at some point I could spawn a new automa beside the main one to create braches. This new automata should play side by side with the first one to create dead ends, islands (both paths created by the automatas meet at some point or lead to the same room. It would be too long to explain here all the tests I have done, etc... just will try to summarize the problems to see if anyone could bring some light to solve them (I don't mind sharing my successes but I think they aren't too relevant): 1) Zone reachability: How can I make sure that the player will be able to reach all zones I created (mainly when branches happen or vertical rooms are created). When branches are created I have to make sure that there will be a way to get onto the new created branch. I mean a bifurcation that the player could follow. Player will follow the main path or jump to a platform to get onto the other way). On the other hand if an island is created by the meeting of both branches I need to make sure the player will be able to get onto the island too. 2) When a branch is created and corridors are generated for each branch how can I make then both merge or repel to create an island or just make them separated corridors. 3) When I create a branch and an island is created becasue both corridors merge at somepoint or they lead to the same room, is there any way to detect this and randomize where to create the needed platforms to get onto the created isle? This platforms could be created at the start of the island or at the end. I guess part of the problem could be solved using some sort of graph following the created paths but I'm a bit lost in this sea of precedural content creation :). On the other hand I don't expect a solution to the problem but some information to get me moving forward again. Thanks in advance.

    Read the article

  • Simulating the effects of wind

    - by jernej
    I am developing a mobile game for Android. It is a 3D jumping game (like ski jump) where wind plays a important role so i need to simulate it. How could I achieve this? The game uses libgdx for rendering and a port of Bullet physics engine for physics. To simulate the jump I have 2 spheres which are placed at the start and at the end of the player and gravity is applied to them (they role down the hill and jump at the end). I use them to calculate the angle and the position of the player. If a button is pressed some extra y speed is applied to them (to simulate the jump before the end of the jumping ramp). But now I have to add wind to it. How is this usually done? Which collision box/method should I use? The way I understand it I only have to apply some force with direction to the player while in mid air. How can I do this in Bullet?

    Read the article

  • Lag compensation with networked 2D games

    - by Milo
    I want to make a 2D game that is basically a physics driven sandbox / activity game. There is something I really do not understand though. From research, it seems like updates from the server should only be about every 100ms. I can see how this works for a player since they can just concurrently simulate physics and do lag compensation through interpolation. What I do not understand is how this works for updates from other players. If clients only get notified of player positions every 100ms, I do not see how that works because a lot can happen in 100ms. The player could have changed direction twice or so in that time. I was wondering if anyone would have some insight on this issue. Basically how does this work for shooting and stuff like that? Thanks

    Read the article

  • 2D graphics - why use spritesheets?

    - by Columbo
    I have seen many examples of how to render sprites from a spritesheet but I havent grasped why it is the most common way of dealing with sprites in 2d games. I have started out with 2d sprite rendering in the few demo applications I've made by dealing with each animation frame for any given sprite type as its own texture - and this collection of textures is stored in a dictionary. This seems to work for me, and suits my workflow pretty well, as I tend to make my animations as gif/mng files and then extract the frames to individual pngs. Is there a noticeable performance advantage to rendering from a single sheet rather than from individual textures? With modern hardware that is capable of drawing millions of polygons to the screen a hundred times a second, does it even matter for my 2d games which just deal with a few dozen 50x100px rectangles? The implementation details of loading a texture into graphics memory and displaying it in XNA seems pretty abstracted. All I know is that textures are bound to the graphics device when they are loaded, then during the game loop, the textures get rendered in batches. So it's not clear to me whether my choice affects performance. I suspect that there are some very good reasons most 2d game developers seem to be using them, I just don't understand why.

    Read the article

  • 2D map/plane with nodes overlayed that supports panning, scaling and clicking on nodes

    - by garlicman
    I'm trying my hand at Android development and seem to be running into an invisible ceiling in trying to get what I want accomplished. Basically I'm trying to create an app that renders a 2D surface map that I can (pinch) zoom and pan. I'll have to place nodes on the surface of the map that will scale/zoom and pan in relation to the surface. I started out with a 2D ImageView approach and got as far as pinch zoom, pan and laying nodes as relative ImageViews, but all the methods I tried to get X,Y,W,H for the 2D surface were always off for some reason. Additionally, I was never able to scale the node ImageViews correctly, and as a result never got far enough to try and work out their X,Y scaled offset. So I decided to get back to 3D rendering. Conceptually pan/zoom is camera manipulation, so I don't have to mess with how to scale the 2D map or the nodes. But I need a starting point or sample to get me going that's close to what I'm trying to achieve. A sample on a translucent spinning cube isn't helping as much as I need it to. Any tips? Links, insults and sympathy are all welcome!

    Read the article

  • Impulsioned jumping

    - by Mutoh
    There's one thing that has been puzzling me, and that is how to implement a 'faux-impulsed' jump in a platformer. If you don't know what I'm talking about, then think of the jumps of Mario, Kirby, and Quote from Cave Story. What do they have in common? Well, the height of your jump is determined by how long you keep the jump button pressed. Knowing that these character's 'impulses' are built not before their jump, as in actual physics, but rather while in mid-air - that is, you can very well lift your finger midway of the max height and it will stop, even if with desacceleration between it and the full stop; which is why you can simply tap for a hop and hold it for a long jump -, I am mesmerized by how they keep their trajetories as arcs. My current implementation works as following: While the jump button is pressed, gravity is turned off and the avatar's Y coordenate is decremented by the constant value of the gravity. For example, if things fall at Z units per tick, it will rise Z units per tick. Once the button is released or the limit is reached, the avatar desaccelerates in an amount that would make it cover X units until its speed reaches 0; once it does, it accelerates up until its speed matches gravity - sticking to the example, I could say it accelerates from 0 to Z units/tick while still covering X units. This implementation, however, makes jumps too diagonal, and unless the avatar's speed is faster than the gravity, which would make it way too fast in my current project (it moves at about 4 pixels per tick and gravity is 10 pixels per tick, at a framerate of 40FPS), it also makes it more vertical than horizontal. Those familiar with platformers would notice that the character's arc'd jump almost always allows them to jump further even if they aren't as fast as the game's gravity, and when it doesn't, if not played right, would prove itself to be very counter-intuitive. I know this because I could attest that my implementation is very annoying. Has anyone ever attempted at similar mechanics, and maybe even succeeded? I'd like to know what's behind this kind of platformer jumping. If you haven't ever had any experience with this beforehand and want to give it a go, then please, don't try to correct or enhance my explained implementation, unless I was on the right way - try to make up your solution from scratch. I don't care if you use gravity, physics or whatnot, as long as it shows how these pseudo-impulses work, it does the job. Also, I'd like its presentation to avoid a language-specific coding; like, sharing us a C++ example, or Delphi... As much as I'm using the XNA framework for my project and wouldn't mind C# stuff, I don't have much patience to read other's code, and I'm certain game developers of other languages would be interested in what we achieve here, so don't mind sticking to pseudo-code. Thank you beforehand.

    Read the article

  • Rendering of 2d water

    - by luke
    Suppose you have a nice way to move your 2D particles in order to simulate a fluid (like water). Any ideas on how to render it? Consider the fact that the game is a 2D game. The perspective is like this (the first image i have found): an example of 2d water. The water will be contained in boxes that can be broken in order to let it fall down and interact with other objects. The most simple way that comes to my mind is to use a small image for each particle. I am interested in hearing more ways of rendering water. Thank you.

    Read the article

  • How to autohide Unity 2D?

    - by ph1b
    In the regular Unity 3D, I used Compiz Config Manager where I could config the Unity-Plugin to autohide the left start-bar and not to show it when moving my mouse to the left. So it was perfect for using Docky. But with Unity 2D the Unity settings don't have any effect. How can I completely hide the start-panel and just have it shown when pressing the windows-key? With the following: dconf write /com/canonical/unity-2d/launcher/hide-mode 1 dconf write /com/canonical/unity-2d/launcher/use-strut false it still opens the bar when going with my mouse to the left.

    Read the article

  • 2D Pixel/sprite game in unity? [on hold]

    - by acidzombie24
    Hi I'm an absolute newbie in unity. In the past I was told unity is terrible for 2d games so I look away after looking at it for a few days. I don't remember if this was right before unity4 came out or after. I hear unity is fairly good at 2d now. I tried googling for tutorials but I'm doing it wrong. I could not find a good tetris or tic tac toe tutorial. What assets/tutorials do I want for a 2D game? Side question is what tutorials are good if I want to make a fire emblem/advance wars type game (HUD heavy grid base game)

    Read the article

  • Why use 3d matrix and camera in 2D world for 2d geometric figures?

    - by Navy Seal
    I'm working in XNA on a 2d isometric world/game and I'm using DrawUserPrimitives to draw some geometric figures... I saw some tutorials about creating dynamic shadows but I didn't understood why they use a "3d" matrix to control the transformations since the figure I'm drawing is in 2d perspective. I know I'm drawing a 2d figure in 3d but I still can't understand if I really need to work with the matrix. Is there any advantage in using a 3d Matrix to control camera and view? Any reason why I can't just update my vertex's positions by using a regular method since the view is always the same... And since I want to work only with single figures, won't this cause all the geometric figures have the same transformations simultaneously? To understand better what I mean here's a video http://www.youtube.com/watch?v=LjvsGHXaGEA&feature=player_embedded

    Read the article

  • Implementing 2D CSG (for collision shapes)?

    - by bluescrn
    Are there any simple (or well documented) algorithms for basic CSG operations on 2D polygons? I'm looking for a way to 'add' a number of overlapping 2D collision shapes. These may be convex or concave, but will be closed shapes, defined as a set of line segments, with no self-intersections. The use of this would be to construct a clean set of collision edges, for use with a 2D physics engine, from a scene consisting of many arbitrarily placed (and frequently overlapping) objects, each with their own collision shape. To begin with, I only need to 'add' shapes, but the ability to 'subtract', to create holes, may also be useful.

    Read the article

  • Resources for 2D rendering using OpenGL?

    - by nightcracker
    I noticed that there is quite some difference between 3D and 2D rendering using OpenGL, the techniques are different - pixel-perfect placing is a lot more desirable, among other things. Are there any good (complete) references on using OpenGL for rendering 2D graphics? There are quite a few "tutorials" around on the net that help you open a window, set up a half-decent environment and draw a sprite, but no real good information on rotation, blending, lightning, drawing order, using the z-buffer, particles, "complex" primitives (circles, stars, cross symbols), ensuring pixel-perfect rendering, instancing and many other staple 2D effects/techniques. Any books, great blogs, anything? Any particular awesome libraries to read?

    Read the article

  • Determining relative velocities on impact?

    - by meds
    I'm trying to figure out a way to determine the relative velocity of a body colliding with another in a 2D environment. For example if one body is moving at (1,0) and another traveling behind it collides with it from behind at (2,0) the velocity of the impact relative to the first body was (1,0). I need a method which takes in two velocities, one velocity belonging to the body the velocity is being measured against, and the other for the impacting body and return the relative velocity.

    Read the article

  • How to achieve highly accurate car physics such as Liveforspeed?

    - by Kim Jong Woo
    Liveforspeed is a racing simulator, there is amazing amount of realistic physics. for example, tires get warm, tire actually deforms when you turn corners. You need to play this game with a mouse at the minimum because it almost drives like the real thing. Anyhow, how does one achieve that level of physics simulation? Are there off-the-shelf solutions out there? If not, how does one start with simulating real world physics as close as possible. I would love to be able to work on an opensource car physics focused game. Imagine, more passionate developers, it could keep things going.

    Read the article

  • Resolving a collision between point and moving line

    - by Conundrumer
    I am designing a 2d physics engine that uses Verlet integration for moving points (velocities mentioned below can be derived), constraints to represent moving line segments, and continuous collision detection to resolve collisions between moving points and static lines, and collisions between moving/static points and moving lines. I already know how to calculate the Time of Impact for both types of collision events, and how to resolve moving point static line collisions. However, I can't figure out how to resolve moving/static point moving line collisions. Here are the initial conditions in a point and moving line collision event. We have a line segment joined by two points, A and B. At this instant, point P is touching/colliding with line AB. These points have unit mass and some might have an initial velocity, unless point P is static. The line is massless and has no explicit rotational component, since points A and B could freely move around, extending or contracting the line as a result (which will be fixed later by the constraint solver). Collision is inelastic. What are the final velocities of the points after collision?

    Read the article

  • Can I still use unity 2d [duplicate]

    - by dragonloverlord
    This question already has an answer here: Is it possible to change Unity 3D to 2D and will I gain any performance boost after that? 3 answers I can not run unity 3d on my Chromebook but unity 2d in Ubuntu 12.04 works fine so is it possible to run unity low graphics mode on Ubuntu 14.04 as an alternative? If I can run low graphics mode as an alternative then how would I go about that? If I can not then what would be a good unity like alternative for Ubuntu 14.04?

    Read the article

  • spinning a 2d Cube

    - by Rahul Verma
    I know that a cube is actually a 3d shape , but i have some other problem over here. I have been doing 2D Game dev using libgdx but have never touched 3D rendering. Now what I want in my 2D game is that instead of coins I make my player collect magical cubes. But those cubes need to be spinning on one Diagonal, same can be seen in popular game Vector. Here is a screenshot. Can someone explaing the mathematics of such an animation

    Read the article

  • Calculating the 2D edge normals of a triangle

    - by Kazade
    What's a reliable way to calculate a 2D normal vector for each edge of a triangle, so that each normal is pointing outwards from the triangle? To clarify, given any triangle - for each edge (e.g p2-p1), I need to calculate a 2D normal vector pointing away from the triangle at right angles to the edge (for simplicity we can assume that the points are being specified in an anti-clockwise direction). I've coded a couple of hacky attempts, but I'm sure I'm overlooking some simple method and Google isn't being that helpful today - that and I haven't had my daily caffeine yet!

    Read the article

  • 2D camera perspective projection from 3D coordinates -- HOW?

    - by Jack
    I am developing a camera for a 2D game with a top-down view that has depth. It's almost a 3D camera. Basically, every object has a Z even though it is in 2D, and similarly to parallax layers their position, scale and rotation speed vary based on their Z. I guess this would be a perspective projection. But I am having trouble converting the objects' 3D coordinates into the 2D space of the screen so that everything has correct perspective and scale. I never learned matrices though I did dig the topic a bit today. I tried without using matrices thanks to this article but every attempt gave awkward results. I'm using ActionScript 3 and Flash 11+ (Starling), where the screen coordinates work like this: Left-handed coordinates system illustration I can explain further what I did if you want to help me sort out what's wrong, or you can directly tell me how you would do it properly. In case you prefer the former, read on. These are images showing the formulas I used: upload.wikimedia.org/math/1/c/8/1c89722619b756d05adb4ea38ee6f62b.png upload.wikimedia.org/math/d/4/0/d4069770c68cb8f1aa4b5cfc57e81bc3.png (Sorry new users can't post images, but both are from the wikipedia article linked above, section "Perspective projection". That's where you'll find what all variables mean, too) The long formula is greatly simplified because I believe a normal top-down 2D camera has no X/Y/Z rotation values (correct ?). Then it becomes d = a - c. Still, I can't get it to work. Maybe you could explain what numbers I should put in a(xyz), c(xyz), theta(xyz), and particularly, e(xyz) ? I don't quite get how e is different than c in my case. c.z is also an issue to me. If the Z of the camera's target object is 0, should the camera's Z be something like -600 ? ( = focal length of 600) Whatever I do, it's wrong. I only got it to work when I used arbitrary calculations that "looked" right, like most cameras with parallax layers seem to do, but that's fake! ;) If I want objects to travel between Z layers I might as well do it right. :) Thanks a lot for your help!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >