Friday, July 31, 2015

How to create a game save file format in c++ using STL


Hey so i just learned about the i/o part of the STL, more specifically fstream. Although I can now save binary info and classes i've made to the hard drive, i am not sure how to define how the info should be read.


I saw the answer for making a file format from [this][1] post:



Typically you would define a lot of records/structures, such as BITMAPINFOHEADER, and specify in what order they should come, how they should be nestled, and you might need to write a lot of indicies and look-up tables. Such files consists of a number of records (maybe nestled), look-up tables, magic words (indicating structure begin, structures end, etc.) and strings in a custom-defined format.



What i want to know specifcally is how to do this with the STL and C++... Since the format is meant simply for the use of a game i would think it would be much easier though. The format should:




  • Be traversable (i can look through it and find the start of structure and maybe check it's name

  • Be able to hold multiple classes and data in a single file

  • have identifiable starts and ends to sections: such as the space in text files

  • Maybe have it's own icon to represent it??


How do i do this in c++ ?



Answer



try using boost serialize! other than that what you are asking for is how to implement serialization and that's a real complicated thing! I've recently implemented an implementation for serialization and it's no easy case to talk about.


there is also another way to only save one class into file which contains all the information you need, which makes saving/loading classes much more simpler.


by the way icon is not anything related to file format it's something OS generates per file, and usually icons are stored somewhere between OS files. except for windows executable files(as far as I know). windows executable files are like a zipped folder, containing the actual binary operations, icon data for some various resolutions, and maybe some other data related to OS itself.



An adjective for a person who won't readily accept things?


I'm looking for a word in English that describes a person who wont easily accept what you tell him/her. For example, if you tell her you're beautiful she would say, "No I'm not." If you tell her she has changed she will say, "No, I haven't." If you tell her things will get better she will say, "No, they won't."


And I'm not looking for the word "depressed" – lol.




meaning in context - "What" or "who"?


Imagine having to speak about a profession that no longer exits or is no longer called what it used to be (e.g. "beadsman," "friar," "apothecary"). The audience knows that the talk is about a dead profession, but they don't know yet what it is exactly and whether it was performed by a man or woman. Now, you want to ask them a question to ease them into the subject. The question asks if any of the audience knows about the profession.


Do you ask:



a. Does anyone know what an "apothecary" is?


b. Does anyone know who an "apothecary" is?




"What" suggests that "apothecary" could be something not someone, which may throw the audience out of balance (remember that they have very little background; they can get easily confused)


And


"Who" sounds as if I were asking about his identity or something


Please help.



Answer



A profession is a thing, not a person.


 Q. What is a carpenter? 
A. A person who works with wood.

Q. Who is the carpenter?

A. Dave.

By the way, a friar is neither a profession nor obsolete. A friar is a member of a mendicant religious order (Franciscans, for example) and they still exist today. A friar could practice many different professions.


storyboard - In a visual novel game, What makes a story immersive?


I am planing to make a Visual Novel Game using RenPy and was wondering, how do I make the story immersive to the players playing?


In this Horror Game, there will be drama, thrill and mystery to solve. You are playing as one character and interacting with a couple NPCs.


So what I am really asking is how do I make the charcter’s in the game likable and hate able to give off that feeling of “you are inside the story and not just watching a movie”. Is it the story, is it the dialogue or is it the graphics? or just something else that I am missing.




Answer



There are many theories about how to maintain immersion in games, and no single ingredient that does it all. But here's one framework I've found useful personally:


It's a psychological theory of motivation called Self Determination Theory. It says that humans (players) are motivated by three core drives: Autonomy, Competence, and Relatedness.




  • Autonomy is an alignment between what you're doing and what you personally value. Few things will sap a player's investment in a story faster than a long sequence of actions they don't care about but have to do/read through anyway.


    In games, autonomy is often mistaken for "choice," but giving tons of wide-open choices is basically throwing eggs at the wall, hoping one of them lands on what the player cares about. Instead it's more effective to identify a few core values the player is likely to be pursuing, and drive key moments around threats or opportunities related to those values. Even stronger is when you can put those values in conflict, so the player needs to reflect and make very personal choices about which to prioritize. This promotes a "volitional" mode of play, where players are drawn into actively striving toward goals they care about, even when real choices are sparse.


    It may seem like a silly example, but play deep enough into Hatoful Boyfriend and you'll find that some of the most deeply immersive parts of that visual novel are almost entirely linear. They work by building the player's investment early in the game, and establishing high stakes targeting those values, so the player is motivated to push through the available path.


    Giving players in-game tools to express what they value and why can help cement this feeling of autonomy, even when the player has to take actions contrary to those values. Just including a reluctant yes option when "no" isn't available, or conversations where the player can express their conflict, can let the player feel listened to, and allows them to act in a way that's consistent with what they care about even when they have to make compromises or bump into the boundaries of what the written possibility space allows.





  • Competence is a feeling of control and capability, that your skills are up to the tasks you're pursuing, and that you are growing and learning over time. Traditionally this is an area where games have excelled through their tight loops of challenge, action, and reward, driving the player to learn, apply, and master their mechanics, and progression systems that show you measurable growth even during learning lulls.


    It can be more difficult to create a sense of competence in a visual novel game though. Because the options available to the player at each juncture might be totally unique, they can have a hard time predicting the consequences of each option and making deliberate, meaningful choices. Every time you hit "oh, wait, that's not what I expected that choice to do!" you've put the player in a position of not feeling competent.


    Ensuring your story and world have what Emily Short calls systematic mechanics can help with this: rules and conventions your player can learn over time and apply to inform new choices in scenes they've never seen before. The developers at Inkle for example conceived of 80 Days as a board game at its foundation, where the player can exercise their competence, with the story layered on top providing context, nuance, and richness. This lets the player choose with purpose, and develop a mental model of how to make progress toward their goals.




  • Relatedness is a feeling of connection with other people, of belonging in a community, or being a part of something bigger. It's strongest when used with other real players, but it's possible to cultivate strong relatedness with non-player characters too. Most normal writing advice applies here, about creating characters with depth and motivations, so they don't appear one-dimensional.


    In games we also have the ability to shape interactions and dependencies on the characters - giving the player the opportunity to rely on another character for support, or make sacrifices to help them, can help foster strong relationships. One reason Aeris's death in Final Fantasy 7 was felt so keenly by so many players was that she served as the player's primary healer, so the narrative loss of the character was backed-up with an "oh shit, what now?" sense of dread from their practical gaming instincts too.





Once you're structuring your game around these core drives, you can also subvert the theory and selectively deny the player one of these axes to create emotional turning points.


For more on applying self-determination theory in games, I recommend checking out the work of Scott Rigby and Troy Skinner of Immersyve. They've developed a model based on SDT they call PENS (Player Experience of Need Satisfaction) and they've given many presentations exploring how these aspects drive play. (Granted, they also want to sell their services, so take this with the requisite grain of salt too)


collision detection - 3D RTS pathfinding


I understand the A* algorithm, but I have some trouble doing it in 3D to suit the needs of my RTS


Basically, in the game I'm making, there will be agents with different sizes of OBB collision boxes.


I can use steering behaviours for avoiding other agents, so I don't need complete dynamic pathfinding. However, there is a problem because different agents have different collision geometry, and structures can be placed in almost any place. This means that there might be a gap between two structures where some agents can go through and some can't.


A solution I have found to this problem is to do a sweep of the collision geometry of the agent from start node of the edge the pf algorithm is currently testing, to the end node of that edge. But this is probably a bit overkill since every edge the algorithm tests would also have to create and test with a collision geometry sweep.


What are some reasonable approaches to this problem? I should mention that I'd prefer not to use navmeshes, I prefer waypoints because my entire system is based on it atm.



Answer



Since you're talking about combining waypoint path-finding and steering behaviours I strongly suggest you take a look at the Corridor Map Method (CMM), if you aren't already.


It creates a waypoint graph that includes clearance information which is helpful for constraining the steering behaviours.



A derivative method that just popped in my head, which might be less of a hassle to implement than the CMM (no expensive off-line processing phase), is to use your current waypoint graph and add chokepoint waypoints with clearance data where necessary.


mathematics - Make a fake random distribution?


Sometimes a "real" random event seems unfair and makes players frustrated. For instance a enemy has probability of 20% to cause double damage("critical hit"). Thus he could make 4 critical hits in a row with 1/725 probability. It's not as small as it sounds.


I hope the probability could be adjusted after each hit. If the player just got a critical hit, the probability decreases for the next hit. Otherwise it increases.



Is there a mathematical model for this behaviour?



Answer



You may wish to completely rethink what "critical hits" do in your system and why you're using them. "Well, other RPGs use them!" is not a valid reason. One warning sign of a skewed design is the need to apply more and more special rules.


Any kind of random bonus takes away from direct, tactical player skill and adds to strategic planning (RPG item load-out, prioritizing stats on gear, etc...). Because of this shift of focus you have to decide what your game is about before wantonly applying old standards like criticals and fumbles.


My suggestion is that if you want randomness to take any part in your game then glory in it, let it be random.


But if you really want to add more arbitrary rules you can simply start a countdown when the first critical happens and during that countdown any more criticals are reduced to 50% and then 25% and so on. Each critical, of course, resets the countdown. This gives you two places to tune your arbitrary rules: how long is the countdown and how much reduction is accumulated at each critical. A combination of those two controls lets you clearly avoid the unspoken problem of "what if the boss gets a critical, then normal, then second critical?" that a simple chain check wouldn't fix.


c++ - 2D AABB collision response


I'm making a simple platformer, and I wanted simple collision handling. So I gave all my objects an AABB hitbox and tried to resolve collisions. However, I can't get it to work.


My main character has a 32x32 hitbox and my walls have a 16x16 hitbox. I've used the separating axes solution to resolve the collision, like so (unoptimized):


Vec2 Box::Collides(Box* a_Other)
{
Vec2 sum_extents;
sum_extents.x = (m_Max.x - m_Min.x) + (a_Other->GetMax().x - a_Other->GetMin().x);

sum_extents.y = (m_Max.y - m_Min.y) + (a_Other->GetMax().y - a_Other->GetMin().y);

Vec2 double_center_to_center;
double_center_to_center.x = (a_Other->GetMin().x + a_Other->GetMax().x) - (m_Min.x + m_Max.x);
double_center_to_center.y = (a_Other->GetMin().y + a_Other->GetMax().y) - (m_Min.y + m_Max.y);

bool result = (fabsf(double_center_to_center.x) < sum_extents.x) && (fabsf(double_center_to_center.y) < sum_extents.y);

if (result)
{

return (
Vec2(
((sum_extents).x - (double_center_to_center).x) / 2.f,
((sum_extents).y - (double_center_to_center).y) / 2.f
)
);
}

return (Vec2(0.f, 0.f));
}


My character just falls down onto the floor. I check the object I want to check against every other object and just see which one has the smallest intersection area.


Object* Scene::Collides(Object* a_Test, Vec2& a_Difference)
{
float smallest_area = 10000.f;
Object* closest = NULL;
Vec2 final;

std::vector check;


for (uint32 i = 0; i < s_ObjectTotal; i++)
{
if (a_Test == s_Objects[i]) { continue; }

Vec2 test = a_Test->GetCollision()->Collides(s_Objects[i]->GetCollision());
float area = test.x * test.y;
if (area > 0.f)
{
check.push_back(test);


if (area < smallest_area)
{
smallest_area = area;
final = test;
closest = s_Objects[i];
}
}
}

if (closest)

{
a_Difference = final;
}

return closest;
}

The hitbox for the player is (32, 229.999995)(64, 261.999994) and the hitbox for the floor is (48, 256)(64, 272). So, the resulting movement (to resolve the collision) is (16, 5.9999930). The y is correct, the x is not. As a result, the player character hits the floor, stays above it and slides to the right very fast.


How do I resolve this collision?




Thursday, July 30, 2015

opengl - Why do we move the world instead of the camera?


I heard that in an OpenGL game what we do to let the player move is not to move the camera but to move the whole world around.


For example here is an extract of this tutorial: OpenGL View matrix



In real life you're used to moving the camera to alter the view of a certain scene, in OpenGL it's the other way around. The camera in OpenGL cannot move and is defined to be located at (0,0,0) facing the negative Z direction. That means that instead of moving and rotating the camera, the world is moved and rotated around the camera to construct the appropriate view.



Why do we do that?



Answer



Why ?



Because, A camera represents a projection view.



But in case of 3D Camera (Virtual Camera), camera moves instead of the world. I have made a detailed explanation later of this answer.



Understanding Mathematically


Projection View moves around space and change its orientation. The first thing to notice is that the desired projection on the screen does not change with view direction.



For this reason, we transform other things to get the desired projection.


Understanding From http://opengl.org


To give the appearance of moving the camera, your OpenGL application must move the scene with the inverse of the camera transformation. where OpenGL is concerned, there is no camera. More specifically, the camera is always located at the eye space coordinate (0, 0, 0)




Understanding From http://open.gl


Also want to share the following lines from View matrix portion of http://open.gl/transformations



To simulate a camera transformation, you actually have to transform the world with the inverse of that transformation. Example: if you want to move the camera up, you have to move the world down instead.



Understanding by perspective


In the real world, we see things in a way that is called "perspective".


Perspective refers to the concept that objects that are farther away appear to be smaller than those that are closer to you. Perspective also means that if you are sitting in the middle of a straight road, you actually see the borders of the road as two converging lines.


That’s perspective. Perspective is critical in 3D projects. Without perspective, the 3D world doesn't look real.



While this may seem natural and obvious, it's important to consider that when you create a 3D rendering on a computer you are attempting to simulate a 3D world on the computer screen, which is a 2D surface.


Imagine that behind the computer screen there is a real 3D scene of sorts, and you are watching it through the "glass" of your computer screen. Using perspective, your goal is to create code that renders what gets "projected" on this "glass" of your screen as if there was this real 3D world behind the screen. The only caveat is that this 3D world is not real…it's just a mathematical simulation of a 3D world.


So, when using 3D rendering to simulate a scene in 3D and then projecting the 3D scene onto the 2D surface of your screen, the process is called perspective projection.


Begin by envisioning intuitively what you want to achieve. If an object is closer to the viewer, the object must appear to be bigger. If the object is farther away, it must appear to be smaller. Also, if an object is traveling away from the viewer, in a straight line, you want it to converge towards the center of the screen, as it moves farther off into the distance.


Translating perspective into math


As you view the illustration in following figure , imagine that an object is positioned in your 3D scene. In the 3D world, the position of the object can be described as xW, yW, zW, referring to a 3D coordinate system with the origin in the eye-point. That’s where the object is actually positioned, in the 3D scene beyond the screen.


enter image description here


As the viewer watches this object on the screen, the 3D object is "projected" to a 2D position described as xP and yP, which references the 2D coordinate system of the screen (projection plane).


To put these values into a mathematical formula, I'll use a 3D coordinate system for world coordinates, where the x axis points to the right, y points up, and positive z points inside the screen. The 3D origin refers to the location of the viewer's eye. So, the glass of the screen is on a plane orthogonal (at right angles) to the z-axis, at some z that I’ll call zProj.


You can calculate the projected positions xP and yP, by dividing the world positions xW, and yW, by zW, like this:




xP = K1 * xW / zW
yP = K2 * yW / zW



K1 and K2 are constants that are derived from geometrical factors such as the aspect ratio of your projection plane (your viewport) and the "field of view" of your eye, which takes into account the degree of wide-angle vision.


You can see how this transform simulates perspective. Points near the sides of the screen get pushed toward the center as the distance from the eye (zW) increases. At the same time, points closer to the center (0,0) are much less affected by the distance from the eye and remain close to the center.


This division by z is the famous "perspective divide."


Now, consider that an object in the 3D scene is defined as a series of vertices. So, by applying this kind of transform to all vertices of geometry, you effectively ensure that the object will shrink when it's farther away from the eye point.


Other Important Cases




  • In case of 3D Camera (Virtual Camera), camera moves instead of the world.


To get a better understanding of 3D cameras, imagine you are shooting a movie. You have to set up a scene that you want to shoot and you need a camera. To get the footage, you'll roam through the scene with your camera, shooting the objects in the scene from different angles and points of view.


The same filming process occurs with a 3D camera. You need a "virtual" camera, which can roam around the "virtual" scene that you have created.


Two popular shooting styles involve watching the world through a character's eyes (also known as a first person camera) or pointing the camera at a character and keeping them in view (known as a third person camera).


This is the basic premise of a 3D camera: a virtual camera that you can use to roam around a 3D scene, and render the footage from a specific point of view.


Understanding world space and view space


To code this kind of behavior, you'll render the contents of the 3D world from the camera's point of view, not just from the world coordinate system point of view, or from some other fixed point of view.


Generally speaking, a 3D scene contains a set of 3D models. The models are defined as a set of vertices and triangles, referenced to their own coordinate system. The space in which the models are defined is called the model (or local) space.


After placing the model objects into a 3D scene, you'll transform these models' vertices using a "world transform" matrix. Each object has its own world matrix that defines where the object is in the world and how it is oriented.



This new reference system is called "world space” (or global space). A simple way to manage it is by associating a world transform matrix to each object.


In order to implement the behavior of a 3D camera, you'll need to perform additional steps. You'll reference the world—not to the world origin—but to the reference system of the 3D camera itself.


A good strategy involves treating the camera as an actual 3D object in the 3D world. Like any other 3D object, you use a "world transform" matrix to place the camera at the desired position and orientation in the 3D world. This camera world transform matrix transforms the camera object from the original, looking forward rotation (along the z-axis), to the actual world (xc, yc, zc) position, and world rotation.


Following figure shows the relationships between the World (x, y, z) coordinate system and the View (camera) (x', y', z') coordinate system.


enter image description here


libgdx - Why does resizing my game window move and distort my rendering?


I'm starting to make a game, and the first screen I've made is a very simple loading screen with some centered text.


On starting it up, the text is nicely centered: enter image description here


Then I resize the window, and I get: enter image description here


Why is it stretched? And why has it moved? Looking at my code it looks like everything should be perfectly centered:


public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0.2f, 1);

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

if (Assets.manager.update()) {
// Eventually change to a main menu or something
}

String text = "Loading " + Math.round(Assets.manager.getProgress()) + "%";

BitmapFont.TextBounds bounds = fnt.getBounds(text);


batch.begin();
fnt.draw(batch, text, (Gdx.graphics.getWidth()/2)-(bounds.width/2), (Gdx.graphics.getHeight()/2)-(bounds.height/2));
batch.end();
}


xna - Good example of a multi-pass effect?



In XNA (and Direct3D in general AFAIK), rather than creating individual vertex and fragment shaders, you bundle potentially many related shaders into 'Effects'. When you come to use an effect you select a 'technique' (or iterate through all of them) and then each 'technique' has a number of 'passes'. You loop through the each pass it selects the relevant vertex and fragment shader and you draw the geometry.


What I'm curious about though is what you would need multiple passes for? I understand in the early days of 3d you only had one texture unit and then you had 2 and that often still wasn't enough if you also wanted to do environment mapping. But on modern devices, even in the mobile class, you can sample 8 or more textures and do as many lighting calculations as you'd want to in a single shader.


Can the more experienced here offer practical examples of where multi-pass rendering is still needed, or is this just over-engineering on the part of XNA/Direct3d?



Answer



Any time you're doing post-process effects on a set of captured buffers would be a reasonable time to use a multi-pass effect, i.e. toon outlining, motion blur, SSAO, bloom. The idea being that the first pass would be where you'd render everything out to the appropriate buffers, and each subsequent pass would handle each post-process effect.


Like Ranieri mentioned about the XNACC example, they're using multiple passes to render a huge number of lights. Though in that example, they're executing the same pass, just once for each light.


Keep in mind that Shader Model 2 and before can't handle having anywhere near as many instructions as Shader Model 3 or 4 in each shader, yet another reason to split an effect into multiple passes -- to support older hardware.


grammar - When -s is used with third person singular. What's its use in this context?


During a conversation


My friend wrote •shrugs•



Why shrugs not shrug?


She was the one who did it then why third person singular form?



Answer



It is becoming increasingly common during text messaging to write actions as if they are from a script, for example, words like laughs or shrugs describe an action that the other person is doing but you cannot see over a text message.


TV and movie scripts are often written this way:



BOB
WHY DID YOU WRITE THAT?


JOHN
[SHRUGS]




The tense makes sense in a script because it is a prompt to say what happens. I guess this has just found its way into text-messaging as I have seen it done quite a few times.


It is also possible that your friend tried to send some kind of emoji that is named "shrugs" and you just saw a text representation of it.


grammar - "have been here" vs. "have been being here"


Which one is correct? I know the present perfect continuous tense is for what. My question is here that we should use that tense when we want to say "I was here (a city) for ten years and now I am here as well" we must use the present perfect continuous but we use the present perfect (I've seen in the grammar books):



I have been here for ten years.



vs.


I have been being here for ten years.




Answer



I have been being here is not idiomatic.


You have probably learned that there is a category of verbs which are only very rarely used in with the progressive/continuous construction: stative verbs like be, know, live, see which express a state rather than an action or event. These verbs have the fundamental sense of a continuing state (which is what the progressive/continuous construction expresses) built into their meanings, so the progressive/continuous is superfluous.


For the same reason these verbs are rarely used with the progressive/continuous perfect construction. Indeed, there is even stronger pressure to avoid the progressive/continuous perfect, because the perfect is also inherently stative: it designates a state which came into being as a result of a prior action or event.


Saying I have been being here for ten years thus adds nothing to the sense of I have been being here for ten years, so we don't say it.


Furthermore: These "rules", like most "rules" of grammar, are not absolute: there are exceptions. But lexical be (that is, be as a main verb, not a component of the progressive or passive construction) is exceptionally resistant to exception, because it is the most "stative" of verbs: it ordinarily expresses nothing beyond a particular state. In consequence, when lexical be is cast in the progressive construction it usually has a different meaning, approximately "temporarily behave":




"John is being a jerk" does not mean that John is a jerk but that John is behaving like a jerk right now.



path finding - A star pathfinding and discrete/smooth positions



The A* (A-star) algorithm usually represents a path on a grid.


Once a path has been found, however, the path looks blocky and is not suited if you move your units with floating point datatypes.


Here is an image describing the problem. The whites tiles represent the path found by A*. The black line path is the path I want, the red line path is the one I don't.


here is the picture


One solution would be to select a corner when the path turns, and switch/keep side when the path turns the other way. Seems like the most logical and cleanest way to do this.




game design - How to deal with (bad?) player suggestions


Every game which builds a community while still being in active development will soon be confronted with players who post suggestions for new features on its forum. Most of these suggestions, however:



  • Go into a completely different direction than where you want your game to go

  • Would require far too much effort for the benefit they could have

  • Are just plain awful



What's a good way to deal with such suggestions?


Should you tell the players honestly what you think about their suggestions so that they learn to make more constructive ones?


Should you always try to maintain a positive and encouraging attitude towards player ideas, even when you secretly think that there is not a chance in hell you are following them?


Should you just ignore any suggestions which you don't like?



Answer



People who make suggestions are often fans or critics, who are invaluable as they help you know how well you are doing. Therefore you should treat these people with respect. Be gentle, firm, and most importantly, honest. This means you tell them exactly why you think their idea is bad, whilst being as understanding as possible.




  • If the idea is technically difficult, tell them so, and explain how it is technically difficult. Stick to the facts, stick to established wisdom. Address the difficulty as a shortcoming of the current system, rather than the impracticality of the suggestion, and never suggest that the player lacks technical know-how (even though that is often true).


    Good: To support 100 billion players, we'll have to move to some server cluster solution, and we just don't have the resources to do that in a reasonable time.



    Bad: That's not even physically possible; the algorithms involved have not even been discovered.




  • If the idea has merit but goes in a different direction, tell them so, and explain how the idea goes against your direction. Try to be diplomatic, and keep in mind that design is subjective, but at the same time be firm in stating that you have control over the artistic/design direction of the game.


    Good: I believe lasers will look out-of-place with the medieval theme of this game, and we want to be faithful in our rendition of a medieval society.




  • If the idea has flaws or lacks merit, tell them so, and explain its shortcomings. Keep in mind that for whatever reason (limitations of the medium, difficulty in expression, lack of forethought), the player may not be aware of the flaws, so kindly but clearly point them out. You'll find that players often come back with refinements, clarifications or just drop the idea, which are all much better outcomes. Remember that with a lot of ideas, players are dying to get a whiteboard and explain their idea face-to-face, but instead have to resort to a crappy text-only medium, so do not assume that just because the idea comes off as flawed that it is actually so. Also consider that a lot of great games started from ideas that don't seem brilliant at all, and it was execution that made them great.


    Good: Dishing out a 1-hit-KO spell may be fun, but I think it would be very annoying to be on the receiving side.





  • If you just don't find the idea good, tell them so, but be careful how you tell them, and always suggest alternatives. This type of response is the hardest to give, so see if you can treat it as one of the previous cases instead - eliminate the technical and obvious flaws first. In forming your response, assume that the idea is actually good, and ask why did the idea come off as bad? Does the player need to sell it a bit more? Would examples, sketches, or demos help? Would getting more community support help? Always give them a realistic out - what would convince you, and how could they go about it? Try to see the idea in the best possible light, don't be defensive, and look for that hidden kernel of wisdom that is often there.


    Good: I don't think a half-elf-dragon-devil-samurai-ninja would look good and be balanced, could you please show me what it might look like, what its stats and abilities might be?




Another way of looking at the problem is: these people may not be game development experts, but they could very well be experts in other areas that you are not - they could be doctors or lawyers. I'm sure you've said things that your doctor/lawyer would consider hare-brained, so ask yourself how you would like them to respond in that situation.


Wednesday, July 29, 2015

game maker - Way to Round Numbers


I have it when the player clicks the mouse they can move the peice aoround the board. I am trying to have the chess pieces snap to a grid after the mouse has been released. Is there any way to round numbers so that I can round the X and Y coordinates so that it will snap to the grid?



Answer



You will basically turn the position of your mouse click into an integer. To do this simply divide the coordinates obtained by the size of the grid you want to create (32 in my case).


Then just multiply by the same amount you divided (32 in my case).


Splitting has to be done using div, no /.



Create Event:


gridx=0;
gridy=0;

Global Left Pressed Event:


gridx=mouse_x div 32;
gridy=mouse_y div 32;

x=gridx*32;
y=gridy*32;




The way I suggested above is more didactic and simpler to change, but if you want it can be simply...


Global Left Pressed Event:


x=(mouse_x div 32)*32;
y=(mouse_y div 32)*32;

Tuesday, July 28, 2015

word meaning - Having, holding, giving, and throwing parties


What is the difference between "hold a party", "have a party", "give a party" and "throw a party"?



Is there any difference in meaning? Can we use them interchangeably?


Could you provide some examples (if any exist) where we can't replace one by another?



Answer



I think they're all pretty much interchangeable. As I tried to think of an exception, I wondered if throw would be a bit more appropriate for a wild party, and less appropriate for a less festive occasion. However, I found plenty of instances of "throw an office party" on Google, enough to convince me that throw doesn't necessarily imply "wild and crazy."


One additional verb you could use is "host": We are going to host a party on the 11th.


For what it's worth, here's an Ngram, but there's nothing too remarkable there.


word order - Position of not in questions


Is there any difference between the following sentences?



Could not you help him?
Could you not help him?




For me, it seems as if the first sentence is more like a complaint 'You didn't help him, I'm angry at you' while the second one is 'Could you stay away and not help him? I want him to do it on his own'.



Didn't you help him?
Did you not help him?



In this pair, I read the first one as 'I think you helped him. Didn't you?' and the second as 'Did you refuse to help him?'. Am I right?



Answer



Syntactically, OP's first alternative (Could not you help him?) is more "correct", in that it places the negating not closer to could - the element it most applies to. But idiomatically today we almost always contract that to...




Couldn't you help him?



...even in "formal" contexts. But people often think of such contractions as "informal", and precisely because everyone normally makes the above contraction, the full form as given by OP tends to sound "strange" to the native ear. Thus, when looking for more formal phrasing we're likely to think in terms of discarding the contraction, but we avoid OP's #1 and go for #2 because it doesn't sound quite so odd.


In fact, given a formal setting (lawyer questioning witness, say) there's nothing at all unusual about...



"Is not this the murder weapon, Professor Plum?"
"Could not the gun cabinet have been left unlocked, Colonel Mustard?"
"Was not the dagger kept with the other cutlery in the kitchen, Mrs Peacock?"






OP's idea that the position of not determines whether it's a genuine enquiry or a complaint isn't quite right. What matters is that a complaint would stress the word not - which you can't do if it's contracted. You want that stress because effectively all the other words in the utterance apart from could and not simply describe the current situation (although less common, in most contexts it's possible to stress could instead of not when the intention is to complain about something rather than ask if it's true).


Note that it's not always possible to distinguish a question from a request. For example, given just...



"Could you not do that?"



...it can often be effectively impossible without further context to establish whether the speaker is asking you to stop doing something (complaint) or asking whether you're unable to do it (question).




In short, context and intonation are crucial in such negated constructions. Consider, for example,...



"Could you not do that?"




...which might mean...



1: You're doing it right now, and I want you to stop
2: It's what you plan to do, and I'm asking if you will (or are able to) change your plan
3: It's not what you plan to do, but I'm asking if you will change your plan
(and probably other possibilities)



If it's not obvious how #2 and #3 apply, consider "Could you not work tomorrow?", which could either be asking you to take an unscheduled day off, to work on a day when you normally wouldn't.


architecture - How to design a game's software such that it is easy to unit test?


Is it practical to use a testing framework like JUnit in a game development situation? What sort of design considerations can you follow in order to make your game more testable? What parts of a game can/should be tested and what parts should/must be left to human testing?


For example, if the game loop is encapsulated in one function, it seems like it would be terribly hard to test. I like to refactor out an "update" function that takes a time delta and moves forward the game logic; this allows some interesting tricks like the ability to slow the game down by feeding it fake, slower time deltas.



Answer



One of the tenets of TDD is that you let TDD in some cases influence your design. You write a test for system, then write the code to make that test pass, keep dependencies as shallow as possible.


For me, there are only two things I don't test as part of unit testing:



First, I don't test visual elements and how things look. I test that and object will be in the right place after it updates, that a camera will cull an object outside it's bounds, that transforms (at least those that are done outside of shaders) are performed properly before being handed over to the graphics engine, but once it hits the graphics system I draw the line. I don't like trying to mock out things like DirectX.


Second, I don't really test the main game loop function. I test that every system will work when passed a reasonable delta, and that systems work together correctly when they need to. Then I just update each system with the correct delta in the game loop. I could actually have a test to show that each system got called with the correct delta, but in many cases I find that overkill (unless you're doing complex logic to get your delta, then it's no overkill).


Monday, July 27, 2015

grammaticality - Word order: "10 minutes more" or "10 more minutes"?





  • I'm still packing my clothes. I'll need 10 minutes more.

  • I'm still packing my clothes. I'll need 10 more minutes.



Are both grammatically correct?



Answer



They're both correct. But "I need 10 more minutes" is probably more common. (There's no reason to make it progressive or conditional. The need is in the present.)


Sunday, July 26, 2015

tense - When a sentence includes a word like 'today' that indicates present time, can a past form of verb be used?



  1. Today an excruciating accident has taken place in our vicinity.

  2. Today an excruciating accident took place in our vicinity.



Today indicates the present time. So I prefer has taken, which has been used in first sentence. But a native speaker of English said that he would prefer took place, though he didn't tell me why he would do this.


Now I ask to the members of this site what do they think about this?



Answer



Today is not necessarily the present. Today signifies the present in the first sentence, since the sentence would be invalid/ungrammatical with an adverb of time that is completely in the past (example: yesterday).


However, since today lasts 24 hours, the use of 'today' in the second sentence (using the simple past) refers to earlier today or earlier in the day, which is in the past. Thus the same word today is conceived of in two different ways.


The use of the present perfect is often used to report the latest news. Its effect is to make the news seem more urgent to listeners or readers.


The use of the simple past reports the event as something that is over and done with, that is, an event that took place in the past.


Again, either verb tense is fine, because today is being used differently.


Another example is




I had a really good day today.



Although "today" is not over, the speaker is referring to the part of the 24-hour period of today that is in the past.


Compare with



I have had a really good day today.



Using the present perfect in this sentence, the adverb of time today must include the moment of speaking (that is, the present).


The possessive S should not be before the noun that it belongs to?


I'm solving English grammar exam (MCQ) and one of the questions there is about the next sentence:



This car is my car, and that car is Tom's.



According to what I know the possessive s should come before the name rather than after him or in the end of sentence. Therefore it should be Tom's car rather than car Tom's. Then I'm not sure if what I see in the exam is just a mistake or it has explanation.


enter image description here




Where can I find free md2 models and .obj objects for a boxing game?



I'm creating a first person boxing game in Opengl as a school project and I want textures and models to apply to it. A look like Wii Sport's Boxing is what I'm aiming for.


Something like this (but, you know, free)



Answer



The problem with free is, as the saying goes, you often get what you paid for :)


A good place to find 3D models (from the good to the unbelievably ugly) is the Google 3D Warehouse. It's a huge collection of free models that can be loaded with Google's Sketchup program plus be loaded in to Google Earth if geo-referenced.



From the site, here is a model of a boxing ring that can be downloaded in Collada format as well as for Google Sketchup. You ought to be able to find a way to convert Collada to OBJ.


alt text


http://sketchup.google.com/3dwarehouse/details?mid=1579926f4237c91137494d2d6fb60eef&prevstart=0


meaning in context - What does "they’ve got a hotel to run" mean?



They’ve got a hotel to run.



I've across with the phrase above in a novel. But apparently it's a famous sentence in The Furchester Hotel:



They're furry and crazy - and they've got a hotel to run!



But what does it mean?





Note: James and Bradley are the hotel's owners.


The fuller text is:



“If we could all just stop pointing the finger at me for a minute, there’s something I’d like to bring up,” Matthew says. He knows he sounds a bit aggressive; he doesn’t care. They’ve practically accused him of murder, for God’s sake. “What’s that?” David says. “I think James and Bradley are hiding something.” James looks completely taken aback. Bradley flushes to the roots of his hair. “What do you mean?” James stammers. Matthew leans toward James and Bradley, who are seated together. “This is your hotel. Maybe you know something the rest of us don’t.” “Like what?” James says, on the defensive. “I don’t know. But I’ve seen you two whispering together. What have you been whispering about?” “We haven’t been whispering,” James says, coloring. “Yes, you have, I’ve seen you.” “Oh, for Christ’s sake,” Ian interjects, “they’ve got a hotel to run.”




Answer



When you've got a {something} to {verb of doing} you have (pressing) obligations in respect to the something.


We've got a test to take. We must take a test.



We can't party tonight. We've got a test to take.




We've got a hole to dig. We must dig a hole.



We're not making much progress here. Come on guys, we've got a hole to dig!



We've got a cake to bake. We must bake a cake.



Stop playing with the spatula. Your cousin's visiting tomorrow. It's her birthday, and we've got a cake to bake.


Come on, kids! We've got a train to catch!




articles - Why do we say 'The earth' and not 'An earth'?


As I understand, noun which is singular and start with vowels, we put an article "an" in front of it. ( e.g an eye, an ear )
But why it is not "an earth" and why "the earth"?



Answer



You seem to be mixing up two rules here.


We use an instead of a when the next word starts with a vowel sound. Indeed, 'a ear' would sound clumsy, so we say 'an ear'.



We do not use an instead of the; the English have no problem at all saying 'The ice is thick' or 'The ears of a cat are fluffy' (in fact, I would be hard-pressed to find a sentence with 'an ice' in it, since 'ice' is a mass noun).


The distinction between a / an and the is well explained in the other answers.


Saturday, July 25, 2015

How can I minimise memory thrashing when doing vector math in C# or C++?


I'm doing a lot of 3D math in my game engine loop using typical classes like Vector3D, Matrix4x4, Plane3D, etc. Currently every operation causes a new object to be created for the result value. The number of new objects created causes a stutter whenever the GC kicks in.


In this simple vector operation, 2 new Vector3D objects are created, one at the divide and one at the multiply operator.


// C#
result = (v / len1) * len2; // where len* is a `double`


I happen to know some C++, so an optimized version would create a disposable object on the stack and pass that to the individual ops, thereby automatically disposing off the temporary objects at the end of the function (also avoiding the GC altogether), something like this:


// C++
Vector3D result;
v.divideBy(len1, &result);
result.multiplyBy(len2, &result);

But as you can see its cumbersome and unreadable. So what are commonly used memory optimization strategies used by pro C++ gamedevs to optimize vector math? I'm looking for general platform agnostic solutions that can be implemented in C# and other high-level languages, although C++ memory tricks are also appreciated.



Answer



Are you sure that the matrix operations are causing the slowdown? In C# most Vector libraries implement their types as structures, which are not generally allocated using the garbage collector, but are instead created on the stack. The temporaries in your example don't cause allocations that need to be collected.



networking - Implementing network smoothing


We are making a multipler first person shooter. The client sends it's position to the server at a fixed rate (currently at 10Hz). The server sends a single message contatining all player's positions to all players at the same rate (10Hz).


As expected, the movement is pretty choppy since the 60fps game is only recieving updates 10 times a second. What is the best way to smooth this movement? The most obvious way would be to interpolate between the last two packets, so that the interpolation finishes as we recieve a new packet. But this adds an instant 100ms delay for all players.


The other way would be to use the velocity and acceleration inferred from the last few packets to predict where the player is before the next packet arrives, however if the prediction is wrong, the player would tend to jump as soon as a new packet is recieved.


Does anyone know how AAA titles solve this problem?



Answer



They do exactly what you've just said - either one of those two approaches, or some compromise between them. (eg. accept a small delay and interpolate where possible, and extrapolate when the ping exceeds that delay.) Instead of jumping (also known as 'snapping') back to a corrected position, you typically do some sort of interpolation between the wrong prediction and the corrected value, smoothing it out, if possible. You also handle the corrections in the past to reduce the amount of correction you need to apply.



This is a frequently asked question and there are several canonical links which you will probably find elsewhere on gamedev.stackexchange.com if you search, and they include the following:


What every programmer needs to know about game networking (this summarises stuff in the next two links)


Source Multiplayer Networking


Unreal Networking Architecture


c# - How can I accurately simulate orbits in Unity?


I would like to create a space simulation with realistic gravity.


This means planets in 3d space which act as central gravity sources and multiple objects which are attracted by those planets gravity so that they orbit them in physically correct orbits (like in Kerbal Space Program, for example).


How can I implement such gravity sources with C# script?



Answer



Here is a C# script for a GravitySource component.


It requires a Collider attached to the same game object with the "Is Trigger" checkbox set. This collider represents the zone of influence of the bodies gravity. Any Rigidbodys inside of that collider will be affected.


The public property gravity needs to be set in the inspector. It represents the strength of the gravity source. The ideal value depends on the time-scale and space-scale of your simulation.


using UnityEngine;

using System.Collections;

public class GravitySource : MonoBehaviour {

public float gravity;

void OnTriggerStay(Collider other) {
Rigidbody otherRigidbody = other.gameObject.GetComponent()
if (otherRigidbody) {
Vector3 difference = this.gameObject.transform.position - other.gameObject.transform.position;


float dist = difference.magnitude;
Vector3 gravityDirection = difference.normalized;
Vector3 gravityVector = (gravityDirection * gravity) / (dist * dist) ;

otherRigidbody.AddForce(gravityVector, ForceMode.Acceleration);

}
}
}

prepositions - What is different between "for" and "to"?




  1. The place is important for/to me.

  2. I changed the variable for/to the project.

  3. I can do to/for you.


  4. In/for/to this project, I created a new method.



Does it mean any difference?


This bothered me many times.


Wish someone can answer.



Answer



Yes, the use of 'to' or 'for' usually does change the meaning of your phrase, and the difference can be quite big.


To look at your examples:




The place is important for/to me.



Here the difference is possibly the smallest. Without having any definite answer on this, I say I feel that in this case 'to' give the phrase a bit more of a personal feel. But both forms convey the same concept.



I changed the variable for/to the project.



Here, the version with 'to' sounds simply strange to me, I would always go for 'for' if given only these choices. Maybe 'in' or 'of' the project sounds even better though.



I can do to/for you.




There is a very big difference between doing something to someone or for someone. When you do something to someone, that person is the (more or less) passive 'victim' of whatever you do. If I ask what you are doing to someone, correct answers may include acts of violence :)


Doing something for someone does not even necessarily include that person's cooperation, you can buy a ticket for someone, do a chore for someone or buy a gift for someone.



In/for/to this project, I created a new method.



Here I would never use 'to'. Whether to use 'in' or 'for' depends on whether you created the method inside the project or whether it is a new method created externally, to help with the specific project, in which case you use 'for'.


meaning - Can "dress" mean "skirt"?


I've encountered a person learning English using "dress" for a piece of clothing that covers the top half of her body (and possibly her legs as well).


I was under the impression that "dress" used to mean clothing in general, but nowadays is more commonly used to mean "skirt".


However, I looked up Wiktionary and Cambridge Dictionaries Online, and both of them indicate it means a piece of clothing that covers the top half of the body and hangs down over the legs.


I'm not an expert on women's apparel. Was I mistaken in thinking that "dress" could be used for a synonym for "skirt"?



Answer



Dress can mean garb in the general sense.


But it can also mean a specific type of women's clothing. I used to think that dresses and skirts were all the same, but my wife has finally straightened me out.


A dress is a single piece of clothing that covers the upper and lower parts of the body:



red dress


whereas a skirt only covers from the waist down:


grey skirt


But some people (like me) don't understand the difference and tend to use the terms incorrectly – most people are very forgiving about it.


java - How can I add a transparent overlay to a UI in libGDX?


I am attempting to use the following code


        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(3,3,3,.3f);
shapeRenderer.rect(0,0,gameWidth,gameHeight);
shapeRenderer.end();


So that when the menu is accessed, a transparent background appears. The problem I am facing is that when I try to do this the objects rendered by the SpriteBatch seem to misbehave. Upon further research i found that attempting to nest that code within SpriteBatch.begin() and SpriteBatch.end() is the cause of that. However, If I try to place the code after the SpriteBatch.end(), because the SpriteBatch has ended the objects rendered by it do not appear behind the transparent rectangle. (I tried assigning SpriteBatch and Shaperender a different camera, however, that didn't fix the problem.) How can I fix this or find another way to implement the transparent background for the menu.




Friday, July 24, 2015

present perfect - For or Since or Nothing



Following situation is given: Sue has been in France for the last three weeks.


I have to repeat this sentence using, "She went ...", I would say something like this:



"She went to France three weeks ago."



Is this correct?


Another one: "Do you often go to the cinema?"



"No, I haven´t gone to the cinema for a long time."




I used for, because its a period of time, and I used present perfect, because there is a connection to the present.




prepositions - "Interested with the course" or "interested in the course"?




Interested in/with the course



Which preposition is correct? in or with, or both.




Thursday, July 23, 2015

javascript - Saving Scores Using Cookies


I've recently created a small galiga like game recently using JavaScript and HTML5. I've run into a bit of trouble saving cookies, the cookie saves, but then resets itself when the page is refreshed, my code:


function saveScore() {
var date = new Date();
date.setMonth(date.getMonth()+5);

var expires = "; expires=" + date.toGMTString();
document.cookie = "score=" + lvl + expires + "; path=/";
}

function loadScore() {

var cookiearray = document.cookie.split(';');
for (var i = 0; i < cookiearray.length; i++) {
var name = cookiearray[i].split('=')[0];
var value = cookiearray[i].split('=')[1];

if (name == "score") {
alert("Prior score found. Loading score...");
lvl = value;
}
}
}

EDIT: It appears as though I made an error outside of the given code, and reset the level to zero, I fixed this, and everything works well, I apologize for any confusion caused.



Answer



ddocument.cookie = "score=" + lvl + expires + "; path=/";


One d too much in document. Is that typo also in your real code?


When I might suggest an alternative solution: Why don't you use HTML5 localStorage? As long as you don't have any server-sided programming which needs persistent data, it's a much superior solution.


When you already require that the users browser supports canvas you don't have to worry about browser support for localStorage. Almost every browser which supports canvas also supports localstorage.


unity - how to get if a rotation/position has been completed?


I've done an if / else with the final position / rotation plus they never complete, how can I check this? stays like this


https://i.imgur.com/3cQ9AEk.gif


    if(head == false)

cam.transform.position = Vector3.Lerp(cam.transform.position, PosicMin, Time.deltaTime * Speed);
else {
cam.transform.position = Vector3.Lerp(cam.transform.position, PosicMax, Time.deltaTime * Speed);
}
if(head == false)
cam.transform.eulerAngles = Vector3.Lerp(cam.transform.rotation.eulerAngles, RotationMin, Time.deltaTime*Speed);
else {
cam.transform.eulerAngles = Vector3.Lerp(cam.transform.rotation.eulerAngles, RotationMax, Time.deltaTime*Speed);
}

Answer




You're using an exponential ease-out Lerp, which in real numbers never actually reaches completion. Each iteration, it moves a fraction of the remaining distance - always leaving a nonzero fraction left to go. Even in finite-precision floating point, it might not reach the destination value: at a certain point, the incremental displacement can round to less than the precision of the current value, resulting in no further change.


Fortunately, Unity's == comparison operator on Vector3s and Quaternions includes a tolerance range so it will return true when they're almost the same.


The other issue that's going to throw you off is you're trying to interpolate Euler angles. This is almost always a bad idea. The game engine does not store or use Euler angles internally - it computes them on demand from the quaternion internals. That means the output you save in one frame might not match the input you get in the next frame, due to inevitable discontinuities in computing an Euler angle triplet from an orientation. That can be the source of the perpetual jitter in your implementation. And even without that complication, Euler angles do not interpolate well in general:


Animation contrasting smooth quaternion interpolation and tumbling Euler angle interpolation




  • On the left: interpolating rotations with quaternions, we get smooth rotation along the shortest arc to the destination




  • On the right: interpolating rotations with Euler angles results in excessive spinning/tumbling





(See this UnityAnswers post for more details - unfortunately the original source of this animation is no longer available online nor in the Wayback machine, but you can play with an interactive app)


So, we can fix your code like so:


// Adjust for deltaTime correctly, given the non-linear nature of this use of Lerp.
float blend = 1.0f - Mathf.Pow(1.0f - Speed/30f, Time.deltaTime * 30f);

// Select destinations. This way we don't need to repeat our blend / check logic.
Vector3 destinationPosition = head ? PosicMax : PosicMin;
Quaternion destinationRotation = Quaternion.Euler(head ? RotationMax : RotationMin);


// Ease toward the selected destinations.
cam.transform.position = Vector3.Lerp(cam.transform.position, destinationPosition, blend);
cam.transform.rotation = Quaternion.Lerp(cam.transform.rotation, destinationRotation, blend);

// Check whether we're "close enough".
if(cam.transform.position == destinationPosition && cam.transform.rotation == destinationRotation) {
// Arrived!
}


If you want to more precisely control the threshold of what gets to count as "close enough," you can use Vector3.Distance and Quaternion.Angle to compute how far we are from our destinations, and compare those against custom thresholds.


c++ - Removing delay at start of a key press



I'm making a simple game, and one of the problems I encountered is the annoying delay when pressing a key continuously.


So basically, when I press (for a very long time) for example Up, my object will move 1 unit up, not move (for approx. 1 second), and then move continuously 1 unit up (without any delays).


Currently, I use this to move the object (SDL2):


while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{

case SDLK_UP:
//Move object 1 unit up
break;
//Other unrelated things omitted
}
break;
//Omitted other cases
}
}


What I would like to have is to remove the delay, so that the object can immediately move Up very quickly. Is there any way to do this?



Answer



By waiting for key-down events to be fired, you are likely at the mercy of the key event repeat rate that the OS controls (and which users can specify themselves).


Instead, you may want to call SDL_GetKeyboardState at the top of your game update loop (the part of the update that happens every frame, whether or not an event has come in) to get the state of the keyboard and check that to see if the up key is down or not during any individual frame.


tag questions - affirmative imperative + "will you?"


Now and then I come across an "affirmative imperative + will you?" construction where, I suspect, the speaker seems to be telling someone NOT to do something or censuring him/her for doing so, as opposed to making a request for a certain action, as in:



“Run away from me, will you?” His voice was hoarse and strangled in his throat. “I'll have your skin off your bones, I will!” He took a lurching step.



However, no English usage guides I turned to seemed to address this (supposed) usage.


Is my suspicion correct or am I on the wrong track here?



Answer



You are correct that the speaker is censuring someone for running away.


However, it is not correct to characterize the phrase "Run away from me" as an imperative. The sentence is a question and that phrase is actually simply part of the question. What makes it difficult to understand is that the sentence contains two inversions.



An inversion is a sentence structure in which the usual word order is reversed. The usual word order is “subject” followed by “verb.” An inversion places the verb, or part of the verb, ahead of the subject.


The two main reasons for inversions are (a) to ask a question or (b) for stylistic reasons. The sentence you are asking about has both types of inversion.


The verb in this sentence is "will run." The normal word order is "You will run."


The first inversion is the placement of “will” before “you.” In this inversion the helping verb ("will") comes before the subject; this is a normal word placement for a question.


The second inversion is the placement of “will you” at the end, after “run away from me.” The second inversion is done to set a tone, and for emphasis.


If we undo that inversion, the sentence reads: “Will you run away from me?”


This re-ordered sentence clearly is a question. However, it does not have the same angry undertones as the original, inverted sentence. The inversion places emphasis on the act of running away and in the context adds meaning without words.


As it is stated in the “Inversion” tutorial provided by Learn-English-Today.com



Inversion . . . is a literary technique in which the normal order of words is reversed, generally for emphasis or special effect. It makes a sentence sound striking or unusual. It also sounds quite formal. Sentences with inversion are less common in ordinary English. In a sentence with no special effect or emphasis, the normal order of words is retained.



Example 1: I have never seen such a beautiful rose.


Example 2: Never have I seen such a beautiful rose.



For more information about inversions, you may wish to start by taking a look at that tutorial. http://www.learn-english-today.com/lessons/lesson_cont/verbs/inversion.html


grammaticality - Should I use "important" or "importantly" in the introductory phase of a sentence?


Should I use important or importantly in the introductory clause of the second sentence:



Appellant's argument is premature. More important, it lacks merit.



Google NGram shows a significant preference for "more important." Recently, however, it appears the democracy of usage has swung slightly in favor of "more importantly."


I prefer the former, but I am more concerned about learning which one is grammatically proper, and the particular rules that control the analysis. Can someone walk me through it?




word usage - When to use 'one' instead of indefinite article 'a'?



I'm confused about using the word one or a at times.



I was walking down the street and saw one person climbing the building.
I was walking down the street and saw a person climbing the building.



Which one is correct? Why?




phrase meaning - What does "I have got some time on my hands" mean?




My shift at work's kinda long, so I've got some time on my hands to, you know...whatever. Think, I guess.



What does "I have got some time on my hands" mean in the above quote?



Answer





  1. Having time on your hands usually implies you're bored - and actually looking for something to do, because you don't want to simply sit around doing nothing.





  2. To have time in hand usually implies you did have something to do, but you've completed it early. Maybe you'll just kick back, relax, and do nothing - or maybe you'll start tackling another task.




It should be clear from the above that sense #1 usually describes an unsatisfactory state of affairs (you need something to do), whereas #2 applies to a desirable state (you're available to do something extra).




By extension from sense #1 you'll often come across variants of...



Time weighed on his hands (he was bored, having nothing to do).



word usage - Can a ship or a car be a "he"?


In English, especially in a poetic description, ships and cars are referred to as "she".


Maybe their owners compare their beauty and elegance with those of women, but what if a female owner wanted to describe her yacht or car?


Would she also say, "She is a real beauty", or it might be "he" then?


Does the choice of a pronoun depend on whom she is giving the description of it to — a man or a woman?


What about a man-o’-war or a merchantman? Being ships, are they also referred as "she"?


P.S. There's a post on the use of "she" in reference to ships, but there seems to be no answer to my question there.


P.P.S. My question wasn't pulled out of a thin air. I came across a book by a prominent Russian linguist, G.Veichman, written in 1990, (Novelties in The English Grammar is my translation of the title), where I read that the rule of personification of vehicles may be added regarding a female owner talking about her car using the preposition "he". Period. No further explanation or reference examples.



Answer




There is no law that one cannot use masculine or gender neutral pronouns to refer to ships and other things that are normally referred to by feminine pronouns.


For instance, if a female owner wanted to name her yacht a man's name, paint that name on her yacht and refer to this yacht as he, there is no language police that can stop her.


Besides that, Is your vehicle a 'he' or a 'she'? quotes a survey that says



Nearly half of drivers think their vehicle has a gender, with 60 percent of vehicles viewed as female and 40 percent viewed as male. Of those with a gender, vehicles in Southern states are more likely to be female, while autos in the Midwest are more likely to be male [my emphasis].



There is also a current commercial on TV for an insurance company, and it starts off with a woman who has named her car 'Brad' (a male's name)...


At any rate, this question is not, to me, about what the convention is, but whether or not it is possible in English. And of course it's possible. And I see no reason to discourage a woman, or man, from doing so.


Hurricanes used to always be given female names. Now during each hurricane season, the names alter between male and female. So it's not like there is absolutely no room to maneuver regarding this subject: for whatever the reason may be, it's possible to incorporate change.


Wednesday, July 22, 2015

phrase meaning - What does "the C++ track" mean?



From the book Thinking in Java:



I found out, by creating and chairing the C++ track at the Software Development Conference for a number of years (and later creating and chairing the Java track), that I and other speakers tended to give the typical audience too many topics too quickly.



What does that actually mean? I tried to look up other definitions of the word track in dictionaries, but to no avail. I couldn't find anything that could even remotely fit the particular usage the author uses here.



Answer



In the context of a conference, a track is a series of related presentations all focused on the same topic.


For example, if you look at the conference planner for OOPSLA 2014, you'll see that they had four presentations on Program Analysis and the Web in one room, while there were four more talks on Runtime Systems in another room.


enter image description here


So, two conference attendees might be having lunch together, and say:




"Did you see that talk on garbage collection?"
"No, I was in the other track."



meaning that she was listening to the talk in the other room.


Evidently, the author of the book started the C++ track at the Software Development Conference, and later did the same thing with the Java track. The chair of a track often has the responsibility of introducing each speaker during that session, and making sure speakers don't go past their allotted time.




Incidentally, a corollary of Murphy's Law says: At a conference, the two talks you most want to attend will be held at the same time.


terrain - 2d Procedural universe generation


I want to create a flat universe, where at first the whole universe is blank.


That would be represented by a parallax scrolling nebula background image.


What I want to do is represent the planets as disc shaped objects in the universe. They can be of various sizes.


The inside of the discs will consist of a landmass, then outside that will be a body of water and after that air.


what would be the best way to go about creating those tiles procedurally as for example the air would consist of various gases and the land of various minerals and resources.


My first thought is to create texture images and then stamp out the circles out of those textures, but problem is that those textures would have to wrap horizontal and vertically. Is there a fully procedural way of doing this?



Answer




Procedural textures, particularly noise-based ones, can be made to tile. See this thread at GDNet for some discussion, as well as this journal entry. There's also this link, which sounds interesting although I can't speak for its veracity.


As for procedurally generating the world, there's this article written by the guy developing Infinity. His system is 3D but you could probably adapt the techniques easily enough.


There's a whole wiki on procedural content generation, too.


algorithm - How do I avoid "too" lucky / unlucky streaks in random number generation?


I'm currently dealing with a multiplayer combat system where the damage dealt by the players is always multiplied by a random factor between 0.8 and 1.2.


In theory, a truly random RNG may eventually yield the same number many times (see the Tetris dilemma). This could result in a match where player is always making very high damage while the other always makes very low damage.



What can I do to make sure this doesn't happen? Are some RNGs better than others at avoiding repetition?




Tuesday, July 21, 2015

entity system - Input handling in component based design


I know this question has been asked several times, but I'm still not sure how to implement input handling in a component based engine.


The component based design I used was based on T=Machine's blog series and on Artemis in which Entities are just ids.


There are three main ideas I have in implementing input handling:




  1. The input component will hold events it's interested. The input system will translate key and mouse events to game events and loop through the entities with the input component and if they are interested in the event an appropriate action will be taken by the input system. This action would be hard coded to the input system.

  2. No input component. You would register entities with specific events to the input system. The input system would then send messages (with the entity id and event type) to other systems so that these can take the appropriate action. Or as in the first case, the actions would be hard-coded to the input system.

  3. Similar to the first method, but instead of hard coding the action to the input system, the component would contain a map of events to functions (i.e. std::map) which would be called by the input system. This has the added effect of being able to couple the same event to different actions.


Would you recommend any of the above methods or do you have any suggestions that would help me implement a flexible input handling system? Also, I'm not yet familiar with multi-threading but any suggestions that would make the implementation thread-friendly are also welcome.


Note: One added requirement I'd like the implementation to fulfill is that I'd be able to pass the same input to many entities, like for example moving a camera entity and the player at the same time.



Answer



I think that, just like my answer regarding materials in a component system, you're running in to a problem where you're trying to shove everything into a "component." You don't need to do this and in doing so you're probably creating a really cumbersome interface by trying to fit a bunch of square pegs into round holes.


It sounds like you already have a system that handles the acquisition of input from the player. I'd opt for an approach that then translates that input into actions ("move forward," or "move backwards") or events and dispatches those to interested parties. In the past, I've disallowed components from registering themselves for these events, preferring an approach where the higher-level system explicitly selected the "controlled entity." But it could work that other way if you prefer, especially if you're going to re-use the same messages for taking actions that were not stimulated directly by input.



I wouldn't necessarily suggest implementing camera-following behavior by having both the camera entity and the player entity respond to the "move forward" (et cetera) message, though. This creates an extremely rigid connection between the two objects that will likely not feel good to the player, and it also makes it a bit trickier to handle things like having the camera orbit the player when the player rotates left or right: you have an entity responding to "rotate left" by assuming it is slaved to the player, but that means it can't correctly respond if it were ever unslaved... unless you introduce that concept as some state you can check. And if you're going to do that, you may as well implement a proper system for slaving two physical objects together, complete with appropriate elasticity tweakables and so on.


Regarding multi-threading, I don't really see a need to employ it here as it would likely cause more complication than it's worth, and you're dealing with an inherently serial problem so you'd just need to involve a lot of thread synchronization primitives.


word request - What would be the equivalent of "Grundlagen" from German in a scientific paper?


I am required to make the first chapter of my scientific paper be called "Einleitung" in German, that would be "Introduction" in English, but the second one should be "Grundlagen", which I can't find a good translation for.


There are a couple of translations on dict.cc (http://www.dict.cc/?s=grundlagen), but none really fits in my opinion.


While the introduction contains meta-information about the paper itself (aims, procedures, structure, etc.), the chapter with the title that I am looking for is the first real chapter of the paper, containing the basics about the topic, with definitions of words and a general start into the topic.


While I used "basics" in the paragraph above, which actually describes what I am looking for quite well, I find that word to sound too casual and non-scientific. The other suggestions by dict.cc, for example principles don't fit nicely, since the chapter contains more than just that.



But I am sure an English paper contains chapters like these with standard titles that are used as a standard. What would be the name of the chapter I am describing?



Answer



I found this PDF from the University of North Carolina Wilmington titled Organization of a Traditional Academic Paper that I think is a very helpful description of each of the traditional sections of a paper along with a section title or in some cases, a list of possible section titles.


It suggests that the section after the introduction could be "Background", "History", "Review-of-Literature", or "Methodology" and describes that section as "[...] this section would provide the necessary background or history for understanding the discussion to come [...] this section justifies the research done by either showing that the writer has done their homework and/or has a clear understanding of research methods."


I think that "Background" would be the best choice from that list based on what you've explained about your second section, although I also like StoneyB's suggestion of "Fundamentals".


phrase usage - What does "live local" mean?



I found it in a list of pet peeves of somebody in the internet through searching that what pet peeves mean. Now, I know what pet peeve is but there is another problem with "Live local!" which I want to know the exact meaning,usage and formality/informality rate.


Apparently, it means go and experience new things same locals from that area are doing it but I am not sure about this usage and also want to know the other usages if there is any more.


For example: Let's Live Local


Can I use it in my conversations with a native to encourage her/him in protecting local life in her/his hometown? Is this a common phrase or only a kind of esoteric phrase and inappropriate in the modern English?



Answer



Jim has hit the nail on the head; Live Local is a movement designed to encourage folks to support their local economies and businesses.


I'd only like to add that the Live Local movement is largely in response to expansion and proliferation of franchises across North America. Sometimes I've marveled how, just before I get on the highway, the last things I see in my hometown are a Best Buy, a McDonald's, a Lowe's, an Olive Garden, and a Target. I drive 300 miles and across two state lines, and the first thing I see as I get off the highway are a Best Buy, a McDonald's, a Lowe's, an Olive Garden, and a Target. There's even a term in the Urban Dictionary to describe this phenomenon – generica (which is a neologism of generic America):



generica
What most of America, particularly Middle America, has become characterized by the ubiquitous Wal-Mart, TGI Fridays, Applebees, Chili's, Gap, J Crew, Best Buy, Target, Olive Garden, PetCo, McDonalds, Banana Republic, Border's, Costco, Home Depot, Nordstrom, Circuit City, KFC, Sports Authority, Starbucks.. and on and on it goes.... until every city/town/suburb starts to blend in and look like one big flavorless mall... where all the people, genericans, mindless zombies, consume and consume and consume.... slaves to corporations and keeping up with the Jones'...




As we travel through and across the country, it's becoming harder and harder to find mom-and-pop businesses among the restaurants and shops of a particular region. Live Local, then, is an exhortation to actively support such businesses, lest the last vestiges of local color die out from a community's restaurants, inns, and shops. It almost requires a certain grass-roots mindset to keep these businesses viable, because it's difficult for them to compete against the larger, more prominent chain outfits, which are usually much easier to locate and recognize.



Can I use it (live local) in my conversations with a native to encourage her/him in protecting local life in her/his hometown?



If "protecting local life" means "keeping local businesses healthy", then you could use that expression. However, it's not a particularly common idiom, and there are other ways you could express the same sentiment that might be more understandable. Perhaps the most common way to convey that thought is the phrase "Buy Local", but there are many catchy ways one could encourage the support of hometown businesses. I found these graphics by doing a Google image search on "support local businesses":


Buy Local marketing logos


The one in the bottom right corner is a particularly clever pun. The expression "mind your own business" is usually an admonition to not meddle in the affairs of others. However, in this context, the word mind is being used in the sense of take care of (that is, the meaning of the word shifts from Definition #20 to Definition #22, as listed in this dictionary entry). While the pun is clever as part of an ad campaign, I would not use it in day-to-day conversation, lest it be misunderstood.


Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...