Thursday, January 31, 2019

present perfect - “I have been *verb*ing...”: once or many times?


There is someone who drives me crazy using the past perfect to indicate an action that was performed only once, and I understand that it indicates an action performed more than once. For example:



I have been calling you.


I have been trying to reach you.




I understand it means the person has called several times, or tried to reach the other person several times. Could you please tell me the exact meaning of "I have been..." or indicate when we should use it?




negation - verb+"to not"+infinitive OR verb+"not to"+infinitive


I believe the negative of a sentence, in which an infinitive is used, is made in two different ways.


For example, "I know what to say." can be negated as follows;



  1. I know what not to say.

  2. I don’t know what to say.


However, I often come across the swapped version of "not to" as follows;




  1. I know what to not say.


Other examples follow;




  • Tom had enough sense to not go out by himself after dark.

  • I want you to not go to Boston with Tom.

  • Why did you decide to not go to Boston with Tom?




Grammarly finds the third way to be fine.


Google Books Ngram Viewer prefers not to over to not in general.


I need to know if the third way of negating an infinitive-sentence is grammatical. Please, explain!



Answer



First of all "I don't know what to say" and "I know what not to say" mean different things. "I don't know what to say" means "It's not true that I know what to say". "I know what to say" means "There are things that I know I shouldn't say".


As to your question, "to not say" is known as "split infinitive". The "to say" phrase is called the "full infinitive", and putting words between "to" and "say" is known as "splitting the infinitive. There are some who say that infinitives "shouldn't" be split. However, this rule based more on an attachment to Latin (in which infinitives are a single word, and thus it is impossible to split an infinitive), rather than actual grammar. There is nothing ungrammatical about split infinitive, and they are arguably more logical.


Wednesday, January 30, 2019

grammar - Question-like structure (word order) in non-question sentences


Occasionally I see constructs like this in English sentences:





  1. Not only is this true in this case, but ...



What puzzles me is the "is this" part of it. The sentence is not a question, yet it seems to have a question-like order. Isn't this correct/preferred:




  1. Not only this is true in this case, but ...




Are there other cases where non-question sentences contain question-like parts (so to speak)?




passive voice - "The attack happened" or "The attack was happened"



The attack happened on the Lisburn Road shortly after 23:00 GMT on Friday night, police said. BBC




Shouldn't the writer say: "The attack was happened" or "The attack has been happened"? Shouldn't he use the passive voice? I assume that because the attack happened by someone.



Answer



The comments are correct; this statement is correct as is and should not be in the passive voice.


We only use the passive for transitive verbs, ones with an object, where you can say "X verbs Y". For example



The cat eats the fish.
The fish is eaten by the cat.



But it doesn't work for intransitive verbs like happen or fall or smile, because they don't have objects:




The boy smiled. (no object)
Incorrect: The boy was smiled



"The boy was smiled" would mean that there was something else that performed the action of smiling on the boy, but the verb to smile doesn't work that way.


Likewise, to happen is intransitive:



The event happened. (no object)
Incorrect: The event was happened.



Happen simply means "to occur or to take place", and the event that happens is the subject, not the object.



Reference:
Intransitive Verbs (Never Passive)


Application of Game trees in AI


My specific area of interest is designing the AI of real-time multiplayer games, for example, RTS games. Moves by players happen simultaneously, so I was wondering whether or not it would be modeled with a sequential (extensive form) game tree or something else. I don't know if this is even the correct approach at all, and if some other algorithms are more applicable.


How much of Artificial Intelligence design is based off of game trees or extensive-form games, and are there any suggested textbooks which thoroughly cover the subject game tree application to AI or AI of RTS games?



Answer



I will give this Question a partial try.


I guess that Game Trees are the same as decision trees and the answer to the question is, sure, why not.


But this alone will not solve the riddle for a RTS AI, you will need a combination of ai techniques to get the task done.


Some techniques you may want to use/combine:


(warning, the most of this is pure clasical ai stuff)



Control



  • decision trees

  • behaviour trees

  • statemachines

  • fuzzy logic

  • recursive depth or Breadth-first search for planing tasks

  • neural networks for more fuzzy stuff

  • maybe even genetic algorithms/genetic programming for more fancy ai / emergent behaviour

  • maybe even this Designing Emergent AI



to name only a few.


Navigation



  • Dijkstra

  • A-star


Planing


I have absolutly no idea about this field because i never programmed a rts ai, but take a look in the book i linked below.





Books


A very good book for Game AI Programming is Artificial Intelligence for Games.


Tuesday, January 29, 2019

When would I use "scripts" or "scripting" in a game, as opposed to the core language?


The terms scripts and scripting appear to be used interchangeably on the Game Development Stack Exchange, but other than reading questions about a scripting language choice, I don't understand the relationship between scripts and scripting, and the core language. What does a script typically do, when would it be used, and are scripts in some contexts (as defined by game programmers) different than a scripting language?



Answer



Scripts are written for a scripting language. People can use the words in slang sentences to get the muddling that you are referring to but ask anyone for the definitions of Script, Scripting and Scripting Language and you will get something like: Scripting is the act of writing Scripts using a Scripting Language.



When you embed a scripting language into a game engine, or core language as you are referring to, you are exposing not only the objects within the game engine but also allowing logic to be written for the game engine. One other thing of note is that this turns your game into kind of a virtual machine, as scripting languages seldom compile down to machine language and are instead put into a form of byte code and interpreted at run time by your game engine.


This has some huge benefits to the development team, a few of which you can find listed next:



  • Scripting languages are usually memory managed so you do not have to worry about allocations

  • They are usually a loosely typed language that removes the need to make sure you are using the variable type for what you are doing, just make a variable and go with it.

  • The languages themselves are often very simplistic while delivering quite a bit of control to people who are not programmers

  • Altering scripts does not require the core engine to be recompiled.

  • Scripting vs Coding often reduces the time required for very iterative tuning of game logic.

  • Depending on design and language, you can often reload a script while the game is running for even easier tuning/testing.



I am sure the list can keep going on and on I am sure, especially when you get into specialized game types and how scripting can help define group formation rules for moving groups of units in an RTS or how you can create a UI's logic in a scripting language to provide an extensible UI to your end-users and the like.


meaning - What's the difference between "citizenship" and "nationality"?


What's the difference between "citizenship" and "nationality"?


Webster says on "nationality":




the fact or status of being a member or citizen of a particular nation



and on "citizenship":



the fact or status of being a citizen of a particular place



It looks like nationality is more related to your ethnicity, while citizenship is more related to a place of living. Which means that citizenship should be more "flexible" than nationality (as it's much easier to change your place of living rather than your ethnicity).


That's how I thought until I came across a Wiki article today on Steven Seagal stating that he has three nationalities:


enter image description here


So, now it looks to be like I was wrong. But then I really don't see the difference now. Are they synonyms?





Monday, January 28, 2019

vocabulary - What do native speakers think of word roots?


As the number of English vocabularies required by my English literature teacher is increasing, I am now confronting a great problem memorizing them in a short time. Simple words are okay to me, but it's especially difficult when I come across words with crazy suffixes and prefixes or with tricky interchangeable prefixes (such as proclaim, declaim, acclaim, reclaim, disclaim and exclaim).


Since I'm a clever guy (or I just made up :D), I found out a post somewhere written by a Chinese, which was upvoted to the top of the "English Learning" category, and therefore I read it carefully. This post greatly recommends folks to make use of word roots. The writer argues that it can help you spell it correctly, remember the accurate definition, and deal with multiple evolved meanings of a word.


Personally, most of my English vocabularies are remembered by rote memorization, which is, as I have experienced it in person, super inefficient. Since I am convinced by this post, I would like to change my out-of-date method into this new one and give it a shot. However, I would like to know more before I get started.


Thus, would you like to give me your perspective to this method and show off your personal way of English word memorization?


By the way, Word Power Made Easy by Norman Lewis was mentioned in that guy's post.





After reading such a number of reasonable, detailed and helpful answers, I ruminated and decided not to second (in fact, I did :D) any answer here to avoid leaving future confusion to visitors to this post. Every answer here is super delicious, and thus it's hard to judge a BEST one. And, I believe, everyone have his/her own ways of vocabularies acquisition so it depends. Am I right? o(^v^)o


At last, sincere thanks to everyone who generously answered this post and gave me their interesting perspectives. ;D




infinitives - "Do you like to get up early?"




Do you like getting up early? (1)


Do you like to get up early? (2)


(Essential Grammar in Use)



What is the difference between the two?


I guess, in (1) I ask you whether you’re currently enjoying of getting up early. But (2) is rather difficult. It can present asking either about your futural / intentional getting up or repetition of enjoying (CGEL says to-infinitval has the meaning of ‘repetition’ but I don’t know why –– I want to get some explanation about this in CGEL, p1241).



Answer



I would say there's no significant semantic difference between OP's exact two examples, but in certain specific contexts one or the other would be more "idiomatic".


1.) If you were sitting in a hotel having an early "working breakfast", you'd be more likely to use #1 (with the meaning *"Did you like getting up early this morning?").



2.) The hotel manager wanting to know if his guest would like an early or a late breakfast the next day would be more likely to use #2 (with the meaning *"Will it suit you to get up early tomorrow morning?").


Thus, although I don't see any distinction based on "repetition", there is a distinction based on the fact that the gerund/present continuous ("Do you like doing this?") is a better choice when the person you're asking is currently doing whatever it is.




The difference becomes clearer if we change the activity from getting up early to being here...



3: Do you like being here? (normal English)
4: ?Do you like to be here? (unlikely to be said by native speakers)



Where #4 is unlikely because (as explained above) we normally use the first form when the activity being asked about is currently being performed (and usually we'd only be asking such a question if the person was in fact "here" at the time). But contrast that pair with...




5: Do you like being at home on Thanksgiving?
6: Do you like to be at home on Thanksgiving?



In this case, #5 is more likely if you're asking someone who's currently at home, on Thanksgiving Day (or very close to it). Effectively, you're asking if the person likes their current circumstances.


Using Simple present tense for future event / Plan / Schedule


Can we use simple present tense to communicate our future plans? Actually recently I read some strange sentences like,


a) The plane arrives at 18.00 tomorrow.


b) She has a yoga class tomorrow morning.



c) Next Thursday at 14.00 there is an English exam.


So with reference to my above examples. Can I use simple present tense to tell my next day plans? Or Shall I use will in sentence? Or both will be ok?


E.g


Que: What are your plans tomorrow?


Ans a): Tomorrow early morning first I go to Morning walk and then I have a meeting at 10.00 with XYZ.


Or Simply I use will in my sentence.


Ans b): Tomorrow early morning first I will go to Morning walk and then I have a meeting at 10.00 with XYZ.



Answer



Yes you can. Generally the simple present isn't used to express what is happening right now. Instead its purpose is stating general truth about things in the present. But it can also be used to describe scheduled events in the future.


Your example: "The plane arrives at 18:00 tomorrow." would fall into that category. It describes the planes arrival at a time in the future, therefore is considered a planned/scheduled event. This applies to the other examples you listed.



Edit:


I have to add that you cannot express actions in this manner, which you plan to do in the future, even if they are 'planned'. For example this -



Tomorrow morning I go for a walk.



-would be incorrect, yet:



Every morning I go for a walk.



wouldn't, since this is simply a description of the routine and could be considered a general truth.



word usage - This or That person



Today I heard a speaker use the phrase "this person", referring to the subject-person of the story they were telling, and I heard it as (that person). Between the words “this” or “that” in context with the phrase and story-tense, which should you use.



Answer



The difference between "this" and "that" is that "that" is further/far away from "this". So, let's say you're reading a story, from a book, and you have that book placed in front of you, and you're speaking about a person mentioned in the story of that book, it would better to say "this person", whenever you mention a persona of that story. "That", as in "that person", is used when referring to a person not close to you, or close to your perspective.


Also, the subject-person of the story is often addressed with "this", instead of "that".


What I mean with that is, assume there's another persona in that story who's not the person you mention the most, it would be better to use "that". I'll give you an example:


"So, this person (subject or person talked about frequently) went to the market, and met a strange person, who looked really scary. That person (the strange person) was not known to the inhabitants of that city."


So, that's what I mean with perspective. So, which one should you choose? That depends on the context, as shown above.


software engineering - Where does the game code fit into the engine?


I was wondering if somebody could tell me how the game and the game engine fit into game development. What I specifically mean is, the game engine does not actually contain a game. Do game developers build an engine, then create a new class that inherits from the engine, which becomes the game?


For example,


class ShooterGame : public Engine
{

};

I'm not sure about where the game code fits into the engine.



Answer



Don't get caught up on the concept of a "game engine". While it is true that game studios often have some sort of game engine which they create in order to speed the process of producing games, many independent developers get hung up on trying to create a game engine that they never actually make something that works.


A game engine can be whatever you want it to be. If you find enough in common between your games that you can subclass an Engine class like your example, that's fine. If an "engine" is really just a small library of functions which you've found to be handy in past games you've developed, that's great too. Whatever it means to you, the concept of an "engine" is just reusable code to help you make more games.


If you're trying to make a game though, don't focus on making an engine. Make a game. Once the game is done and you're ready to make your second one, start making the second one, and you'll find bits that you already made in your first game; then you can extract those bits into a library or engine, to be shared between the two games. That's how an engine should be made. It's not typically something that you decide to write before making a game, because you'll end up with tons of code which is untested and you are essentially writing things before you know you need them (therefore you might not even need them). This is like premature optimization, but worse.


So to directly answer your question, basically a game engine is a reusable "thing" (library, tool, framework) which a game studio uses to aid in quickly producing games, and they typically create it with specific games in mind or after having created several games, extracting out the similar bits and moulding them into an engine which they know can be used in future games. It should almost never be created without either retrospect (two or more games already created) or EXTENSIVE planning.


path finding - Pathfinding with car steering


Is there pathfinding algorithm which takes car steering into account?


I have large space where user can place cars (trucks actually) and other blocker objects. Objects can be placed vertically or horizontally oriented and have different sizes (may be 3x6 or 2x4 or other size). User needs to be able to select new location for any car - then I need to calculate how can that car move to selected location.


I have pathfinding working, and I can find paths with different size but only for square objects.


Update:


Pathfinding need to give only path that is possible with that type of car. For example on empty map with only one car, if user selects new location right next to its current location, car can't strafe or turn in place it has to either reverse and steer or do U turn or something. Also it must ensure that car orientation at end is what user requested.




rendering - CPU - GPU memory data flow



I'm a newbie graphics programmer and I've been wondering recently - how does model data (meshes and materials) flow from application (CPU memory) to graphics card (GPU memory?)? Say I have a static model (e.g. a building) that I load and setup once and don't change throughout the app lifespan.



  • Does its data get sent to GPU memory only once and sit there forever?

  • When the model gets actually rendered each frame do GPU processors have to fetch its data each time from GPU memory? What I mean is - if I had 2 models rendered multiple times each - would it matter if I first rendered the first one multiple times and then the second one multiple times or if I rendered the first one just once, the second one just once and kept interleaving it like that? I could call this question "internal GPU data flow" in this sense.


  • Obviously graphics cards have limited RAM - when it can't hold all the model data necessary for rendering 1 frame I guess it keeps fetching (some of) it from CPU RAM each frame, is that correct?


I know there's a lot of books and stuff about this on the internet but maybe you have some quick general guidelines as to how to manage this data flow (when to send what and how much, when and how to render)?


Edit: I forgot to make one distinction: there's sending the data to the GPU and there's setting/binding the buffers as current. Does the latter cause any data flow?


Edit2: After reading Raxvan's post I'd like to distinct a few actions:



  • buffer creation with initialisation (as he said I can store the data in either CPU ram or GPU one)

  • buffer data update (which I believe is straightforward when the data is kept in CPU ram and requires fetching from GPU to CPU ram (and then back) when it's kept in GPU ram)

  • binding the buffer as active (is it just a way to tell the API that I want this buffer to be rendered in the next draw call and it doesn't do anything by itself?)

  • API draw call (here I'd like to hear from you what actually happens there)





Sunday, January 27, 2019

ogre - Spherical / Relative Gravity


I'm working on an Ogre3D + Bullet project that involves planets in a solar system. For all intents and purposes, I'm looking to give each planet it's own gravity sphere.


So far, all I've found are ways to change the "general" gravity Vector3 for the entire scene, but that's it.


While I'd hope to add air friction and other physics later on, for now I just want "prioritized" gravity, like in this video.


You'll note that the floor in the video has gravity, but when he jumps near the sphere, he is attracted to it sphere instead. That's exactly what I'm going for.


The video is very low quality and doesn't explain how any of it is working, besides the fact that it uses Ogre3D and Bullet.


The planets themselves are on pre-generated paths around the Sun - I'm not looking to apply "real" physics to the solar system itself; just for the planets themselves and eventually "generated gravity" for ships in space.



Answer



Well I don't think that Bullet physics support multiple attractors out of the box, even though in bullet you can set the gravity per object, Bullet still assumes the objects are being simulated under a global gravity value set for the entire scene, in other words it assumes that the objects gravitational force is neglected in comparison to the planet/surface they dwell on, which is clearly not the case of real planets.



The Solution


Never the less, I can recommend you set the global gravity to 0.0 and simulate planets' gravity using Newton's law of universal gravitation based on each planet's mass, now when any planet is within the other planets gravitational distance you can calculate the force, which can be done using a btSphereShape collider.


Newton's law of universal gravitation equation


After you calculate the gravitational force for each planet you can apply it's gravity on other planets using btRigidBody::applyForce.


The problem though...


Well if you ever heard of the three-body problem you will know that calculating gravitational force between three planets is particularly unsolvable (or hard to solve?) , quoting from Wikipedia:



In its traditional sense, the three-body problem is the problem of taking an initial set of data that specifies the positions, masses and velocities of three bodies for some particular point in time and then determining the motions of the three bodies, in accordance with the laws of classical mechanics (Newton's laws of motion and of universal gravitation).



This will make you approximate the actual motion of the planets rather than calculate the exact one. By reducing the problem to one static body, and calculating the motion of the other body. Then you will find that the motion of a body under gravity is an ellipse.



But that's not a huge problem, since you will get a fine approximation, quoting from this article



But even with just mechanical pencil and paper there are cheats. For example, although there are more than three bodies in the solar system (the Sun, eight planets, dozens of moons, and millions of asteroids and comets), almost everything behaves, roughly, as though it were in a two body system. Basically, this is due to the pronounced size differences between things. As far as each planet is concerned, the only important body in the rest of the universe is the Sun. To get some idea of why; the Sun pulls on the Earth about 200 times harder than the Moon, and about 20,000 times harder than Jupiter. Nothing else even deserves a mention. So, if you want to calculate the orbits of all the planets, a “2-body approximation” will get you more than 99% of the way to the right answer.



2d - Vehicle physics with skid


How would I go about creating vehicle physics for a car that can loose traction? I want it to seem like the driver has a flat foot, so when you press the gas, they cars driving (rear) wheels loose traction, and makes it somewhat hard to control. I would also like to be able to do doughnuts and "drift" around corners.


I would also need to know how much "skid" is happening, so I can add a proportional amount of smoke and tire marks.


Assume a 2d, top-down style car game.


Thanks



Answer




This is a very simplified version but would be fine for most arcade type games. You need the following properties:


positionX, positionY - where the car is
velocityX, velocityY - speed on each axis
drag - how fast the car slows down
angle - the rotation of the car, in radians
angularVelocity - speed the car is spinning, in radians
angularDrag - how fast the car stops spinning
power - how fast car can accelerate
turnSpeed - how fast to turn


every frame:


positionX += velocityX
positionY += velocityY
velocityX *= drag
velocityY *= drag
angle += angularVelocity
angularVelocity *= angularDrag

to accelerate


velocityX += sin(angle) * power;

velocityY += cos(angle) * power;

to steer left


angularVelocity -= turnSpeed;

to steer right


angularVelocity += turnSpeed;

To get good drift, set drag and angularDrag to very close to 1, e.g. 0.9


Saturday, January 26, 2019

Books for designing virtual economy



I am wondering if there are any books on designing virtual economies.



I have encountered some books which have a few lines or paragraphs written about virtual economies, but they mainly highlight how difficult it is to design and control a virtual economy; they don't give any useful advice on how to design a virtual economy.



Answer



I've been doing a lot of research on this topic in the past several months and have gathered quite a bit of resources that you might find useful. Although I haven't come across an actual book about it, these articles are pretty long (and comes in several parts) so they are pretty close :)


Take a look at these to get you started:


Virtual Economic Theory: How MMOs Really Work - Simon Ludgate


The F-Words of MMORPGs: Fairness - Simon Ludgate


The F-Words Of MMOs: Faucets - Simon Ludgate


Sell Your Money! - Simon Ludgate


Designing For Free Takes More Than 'Just' Game Design - Soren Johnson


MMORPG: Luck or Grind? - Simon Ludgate



MMOs: Just a Matter of Time? - Simon Ludgate


Tips on Developing an MMO Economy, Part I - Radu Privantu


Edit: Removed a dead link.


c++ - Defining and selecting an area from an image



I want to create a game, where the world is loaded from an image file, much like Paradox Interactive does it for their games. If I have this image:



Then the red, green, blue, cyan, magenta, white, black and grey should be different provinces. I know how to loop through them, and check if it's a new province, the problem is that I don't know how to define the region of the province for selection: I don't know how I can load in data, to make sure you can click anywhere on that province, and make sure it gets selected.




grammaticality - Analysing the "kind(s) of problem(s) are [ones]/[to be]" construction



A. These kinds of problem are to be avoided.


B. These kind of problems are to be avoided.




Are both A and B grammatical? If not, why not? If so, after having noticed the parallelism between A and C, and between B and D, could we say that C and D are "standard" English, too?



C. These kinds of problem are ones to avoid.


D. These kind of problems are ones to avoid.





Is it possible create an HTML5 mobile game without the user having internet connection?


I trying to make a app for the Play Store and App Store. My app will be 2D, but will have 3D effects. Is it possible to program it in HTML5 without the user having internet connection? Also, are there any good tutorials on HTML5? Thank you in advance.



Answer



In theory with HTML5 you get what you need to code what you want to do, but you can't create an app with just a pure HTML5 codebase, you need to interface your code with native code in a way or another. The real solution that can fit your case is using an HTML5 framework like phonegap. It's the easiest and shortest way in your case.


word choice - "The opposite of" vs. "opposite to"



  1. Small is the opposite of big.

  2. Small is opposite to big.


Is the second statement grammatical? It sounds okay to me, but only if I leave out the the.



Answer



Not in the way you are using it.


"Small is the opposite of big" is saying that the two words mean opposing things. This is okay, because "of" indicates a difference in essence.



"Small is opposite to big", however, indicates an opposition in physical position. It suggests that "X" is in the opposite position compared to "Y". The "to" in this phrase indicates a physical opposition, where the words "small" and "big" do not have physical entities to represent them, and it would only make sense if you were putting the words physically in a list, and saying they were opposite to each other on that list.


sentence construction - There + verb , is it grammatical?



There didn't exist computers.


Will there happen similar events in the future?



Are these sentences grammatical or is my mind making stuff up? I haven't been able to find much on the net.




state - Android: how do I switch between game scenes in a game? Any tutorials?


I am trying to create a simple game using the Android SDK without using AndEngine (or any other game engine). I have plenty of experience designing games from the past, but I'm having lots of trouble trying to use the Android SDK to make my game. By far my biggest hurdle right now is switching between views. That is, for example, going from the menu to the first level, etc.


I am using a traditional model I learned (I think it's called a scene stack or something?) in which you push the current scene onto a stack and the game's main loop runs the top item of the stack. This model seems non-trivial to implement in the Android SDK, mostly because Android seems to be picky about which thread instantiates which view. My issue is that I want the first level to show up when you press a button on the main menu, but when I instantiate the first level (the level class extends SurfaceView and implements SurfaceHolder.Callback) I get a runtime error complaining that the thread that runs the main menu can't instantiate this class. Something about calling Looper.prepare(). I figured at this point I was probably doing things wrong.


I'm not sure how to specifically phrase my issue into a question, so maybe I should leave it as either


1) Does anybody know a good way (or the 'proper' way) to switch between scenes in an Android game?


or


2) Are there any tutorials out there which show how to create a game that doesn't take place entirely in one scene? (I have googled for a while to no avail... maybe someone else knows of one?)


Thanks!





Friday, January 25, 2019

grammar - "My availability for the next two weeks (is/are) as follows"


Which is correct?



My availability for the next two weeks are as follows



OR




My availability for the next two weeks is as follows



I'm confused because I don't know if I should focus on the word "availability" which is singular or "two weeks" which is plural.




grammar - There are vs are there



Nowhere in the United States but in New Jersey ______ so many people per square mile.




  • a) there

  • b) there are

  • c) there is


  • d) are there


The correct one is d.


When I use are there?
Why is there are not correct, is it not about existence?


Can anyone here explain this to me?




python - Locking the frame rate in pygame?


I am having trouble setting up the frame rate in my first game. I know that I can set it up with


clock = pygame.time.Clock()

clock.tick(60)

but this is not producing very desirable results. If I move a character 1 pixel per frame, it will move smoothly but jitter about once a second. If I print(clock.get_fps()) it tells me that my frame rate is about 59.8. Since it never hits 60, it never syncs up with my monitor's refresh rate and the annoying jittering continues.


That I know of, this is not a problem with the game's performance, since it is in a very early stage of development. If I cap the FPS at 1000 then I can get a maximum FPS of about 270.7. Is there any way I can give my game a continuous frame rate of 60?


P.S. I don't mind that my movement code is tied to FPS. I tried making it FPS-independent using this code, but this introduced some floating-point inaccuracies to my movement. It wouldn't let me set the FPS to exactly 60, either.




unity - How can I determine which Trigger is hit?


I have a GameObject. It has 3 BoxCollider2Ds:




  1. Body Collider - Not a trigger - Determines if body is hit

  2. Weapon Collider - Trigger - Determines if weapon is hit

  3. Vision Collider - Trigger - Determines what the GameObject sees


I can tell the Body Collider apart from the other colliders, because it has a different method (OnCollisionEnter2D). However, I cannot tell the Weapon Collider and Vision Collider apart. They both access the same method (OnTriggerEnter2D), and pass in the collider they are hitting. I cannot determine which one is hit.


I could put each trigger on a separate child GameObject, and send a message to the parent, but this is very slow and feels messy to me. What is the best way I can determine which trigger I am hitting?




From the Unity Docs for reference:


using UnityEngine;

using System.Collections;

public class ExampleClass : MonoBehaviour {
public bool characterInQuicksand;
void OnTriggerEnter2D(Collider2D other) {
characterInQuicksand = true;
}
}

Answer



You might have some success checking the Collider2D.IsTouching method in your OnTriggerEnter.



void OnTriggerEnter2D(Collider2D col)
{
if (weaponCollider.IsTouching(col)) { /* Weapon */ }
if (sightCollider.IsTouching(col)) { /* Sight */ }
}

IsTouching is polled against the last physics update so it should be pretty light weight.


However, if your colliders overlap, it might be best to process the triggers during OnLateUpdate or keep tabs on the touching colliders separately.


HashSet collidesWithWeapon;
void OnTriggerEnter2D(Collider2D col)

{
if (weaponCollider.IsTouching(col)
&& !collidesWithWeapon.Contains(col.GetInstanceID()))
{
collidesWithWeapon.Add(col.GetInstanceID());
// Weapon stuff
}
}

void OnTriggerExit2D(Collider2D col)

{
if (!weaponCollider.IsTouching(col)) collidesWithWeapon.Remove(col.GetInstanceID());
}

I'm pretty sure there are other curve balls along the way, but hope this helps forward. Adding the colliders to other GameObjects might help too, but I think trigger events cascade top to bottom or something similar. Can't remember what it was exactly, though... Whatever it was, I've made it a practice to check the IsTouching() if the hierarchy contains more than one collider.


unity - Unity2D - Save everything in a scene before loading another and come back to it?


So I have am into this endless runner thing where everything is generated randomly from prefabs. Okay cool! But I am currently working on a bonus collectible which takes the player to another scene. After certain time, the player must reach at exactly the same position it left from.


But that's not the problem. I have figured out a way to save and load player's and camera's position using temporary prefabs.


My problem is : When the player collects the bonus thing in main scene and goes to the bonus scene and comes back, there's a sort of gltichiness or distortion in the game view. As if, the bonus scene is frozen and other scene is overlapping and everything is being stretched. But in inspector, everything including camera is in place.


In game view, on returning, the camera seems to be starting from beginning while in inspector its exactly where its supposed to be. Not only that, there's a lot of distortion, which I am 70% sure is because the level had to load all over again and there's no possible way of game knowing which prefabs were instantiated as they all are random.


Compiling up, my question is, how can I save everything in a scene before leaving and load it all again at once so it doesn't have to go through all of it again. Is there any less-complex way? I hope I have made my ques clear. Thank you.




word usage - What is correct, "in the British Islands" or "on the British Islands"?


What is correct, "in the British Islands" or "on the British Islands"? Is there a general rule?




Thursday, January 24, 2019

heightmap - How can I compute a "steepness" value for height map cells?


Here's a question related to height map generation. From a 2D height map I want to produce a second map, I guess you can call it sort of a derivative map, which shows the "steepness" of all the discrete values of the map. I plan to use it to quickly determine what kinds of objects can be placed on different locations.


In practice you would have many areas where rise/run is a fractional value, since many places do not have 45 degree angle slopes. But running through the pixels of the height map in any direction, the value differences are all integer values.


So what I planned to do in order to represent smooth slopes of varying degrees is, iterate through the pixels row by row, and find the lengths of all the distances where height does not change, and for every change in height, divide that by the length of the distance. Do the same thing column by column and then average the two results for each pixel. I do have to wonder how accurate this is in situations where a lower elevation is surrounded by two walls/plateaus since the rise/run is technically infinity, as it represents a completely vertical climb.



Is this a reasonable way for calculating steepness? I haven't found any resources on how to produce a 2D array of steepness values from height maps, just things on topographic (real-life maps) with the basic rise/run formula.



Answer



You almost have the right idea, but actually it is much simpler than you might think. The simplest way of measuring steepness is by finite differencing:


float GetSteepness(float[,] heightmap, int x, int y)
{
float height = heightmap[x, y];

// Compute the differentials by stepping over 1 in both directions.
// TODO: Ensure these are inside the heightmap before sampling.
float dx = heightmap[x + 1, y] - height;

float dy = heightmap[x, y + 1] - height;

// The "steepness" is the magnitude of the gradient vector
// For a faster but not as accurate computation, you can just use abs(dx) + abs(dy)
return sqrt(dx * dx + dy * dy);
}

This is sometimes called the "Sobel Filter." There are more complicated ways of doing it (such as a difference of gaussians filter), but finite differencing should give you a pretty good result! You will get some issues with aliasing when the height is changing very rapidly (such as at walls). You will also get issues when the resolution is too low for finite differencing to return a smooth result.


EDIT: By the way, this is what the sobel filter (bottom) looks like on a simple height map (top)


Imgur



Wednesday, January 23, 2019

vocabulary - SIT or SET yourself at the table


Would you please take a glance at the links? Would anyone possibly show me what is the difference between them?



That is, I am wondering what is the difference between these:



Sit yourself at the table
Set yourself at the table



Any help would be appreciated




Answer



I have gone through both the links and could figure out the following meaning and difference.




  1. Sit yourself at the table means - there is this table with a few chairs around it. So it only means to sit (on a chair at the table) to take some rest.




  2. Set the table phrases is used for arranging the things needed for a meal on the table. 'Do you want me to set the table?' means 'Do you want me to arrange things for the meal on the table? - So the sentence in the e-book is 'Do not set yourself at the table to sit alone' means - you should wait for the other members to join you for a meal or have your meal with them and not alone. I have no idea about the story but i think it is related to etiquettes and manners. So this explanation fits.





If you happen to go in a hotel then what expression will the waiter use among the above two. He'll say --


Sit yourself at the table. Your order will be served there.


xna - What is a good way to store tilemap data?


I'm developing a 2D platformer with some uni friends. We've based it upon the XNA Platformer Starter Kit which uses .txt files to store the tile map. While this is simple it does not give us enough control and flexibility with level design. Some examples: for multiple layers of content multiple files are required, each object is fixed onto the grid, doesn't allow for rotation of objects, limited number of characters etc. So I'm doing some research into how to store the level data and map file.


This concerns only the file system storage of the tile maps, not the data structure to be used by the game while it is running. The tile map is loaded into a 2D array, so this question is about which source to fill the array from.


Reasoning for DB: From my perspective I see less redundancy of data using a database to store the tile data. Tiles in the same x,y position with the same characteristics can be reused from level to level. It seems like it would simple enough to write a method to retrieve all the tiles that are used in a particular level from the database.


Reasoning for JSON/XML: Visually editable files, changes can be tracked via SVN a lot easier. But there is repeated content.


Do either have any drawbacks (load times, access times, memory etc) compared to the other? And what is commonly used in the industry?



Currently the file looks like this:


....................
....................
....................
....................
....................
....................
....................
.........GGG........
.........###........

....................
....GGG.......GGG...
....###.......###...
....................
.1................X.
####################

1 - Player start point, X - Level Exit, . - Empty space, # - Platform, G - Gem



Answer



So reading through your updated question, it seems you're most concerned about "redundant data" on disk, with some secondary concerns about load times and what the industry uses.



First off, why are you worried about redundant data? Even for a bloated format like XML, it would be pretty trivial to implement compression and get the size of your levels down. You're more likely to take up space with textures or sounds than your level data.


Second, a binary format is more than likely going to load faster than a text-based one that you have to parse. Doubly so if you can just drop it in memory and have your data structures just there. However, there are some downsides to that. For one, binary files are next to impossible to debug (especially for content creation people). You can't diff or version them. But they will be smaller, and load faster.


What some engines do (and what I consider an ideal situation) is implement two loading paths. For development, you use a text-based format of some kind. It really doesn't matter which specific format you use, as long as you use a library that's solid. For release, you switch to loading a binary (smaller, faster loading, possibly stripped of debug entities) version. Your tools to edit the levels spit out both. It's a lot more work than just one file format, but you can kind of get the best of both worlds.


All that being said, I think you're jumping the gun a bit.


Step one to these problems is always describe the problem you're running in to thoroughly. If you know what data you need, then you know what data you need to store. From there it's a testable optimization question.


If you have a use case to test against, then you can test a few different methods of storing/loading data to measure for whatever you consider to be important (loading time, memory usage, disk size, etc.). Without knowing any of that, it's hard to be more specific.


collision detection - Changing speed of an object


Is there a way of changing speed of an object at certain time? I want to change my speed to my initial speed after colliding with any object. I have already added bounce Physics to my colliding objects and player object with Friction set to 0. Please help.




meaning in context - What does the phrase "listen to yourself" mean?


I was discussing something on another SE site(link). The discussion with full context is,



I searched and found two recent mechanics questions which got migrated to Phys.SE, 1 and 2. Note that problem solving questions aren't allowed on Phys.SE, only conceptual questions are. So homwork questions migrated from MSE can be closed there. — user103816 yesterday


@user103816 These two aren't math questions at all... By the way, 10k users can check the list of recently migrated questions here. I count six questions migrated to Phys.SE in February. Only one of them had some amount of mathematical content, and in that case the OP requested themselves for the question to be migrated. – Najib Idrissi yesterday


@NajibIdrissi Both of them are classical mechanics questions. Classical Mechanics is a well known field of Mathematics. – user103816 yesterday


Classical Mechanics is not a field of Mathematics. – quid yesterday



"Classical Mechanics is a well known field of Mathematics." Do you even listen to yourself...? – Najib Idrissi yesterday




  • Is the phrase "listen to yourself" some idiomatic expression? Or does it literally ask me can I listen to myself. What does it mean?

  • When is it used? Does it have a negative connotation?


Now let us discuss the exact phrase, "Do you even listen to yourself...?". As I understand it is asking me do you listen to yourself with emphasis. What I am confused about is whether it says me that I do not listen to myself all the time I say something, or, just that I didn't listen to myself only when I wrote that "...well known..." sentence. E.g. consider the sentence "Do you even wash hands". To me it appears that someone is implying that I never wash hands, that is a an every-day(continuous) type action. I cannot conceive a one-time type sentence with wording "Do you even xyz".



  • Is the sentence "Do you even listen to yourself...?" a continuous type question or one-time type?

  • What does the three dots after 'yourself...' mean?


  • As a native English speaker if you put yourself in my position then how much negative that sentence would sound to you? That is what is its level of negativeness? Is it simply rude or highly humiliating?

  • Another thing that user Mar Amezani said is that 'even' gives the sentence some negative cannonation and if it is replaced by 'ever' then the sentence is okay. How is the sentence Do you even listen to yourself...? different from Do you ever listen to yourself...? Is the second version a continuous type action sentence or one-time type?




Tuesday, January 22, 2019

meaning - What does "as opposed to" mean?



Can we say that the phrase "as opposed to" means:



instead of



or




Comparing to something?



Thanks.



Answer



"As opposed to" is generally comparing two things that are, at least, somewhat related. For example, if I were to say, "Karen likes blueberry pie, as opposed to Kenny, who likes cherry pie." I would use "As opposed to," instead of "instead of," or "comparing to something," because the first phrase, "Instead of," is used when there are (usually) two things being compared, but the speaker is choosing one of those two things to pick. For example: "I read the blue book instead of going to the park." Also, when using the phrase, "instead of" the two things being talked about don't necessarily need to be related, but they can. The second phrase, "Comparing to something," doesn't really have an example of use in a sentence that I personally can think of at the moment, but I think that there are examples of this being used in a sentence, although I hear it rarely.


I hope this helps!


prepositions - What is the difference between "in" and "for" in "hasn't eaten in five months"?



Now the cubs are growing, fed on mom's milk, but mom herself hasn't eaten in five months, and is getting thinner by the day.




What does in mean here, and how would the meaning of that piece change if for were used?



Answer



I found two similar questions in the English Language & Usage section: [1], [2].


It seems that in and for may be used interchangeably in negative sentences, although in positive sentences only for is correct. The use of in in such cases is more common in American English.


prepositions - Involved in or involved with


there are two sentences:



The HR department will also be involved with training and professional development of the company's staff.


A company's HR department may also be involved in making people redundant.




What's the difference between involved in and involved with in these two sentences?


Where should i use former and latter? Thanks!




sprites - Doom-style 2.5D Movement Animations


I've started working on a demo for my 2.5D game. For a basic scene I figured I would just use the good old fashioned doom sprites textured to a double sided plane. Simple enough. But I've been scratching my head as to how to display the proper sprite animation relative to the player viewing the sprite...if that makes since.



For example suppose I have three players in the scene Players A, B, and C as such:


Example layout


Player C should see player A as: Here's an example of what I think player A should look like from C's perspective:


A from C's perspective


While player B would see player A as follows:


A from B's perspective


My current idea is that for any given player, I will need to know the current direction of each other player, and where they are located/moving to relativly. From this, I could calculate which sprite image is required.


Is this correct? What improvements/optimizations could be made?


** EDIT ** Total number of directions will be 8 as depicted below:


enter image description here



For each direction there are two sprites (to show walking movement, sprites for the right hand directions are mirrors of the left):


enter image description here


** EDIT 2 ** Got this working and have a simple javascript/threejs example for anyone interested: https://github.com/commanderZiltoid/threejs-2.5d-fps



Answer



You would need to know the angle to the element from the spectator, so, if you have


A    |
| \aº|
|bº\ |
| \|
| B


where the lines marked with pipes "|" are the "facing" directions, the diagonal is the "attack line", aº is the angle between B sight and A (-30deg) and bº is the angle between A sight and B (-30deg).


You had to add the angles to see the angle of vision (-60deg). that's the rotation of the element, you only have to set the sprite tile that's closer to that rotation angle.


sentence meaning - "bullied as a kid" vs "bullied in your childhood" - any difference?


Do following sentences imply same thing and Is there anything wrong with the first one?



1) Were you bullied as a kid?
2) Were you bullied in your childhood?



Answer




1) Were you bullied as a kid?
2) Were you bullied in your childhood?



Yes, they mean the same thing. No, there is nothing wrong with the first sentence.


The as a kid part describes the age of the person who was (supposedly) bullied.


I forgot how to exactly name this construction. An adjunct of time, probably? Here's an example:




I travelled a lot as a kid. (When I was a kid, I travelled a lot)



P.S. To me, the sentences mean the same, but to some native speakers, there's a slight difference: see other answers. To other native speakers they also mean the same though.


Why do people use they/them pronoun for a single person?


I see a lot of people using they/them pronoun on their twitter handles. And when I googled about it, I have come to know that it is a Gender-neutral pronouns.


However, isn't it wrong to use words like 'they' and 'them' for a single person?


For example, when talking about such person, one has to say,



They are walking down the road.



which makes it plural. However, for a male/female pronoun, one can say,




He/She is walking down the road.




Answer



First, the singular they has been in use since before English became modern English; it was used in Middle English in the 14th century. It only became déclassé around 1900 when some overly stuffy grammarians started acting up.


Second, its use as a gender neutral singular is a bit more complex: It can be used either when we don't know the gender of the person:



Someone's coming up the street! They are coming to our house!



or when the person is nonbinary and prefers "they". Nonbinary people vary in which pronoun they prefer. Some use he or she, some use e, some use they; there are other possibilities to. Many prefer to use their names whenever possible, and eschew pronouns as much as possible. For instance, if the person's name is (say) Basil (as one nonbinary person I know is named):




Basil is coming up the street! Basil is coming to our house! Now Basil is knocking on our door!



Monday, January 21, 2019

text based - How do I implement branching dialogue in javascript?


I'm making a very basic visual novel type of game in JavaScript. I'm a beginner, so I'm just doing this for fun and learning, and due to bad planning I have run into a bit of a problem when you get to a branch in dialogue.


Currently I hold the script for the game in a string variable and I break up each scene with a tag such as "#~" into smaller arrays so that the game script looks like this:


var script = "Hello World!#~How are you today?"

var gameText = script.split("#~");
//gameText[0]= Hello World!

This works great for linear stuff, but how should I handle a branch in the dialogue tree? This method seems very complicated, as I would have to know exactly how long each path is and then if I ever needed to change anything it would be a headache.


How can I do this in a simpler way? I'm trying to stick to vanilla JavaScript as I'd like the game to work with Web Run Time.



Answer



Philipp's answer already shows the right direction. I just think the data structure is needlessly verbose. Shorter texts would be easier to write and read.


Even if shorter texts would make the algorithm a bit more complex, that's worth doing, because you only write the algorithm once, but most of your time will be spent writing and maintaining the story. Therefore optimize for making easier the part you will spend most time doing.


var story = [
{ m: "Hi!" },

{ m: "This is my new game." },
{ question: "Do you like it?", answers: [
{ m: "yes", next: "like_yes" },
{ m: "no", next: "like_no" },
] },
{ label: "like_yes", m: "I am happy you like my game!", next: "like_end" },
{ label: "like_no", m: "You made me sad!", next: "like_end" },
{ label: "like_end" },
{ m: "OK, let's change the topic" }
];


Some explanations for this design:


The whole story is written in one array. You don't have to provide numbers, they are provided automatically by the array syntax: the first item has index 0, the next one has index 1, etc.


In most cases, it is not necessary to write the number of the following step. I assume that most lines of text are not branches. Let's make "the next step is the following item" a default assumption, and only make notes when it is otherwise.


For jumps, use labels, not numbers. Then, if you later add or remove a few lines, the logic of the story will be preserved, and you don't have to adjust the numbers.


Find a reasonable compromise between clarity and shortness. For example, I suggest to write "m" instead of "message", because that will be the most frequently used command ever, so making it short will make the text more legible. But there is no need to shorten the remaining keywords. (However, do as you wish. The important thing is to make it most legible for you. Alternatively, you could support both "m" and "message" as valid keywords.)


The algorithm for the game should be something like this:


function execute_game() {
var current_line = 0;
while (current_line < story.length) {

var current_step = story[current_line];
if (undefined !== current_step.m) {

display_message(current_step.m);
if (undefined !== current_step.next) {
current_line = find_label(current_step.next);
} else {
current_line = current_line + 1;
}


} else if (undefined !== current_step.question) {

// display the question: current_step.question
// display the answers: current_step.answers
// choose an answer
// and change current_line accordingly

}
}
}


By the way, these ideas were inspired by Ren'Py, which is not exactly what you want (not JavaScript, not web), but could give you some cool ideas anyway.


meaning - What is understood if I say "I'm an English teacher"?


What is understood if I say "I'm an English teacher"?





  1. "I teach English", or

  2. "I'm a teacher coming from England"?





Sunday, January 20, 2019

xna 4.0 - Drawing a texture line between two vectors in XNA WP7


I want to create a simple graph maker in WP7.


The goal is to draw a texture line between two vectors what the user defines with touch. I already made the rotation, and it is working, but not correctly, because it doesn't calculate the line's texture height, and because of that, there are too many overlapping textures. So it does draw the line, but too many of them.


How could I calculate it correctly?


Here is the code:


public void DrawLine(Vector2 st,Vector2 dest,NodeUnit EdgeParent,NodeUnit EdgeChild)

{
float d = Vector2.Distance(st, dest);
float rotate = (float)(Math.Atan2(st.Y - dest.Y, st.X - dest.X));
direction = new Vector2(((dest.X - st.X) / (float)d), (dest.Y - st.Y) / (float)d);
Vector2 _pos = st;
World.TheHive.Add(new LineHiveMind(linetexture, _pos, rotate, EdgeParent, EdgeChild,new List()));
for (int i = 0; i < d; i++)
{
World.TheHive.Last()._lines.Add(new LineUnit(linetexture, _pos, rotate, EdgeParent, EdgeChild));
_pos += direction;


}
}


  • d is for the Distance of the st (Starting node) and dest (Destination node)

  • rotate is for rotation

  • direction calculates the direction between the starting and the destination node

  • _pos is for starting position changing



Thanks for any suggestions/help!



Answer



I'm not sure I understood what your problem is, but here's how I do it. First I create a static class on my project to provide an extension method for SpriteBatch that lets it know how to draw textured line. Example (just the class, it's missing the using directives and the namespace so place it wherever you want):


public static class LineRenderer
{
public static void DrawLine(this SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 end)
{
spriteBatch.Draw(texture, start, null, Color.White,
(float)Math.Atan2(end.Y - start.Y, end.X - start.X),
new Vector2(0f, (float)texture.Height / 2),

new Vector2(Vector2.Distance(start, end), 1f),
SpriteEffects.None, 0f);
}
}

The texture passed to the method should have size 1xN where N is the thickness of my ine. I'll give an example further below but first an usage example:


spriteBatch.Begin();
spriteBatch.DrawLine(lineTexture, new Vector2(20, 20), new Vector2(120, 120));
spriteBatch.DrawLine(lineTexture, new Vector2(120, 20), new Vector2(220, 60));
spriteBatch.DrawLine(lineTexture, new Vector2(20, 240), new Vector2(220, 100));

spriteBatch.End();

Which gives the following result (using the texture on the right side which I zoomed in for clarity):


enter image description here


word choice - When to use "come" & when to use "go"?


I don't understand what this article is saying:



We use come to describe movement between the speaker and listener, and movement from another place to the place where the speaker or listener is. We usually use go to talk about movement from where the speaker or listener is to another place.


When we talk about another person (someone who is neither the speaker nor the listener), we can use either come or go, depending on whether the speaker sees things from the receiver’s viewpoint (come) or the doer’s viewpoint (go).



[doer]Yolanda came to [receiver]her mother for help.


We use come when we see things from the receiver’s viewpoint (in this case the mother).


[doer]Melissa went to [receiver]her mother for help.


We use go when we see things from the doer’s viewpoint (in this case Melissa).



Could you explain it clearly?




career - How to go about getting hired by a game company



I've been programming business applications for Windows for a decade now & thinking it might be time for a change & considering game dev. I've played around in XNA and really enjoyed it. I've mainly programmed in Delphi but my favourite language is C# and I've never worked in C/C++.


My perception though is that most game companies write in C/C++ and would only use something like XNA for tools development/fast prototyping.


So my question is can you be taken seriously applying for game programming jobs having just self-taught games experience in XNA or should I really learn C/C++ & OpenGL/DirectX? What other recommendations would you make for increasing ones chances of getting hired?



Answer



Create games.



Can't stress that enough. Even if they are small prototype fun things or small finished games.


If you are applying for a programmer job, show your skill in that area by doing a well programmed game. The graphics do not need to be good.


meaning of plural of plural v.s. singular of plural


I am confused of the followings:



The locations of nodes are given.


The location of nodes is given.



Node locations are given.


Nodes' location is given.


Nodes' locations are given.



Is there any difference among these?




Saturday, January 19, 2019

Facing Grammar Issues / copywriterly and grammarly



if used (While, As, Which, If, Where, Because) Must use ! or ? or ,


When I did that it dropped 2% in grammarly, is there's specific conditions to put the ( ! , ? ) after this capital words? or every time?



As copywriterly advised to put them, then the result on grammarly went more bad.


Thank you all for answering




singular they - Is it acceptable to use "he" as a neutral pronoun?


In Italian, when I am talking about an unknown person, I would use the third person singular, masculine. For example, I could say Chi ha rubato le chiavi alla ragazza è qualcuno che ha potuto avvicinarsi alla ragazza (literally, "he who has stolen the girl's keys is somebody who has been able to approach the girl"); if I would use the feminine gender, I would imply I am talking of a woman/girl. In this case, the sentence would not use qualcuno, but qualcuna.


Is using he as a neutral gender acceptable in English?
A friend of mine said that she considers using he as a neutral pronoun acceptable, but I have noticed that (for example) some error messages given from applications, or web sites use the singular they.



Answer



Would your example in full be something like this in English?



I don’t know who has stolen the girl's keys. [?] is somebody who has been able to approach the girl.




In that case we can begin the second sentence with It. This is unusual, and it doesn’t mean that the thief is inanimate. Rather, it refers to the entire thieving episode.


StoneyB’s answer gives a good picture of the overall situation, but I would be less cautious about using they to refer to a singular antecedent. Such use has a long and respectable history as shown here. Moreover, the Oxford English Dictionary’s definition of they is



Often used in reference to a singular noun made universal by every, any, no, etc., or applicable to one of either sex (= ‘he or she’).



For those who find such use awkward, a workaround is often available by making the antecedent itself plural.


3d - Turning to face mouse


Given three points on the same Y plane;



  • A ship


  • A point along the ships heading

  • A mouse cursor


How can I find which direction and angle the mouse cursor is from the ships heading?


I have a limited turn speed on the ship - so I can not simply point the ship at the mouse, but tell it to steer left or right until it faces in the same direction of the mouse.



Answer



ship_dir =point_on_heading-ship_pos(ition) //vector ship is heading in
mouse_dir=mouse_pos-ship_pos // vector from ship to mouse position

You can find the angle between these two vectors;



ship_dir.Normalize(); //divide by length
mouse_dir.Normalize();//divide by length
dot_prod=DotProduct(ship_dir,mouse_dir);
angle=acos(dot_prod); //cos-1, this will give angle between two vectors

BUT that doesn't tell you which way to turn (left or right)(positive or negative)(clockwise or anti-clockwise).


You also need to consider the normal to the mouse_dir. The dot product between two vectors is positive if the angle is less than 90deg.


mouse_normal=(-mouse_dir.y,mouse_dir.x);
dot_prod=DotProduct(ship_dir,mouse_normal);
if(dot_prod>0) //+ive value means the angle is <90deg therefore, ship_dir is on 'left'side of mouse dir, so clockwise is shortest route

rotate clockwise;
else
rotate anti_clockwise;

enter image description here


synonyms - Difference between 'illusion' and 'delusion'


What is the difference between 'illusion' and 'delusion'?


Both of them could mean 'false ideas'. I cannot differentiate them.






  1. a false or wrong belief or idea


Many people still have the illusion that full employment is possible.


I had no illusions about the task that lay ahead.




  1. an idea or belief that is not true



It is my conviction, or my delusion, no matter which, that crime brings its own fatality with it.


He had long known that the delusion was partly due to a trap laid for him by Dunstan, who saw in his brother's degrading marriage the means of gratifying at once his jealous hate and his cupidity.




Answer



A delusion is a strongly held belief even when there is strong evidence that the belief is false.


An illusion deceives or misleads someone about the true nature of something. Magicians are often called illusionists because they mislead us into believing that something impossible has happened. Most of the audience however is not deluded into believing that the magician actually performed real magic.


For example:


"The positioning of the mirrors gave the illusion that the room was much larger than it actually was."


"If we could dispel the delusion that Engineering requires a passion for mathematics, we might see more women studying it."


politeness - "Looking forward to hearing from you" - May I omit "I am" at the beginning?


At the end of a letter, is it correct to omit "I am" in this sentence?



I am looking forward to hearing from you



Then it will become:




Looking forward to hearing from you




Answer



“Looking forward to hearing from you” is a written representation of Conversational Deletion, which John Lawler has treated on ELU: here, for instance, and here. This term names the very common colloquial omission of anything at the front of a sentence which can in context be taken for granted.


Because this is a colloquial practice, it should be used only in letters to people with whom you are on familiar terms: friends, family, or business and professional associates with whom you have a long and friendly history. Do not use it with correspondents whom you do not know well. Use the full form instead; or for just a touch more formality use the simple present:



I look forward to hearing from you.



meaning in context - "I'm a large." (Seinfeld)


The Label Maker:



JERRY: Why'd you get him a gift anyway?


ELAINE: Oh, he did some dental work for me and he didn't charge me so I thought I'd get him a Christmas present.


JERRY: Yeah, well, if you're getting him anything for his birthday, I'm a large.



The context is that Elaine had given a present to a guy and then that guy "re-gifted" it to Jerry. What does this I'm a large mean?




Answer



It's a clothing size. He wears a large. His joke anticipates clothing, given as a gift, being re-gifted to Jerry.


past simple - Difference between "did save" and "saved"


What is the difference between the two following sentences?



1) Where did you save that file?



And




2) Where you saved that file ?





meaning of "Get the pitch down"




Convincing the CFO often requires speaking the same language—an area of growth for most CIOs. Driving change will partially rely on being able to sell to your primary investors (CFO, CEO, COO, and Board). Get the pitch down. Practice and refine.



I think it means fail and then stand. is it true.



Answer



No. "To get something down" is an idiom meaning "become proficient at something". At least, that is the case in your example. "Perfect the pitch by practising and refining it".


Another example to help you might be:


"Learning the guitar can seem like a long hard task, but practise, practise and practise some more until you get it down".


c++ - OpenGL Textures not showing


So I'm currently working on a small C++ project for a school assessment and for some reason my Textures are not showing when I run the game. I don't get any compilation errors but they don't show up. I first used


int main()

only for my code but after reading up on functions I thought my code would be better if I used those. The game was working perfectly fine before I started using functions so my question is about the placement of a few parts of my code.


here is the entire code:


#include "raylib.h"


//Variable declaration
static int screenWidth = 800; // Set screen width.
static int screenHeight = 450; // Set Screen Height.
static int EnemyMove = 0;
static int Score = 0;
static int Lives = 5;
static int EnemySpeed = 6;

static Vector3 PlayerPosition = {336.0f, 361.0f, 0.0f}; //Define positions of all objects at the start of the game.
static Vector3 IceCreamPosition = {600.0f, 300.0f, 0.0f};

static Vector3 EnemyPosition = {75.0f, 25.0f, 0.0f};

static bool HasIce = true;
static bool IceShooting = false;
static bool HitEnemy = false;
static bool GameStarted = false;

Image Cone;
Image Ice;
Image Enemy;


Texture2D ConeText;
Texture2D IceText;
Texture2D EnemyText;

//local Function declaration
static void InitGame(void); // Initialize game
static void UpdateGame(void); // Update game (one frame)
static void DrawGame(void); // Draw game (one frame)
static void UpdateDrawFrame(void); // Update and Draw (one frame)


int main()
{
// Initialization
//--------------------------------------------------------------------------------------

InitWindow(screenWidth, screenHeight, "Icecream Eater");

InitGame();


//--------------------------------------------------------------------------------------

// Main game loop.
while (!WindowShouldClose()) // Detect window close button.
{

UpdateDrawFrame();
}

// De-Initialization

//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

return 0;
}

static void InitGame(void)
{
Image Cone = LoadImage("Images/Cone.png"); //load image into CPU memory.

Image Ice = LoadImage("Images/Ice.png");
Image Enemy = LoadImage("Images/Enemy.png");

Texture2D ConeText = LoadTextureFromImage(Cone); //Convert the image into a Texture; Put in vram.
Texture2D IceText = LoadTextureFromImage(Ice);
Texture2D EnemyText = LoadTextureFromImage(Enemy);

UnloadImage(Cone);
UnloadImage(Ice);
UnloadImage(Enemy);


SetTargetFPS(60); //define Target Frames per second.

}

static void UpdateGame(void)
{
if(!GameStarted && IsKeyPressed(KEY_ENTER)){
GameStarted = true;


}
if(GameStarted){
// Update
if(HasIce){ //If player has Ice the Ice will attach to the player.
IceCreamPosition.x = PlayerPosition.x + 12;
IceCreamPosition.y = PlayerPosition.y - 17;

if(IsKeyPressed(KEY_SPACE)){ //if the Space key is pressed the player goes to a shooting state.
IceShooting = true;
HasIce = false;

}
}

if(!HasIce && IceShooting){ //if the player doesn't have Ice and Is shooting check for collision with Enemy.
if(((EnemyPosition.x - IceCreamPosition.x < 10 && EnemyPosition.x - IceCreamPosition.x > - 40) && (EnemyPosition.y - IceCreamPosition.y > -64 && EnemyPosition.y - IceCreamPosition.y < 34))){
HasIce = true;
IceShooting = false;
Score ++;
EnemySpeed += 2;
EnemyPosition.x = 75;

EnemyMove = 0;
}

}

// Move player
if (IsKeyDown(KEY_RIGHT) && PlayerPosition.x < (screenWidth - 64)) PlayerPosition.x += 2.5f;
else if (IsKeyDown(KEY_LEFT) && PlayerPosition.x > 0) PlayerPosition.x -= 2.5f;
else if (IsKeyDown(KEY_DOWN) && PlayerPosition.y < (screenHeight - 64)) PlayerPosition.y += 2.5f;
else if (IsKeyDown(KEY_UP) && PlayerPosition.y > 325) PlayerPosition.y -= 2.5f;


if(IceShooting){ //Shoots ice
IceCreamPosition.y -= 5;
}

{ //enemy movement
if(EnemyMove <= 540){
EnemyPosition.x += EnemySpeed;
EnemyMove += EnemySpeed;


}
else if(EnemyMove >= 540 && EnemyMove <= 1080){
EnemyPosition.x -= EnemySpeed;
EnemyMove += EnemySpeed;

}
else if(EnemyMove == 1080){
EnemyMove = 0;

}

}

if(IceCreamPosition.y < 0 || HitEnemy){ //checks if icecream it the top
HasIce = true;
IceShooting = false;
Lives --;
EnemyPosition.y += 50;
}

if(Lives == 0){ // ends game if player has no lives left

CloseWindow();

}
}

}

static void DrawGame(void)
{
BeginDrawing();


ClearBackground(RAYWHITE);

if(GameStarted){
//draw all Textures for in game.
DrawTexture(EnemyText, EnemyPosition.x, EnemyPosition.y, WHITE);
DrawTexture(ConeText, PlayerPosition.x, PlayerPosition.y, WHITE);
DrawTexture(IceText, IceCreamPosition.x, IceCreamPosition.y, WHITE);

//draw all HUD elements.

DrawText(FormatText("Score: %i", Score), 10, 10, 20, LIGHTGRAY);
DrawText(FormatText("Turns: %i", Lives), 700, 10, 20, LIGHTGRAY);
}
else{
//draw starting menu.
DrawText("Stop the crazy woman", 200, 50, 20, LIGHTGRAY);
DrawText("from eating your icecream cone.", 200, 70, 20, LIGHTGRAY);
DrawText("Make sure she is full by", 200, 90, 20, LIGHTGRAY);
DrawText("Feeding her scoops of ice cream.", 200, 110, 20, LIGHTGRAY);
DrawText("Press ENTER to begin.", 200, 130, 20, LIGHTGRAY);

}

EndDrawing();

}

static void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();


}

my question is regarding this part of my code


Image Cone = LoadImage("Images/Cone.png"); //load image into CPU memory.
Image Ice = LoadImage("Images/Ice.png");
Image Enemy = LoadImage("Images/Enemy.png");

Texture2D ConeText = LoadTextureFromImage(Cone); //Convert the image into a Texture; Put in vram.
Texture2D IceText = LoadTextureFromImage(Ice);

Texture2D EnemyText = LoadTextureFromImage(Enemy);

UnloadImage(Cone);
UnloadImage(Ice);
UnloadImage(Enemy);

this is used to get the textures from the computer into ram and then into vram and then remove them from ram again. LoadImage cannot be used before the initialization of initWindow


does someone know why the images are not showing up?


Image Cone;


Image Ice; Image Enemy;


Texture2D ConeText; Texture2D IceText; Texture2D EnemyText;


I placed those in the variable declaration because otherwise I get an error telling me that those variables are not declared in scope.


if someone could help me that would be greatly appreciated



Answer



The reason for this is something called scope.


These two lines:




  • Texture2D ConeText; (at the top of your program)





  • Texture2D ConeText = LoadTextureFromImage(Cone); (inside your InitGame function)




each define a new Texture2D variable called ConeText.


The reason you don't get a compiler error about re-defining an identifier is that these sit in two different scopes.




  • the first is in Global Scope. Any code in your program can use ConeText to refer to this variable.





  • the second is in the InitGame function's Local Scope. That means any line of code inside InitGame that says ConeText will refer to this local version. This is called Variable Shadowing, and the local ConeText is said to mask the global version.


    Since this variable is local to InitGame, any value you put there will not be available to other code after InitGame returns. They'll just see the global ConeText which has still never been populated.




The fix is simple: if you don't want to declare a new variable, don't put the variable type before the name.


ConeText = LoadTextureFromImage(Cone);

This line says "take the exisiting variable ConeText and assign a value to it" rather than declaring a new local variable with the same name.



Friday, January 18, 2019

tense and time and composite sentence


If the eating meal starts at 7:00 AM and finishes at 8:00 AM. the drinking liquor starts at 7:00 AM and finishes at 7:50 AM.



can I say that :




  1. I drank the liquor when I ate the meal.




  2. I ate the meal when I drank the liquor.




Is I need to use progressive tense ?




Answer



Both of your sentences would reflect the time sequences you've outlined



I drank liquor when I ate my meal
I ate my meal while I drank liquor



since there were 50 mins of overlapping time.


You could also say



I finished drinking my liquor before finishing my meal.

I had finished my liquor before I finished my meal.



You don't need to use the progressive tense.


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...