Tag Info

Hot answers tagged

32

"Delta", "d" or "Δ", means "difference" in a mathematical context. Whenever there's a difference difference between two numbers with similar meanings, that difference may be called a "delta", or a "d". Deltas are very common in game development. For example, the difference between a character's X-coordinate one second ago and its X-coordinate now can be ...


26

This is the "time delta." It's how much time has elapsed since the previous update. It's necessary to ensure that animations, physics, and so on are running at the right speed. The code is running once per frame update. However, there's no guarantee that frames are drawn at a constant speed. One frame might take 1/60th of a second and the next might ...


17

If I understood your problem properly, you just want to shoot a bullet towards a mouse position. Here is how I would do: First of all, you must find the movement required for the bullet to get to the mouse, like so: Vector2 movement = mousePosition - bulletStartPosition; Then, you should normalize it to have a vector with a length of 1 so that you can ...


15

If you stop calling it "pushing forward" on the joystick/mouse, and start calling it "pushing up" (which is the way that most players think of it -- particularly the ones who don't play flight simulators), then the "invert Y axis" name makes complete sense, since pushing up causes the player to look down. Edit: The fundamental issue here is people's mental ...


12

You're on the right track with figuring out when the mouse is transitioning from down to up and writing a handler for that. For a lot of games, it's good enough to treat a mouseUp event as a click. Depending on your game, you're probably want to handle both events -- for example, in an RTS, you'll probably want to incorporate drag-box selecting as well as ...


11

TotalMilliseconds is a double, so you should not be doing an equality comparison there. There is every chance that the timer gets a fraction of a millisecond off, and your conditional never triggers. Also, there is no mechanism in your description for that code to run more than once per update. I recommend storing an integer frame number somewhere: int ...


7

I don't think there are any pre-canned solutions; at least I haven't seen any. But here is the logic to such a thing. What you essentially want is a queue of mouse positions and timestamps. So define an object, let's call it MousePositionSnapshot, which has two members, time and position (or separate x,y if you want). And then define your queue of ...


6

I'm going to go ahead and suggest Real-time Cameras. It appears to cover the topics you require. Honestly, though, you should go code some 3D cameras and figure out what works and doesn't :) That's the fun part, anyway.


6

Although I haven't worked with the bullet physics engine specifically, I've done something very similar in another physics engine. The way that I solved it was to set the rigid body's linear velocity instead of translating it directly. Movement and collisions were then automatically handled by the physics engine update phase. From the documentation there ...


6

Make sure that there is a visual cue that the player is currently not in control. When it is a non-interactive cutscene, you could remove the GUI during the cutscene and bring it back as soon as the player is in control again. When the users control is impaired (but not completely disabled) during normal gameplay, for example because their character is ...


5

It seems intuitively obvious that the mouse (or, even more so, a thumbstick, which even looks kind of like a head sitting atop a neck) is modeling the perspective character's head. Maybe this seems intuitively obvious to you, but not to everyone. To some it would seem intuitively obvious that moving the mouse "up" should move your view "up." I'm ...


5

For the record, my experience with physics is using Chimpunk in a 2D game engine, but I'm pretty sure this concept translates into 3D just fine. I'm assuming that your character is a physics body with weight and such. The best way to do this is to do a very simplified simulation of walking. Think of it like this: If you're standing, your feet have a lot ...


5

If you're having trouble calculating the angle, you can use this: Vector2 target = mousePos - startPos; float angle = Math.Atan2( target.Y, target.X );


5

Add an intermediate layer. You have some kind of PlatformInput that manages all the different input methods and generates low-level events like KeyUp, KeyDown, etc. Another layer then processes these messages into logic events, like MoveUp, Jump, etc. It can do this by receiving the inputs, mapping keys to logic events, and doing only the most basic ...


4

Well, File->Make a Copy doesn't work for me so let's describe the answer the old way :) First, calculate the intersection point between your movement vector and the wall. Second, compute the wall normal (vector perpendicular to the wall) at the intersection point. Next compute the dot product of your reversed movement vector and the normal (so both vectors ...


4

I believe the most likely explanation is that it's an artefact of the original Quake, which defaulted it's mouselooking to forward = up, and had a menu item explicitly called "invert mouse" for forward = down. See e.g. http://en.m.wikipedia.org/wiki/Mouse_(computing)#section_11 Also interesting to note that for standard GUI usage moving the mouse forward ...


4

Ricket's answer was my first idea too. If you draw all the mouse pointers in your queue you get a nice trail as well. Another option would be to linearly interpolate your detected mouse position and the actual mouseposition, that way it will gravitate towards the mouseposition with a delay, but it won't actually follow the exact path the mouse travelled. ...


4

There is no 'best' - you need all of them. If I'm firing a gun, I don't want to wait for the mouse to be released to trigger the weapon firing effect. And if you're dragging a box around a bunch of units, you start the drag action on mouse-down. On the other hand, if I'm clicking a GUI item then I want to wait for the full click because that's what I'm ...


4

Do this in character controller script's Update() First of all you have to detect the user input via touch(begin/moved/ended) methods and then you have to calculate the gesture it ended up in like swipe-left. You can assign a bool to it like SwipeL = true; Now you have to add a condition in the methods where character movement is mapped with ...


3

Your update function probably isn't called in multiples of 500ms every time, which is what your modulus would imply. You could save the last time it was called, then compare it with the current time , like int lastcaret = gameTime.TotalGameTime.TotalMilliseconds; // in loop if((gameTime.TotalGameTime.TotalMilliseconds - lastcaret) >= 500) ...


3

The most responsive and familiar mechanism is the physical D-Pad on the Xperia Play device; you could follow Mojang's example and target your game at that device. This would additionally provide support to any devices with a physical D-Pad, since the Play's D-Pad uses the standard D-Pad key codes. This includes trackballs like the one found on the Nexus One; ...


3

When you tilted too much, you will hardly see the screen (eyes must move), which is bad for intense action games. I'm a joypad and keyboard gamer, so I'm used to key controls, and key or mouse controls give you an accurate directional feedback. So you know if you are driving straight. In the X-Plane app, I found it's missing the HUD that shows your yoke ...


3

While a 2D camera is quite simple to implement, a camera in 3D can become really complicated quite fast. First person perspective or a fixed camera like in a RTS are probably the easiest ones, while a good third-person camera can be a huge challenge. I recently saw a presentation of a game-camera research project which looked really good: Visibility ...


3

This is more of a question of, does the use of the accelerometer improves/or integrates well with the controls of your game or does it makes it worse. Having good controls contribute to the overall design of a game, so ask yourself whether you want to design a good game or a bad one, then implement the best controls (whether it be a touch interface, onscreen ...


3

dt stands for delta time. It is used in the calculation of frame rate to insure the game runs at the same speed no matter what the frame rate is. More information on framerate independence can be found here.


3

dt (delta time) is the time between each cycle/render frame (or any time stamp you desire) of your loop. With this delta time we can stretch certain values over time. Just like in the real world we measure certain physics properties over time. Let's say we run our game 60 frames a second. If we want our our player to move 5 pixels per second we do 5 * ...


3

Create a VBO with a GL_DYNAMIC_DRAW or GL_STREAM_DRAW flag. This is used to give the OpenGL implemetation a hint of where to allocate the memory and enable certain optimizations, for example the data could be cached or not, stored in system memory or graphics memory. Dynamic means the data will be changed frequently (specified and used repeatedly) Stream ...


2

Branching sucks. Every time the user has to look at the screen, comprehend it, and then make a decision, you're slowing the game down. With your somewhat-chaotic "move between open tiles" algorithm, nobody but an expert is going to be able to play the game without constant look-comprehend-act-look-comprehend-act cycles. Here's how I'd do it. Make a ...


2

NB: I'm assuming here you're talking about cameras in third-person games such as Tomb Raider. Even then, some games may have sections, for instance when in cover, when a completely separate camera system is used to the main walking-around sections of the game. This is a very complex area to get right. The simple naive approach is to lock the camera to a ...


2

Yes, as ScrambledRK said, you should be settting flags. You should create 2 boolean variables: Boolean left_key_down = false; Boolean right_key_down = false; and set them to appropriate values in the event listeners: public void keyPressed(KeyEvent e) { int keys = e.getKeyCode(); if(keys == KeyEvent.VK_RIGHT) { right_key_down = true; } ...



Only top voted, non community-wiki answers of a minimum length are eligible