Monday, December 31, 2018

xna - How is this glowing with colors radiating outward 2D effect accomplished?


I'm currently totally at a loss as to how this effect is done: http://www.youtube.com/watch?v=zp8MHUNp7Cg


The glowing on the ship and the changing color. I want to do this effect in XNA 4.0 any hints and tips?




Answer



It looks like simple vertex colouring where the colour index is function of the distance to the centre of the ship, plus time.


This can be implemented using a texture storing a palette. It could also be done proceduraly if the desired colour gradients are simple enough.


If using a palette, the vertex shader would be something like this:


uniform float4 in_ShipCenter; /* Centre of the ship */
uniform float in_Time; /* Elapsed time */
/* ... */

void main(float4 in_Position : POSITION,
uniform sampler1D in_Palette,

/* ... */
out float4 out_Color : COLOR)
{
/* ... */
float distance = length((in_Position - in_ShipCenter).xyz);
float time = in_Time;

/* Simple distance/time combination */
vec2 colorIndex = vec2(distance + time, 0.5);


/* Other possible effects:
* vec2 colorIndex = vec2(A * distance + B * time, 0.5);
* vec2 colorIndex = vec2(distance, time);
* vec2 colorIndex = vec2(distance + A * time, time + B * distance); */

/* Query the colour in the two-dimensional texture palette. */
out_Color = tex2D(in_Palette, colorIndex);
}

Edit: account for the fact that XNA doesn't support 1D palettes. If you still want to access the pixels of a 2D palette as if it was a 1D palette, see this question.



word choice - Nothing / Anything


Two people don't seem to have anything in common, and I need to ask if this is actually true or not.



Should I say...



  • 'Do they really have nothing in common?'


or



  • 'Do they really have anything in common?'




How can 'twice' be an adverb?




I’m twice your age. (Oxford Dictionaries)



It looks like ‘twice’ is a preposition to me, yet it’s an adverb. On what procedure do you think in your brain, can this be an adverb?



Answer



You can make an argument that it is an adverb:


In the sentence "I am your age", the word "am" expresses a relationship between the subject "I" and the phrase "your age". If I insert the word "twice", it modifies "am", changing the relationship between them. I don't think this works particularly well; I feel like "twice" modifies the following phrase, instead. If I say "I am twice", I ask, "Twice what?" It feels incomplete.


I think it makes more sense to analyze it another way. I would say "age" is a noun modified by the determiner "your" to form the phrase "your age"; this in turn is modified by the predeterminer "twice" to form the phrase "twice your age". This phrase is linked to the subject "I" by the verb "am".


idioms - Is "bat an eye over X" idiomatic?


I am wondering if I can use the idiom "bat an eye" and combine it with the preposition "over". I am not sure if this can be done, but to me this makes total sense, but maybe for native speakers this isn't the case, so I am asking.


For example:




They were wearing dog costumes at the party, but people didn't even bat an eye over it, because they were used to that sort of thing.





architecture - Need opinions on my component based design



I have an Entity class and a Component class. The Entity class has a list of attached components, and each component also has a member variable that is a reference to the entity that it is attached to (cyclical design).


Then, there is the EntityManager class, which has a list of (you guessed it!) entities, and each entity also has a reference to its encapsulating entity manager.


The reason for this cyclical design is due to data reliance. To explain further, my Entity class is essentially just a giant bucket of data: any data any type of entity needs already exists on this class when it is instantiated. However, in order to make use of this data, the Entity needs the relevant components attached. For example, my Rendering component takes the Entity's spriteData member and draws it to the backbuffer. Without a rendering component, spriteData is not utilized. Since my components need to access the Entity's member variables, each component needs a reference to the Entity it is attached to.


For an example of why my entity needs a reference to the entity manager, it is because some components (such as collision) need to access other entities' data buckets in order to function (for collision, this would be checking nearby entities' position vector and comparing it to the component's referenced entity).


There is more to it than this, but I just wanted to highlight the central idea of what I was doing, and wanted opinions on whether a cyclical approach like this (with little data encapsulation as well..) is a good idea or not. Maybe I'm just overthinking it /shrug. Opinions on how to steer the design would be hugely appreciated, as well.



Answer



Entity systems do exist since years, your design decision is not new. For example take a look at the Artemis framework, or my own implementation.


To provide some feedback on your system, I wrap it the other way around. Your current approach is to have an entity class and attach properties to it.


class Property

{

};

class Entity
{
std::vector properties;
};

std::vector entities;


Instead, you could drop the entity base class, represent entities by integer ids, and group the properties of the same type together in maps.


std::unordered_map sprites;
std::unordered_map positions;

Which sprite corresponds to which position is given by the id thus the integer key. The advantage of this design is that it leads to more data oriented code. It is much faster, to loop over all PositionProperties and update them (which could even be done in parallel), than to loop over all entities and each update all their different properties.


Using ids to represent entities also has the advantage that you could easily store them to disk and load them back into the system without loosing their identity.


phrase meaning - What does "within two years of the date" exactly mean



The following is from Oxford's Application Guide webpage. It's talking about the English proficiency test that one must take:



The University only accepts certain standardised test results – IELTS, TOEFL iBT, Cambridge Certificate of Proficiency in English (CPE) and Cambridge Certificate in Advanced English (CAE). The English language test must have been taken within two years of the date your programme will commence.




I can't figure it out. Would this mean two years BEFORE the date of the programme commencement or AFTER?



Answer



Answer withdrawn. I have concluded based on other comments it could mislead future language learners.


Also, nobody should rely on anyone's stackexchange opinion (including selected correct or highly rated answers) regarding official standards that you must comply with. Check with the department to validate anything


Sunday, December 30, 2018

Can I say 'What words can I use outside of X and Y'?


Based on the question: *What words can I use outside of "sourpuss" or "Debbie Downer"?


Beside some other misspelling in its full title, I understand what the OP's outside of means, but it sounds to me as if something is coming out of a "sourpuss"! So I edited the title, replacing the word outside of with beside. Soon it was re-edited (from beside) into other than.


Both of beside and other than sound fine to me, but outside of does not.


Is what I understand is correct (that outside of should be avoided in this case)? or it already is a correct usage?



Answer



outside of is perfectly fine in this case. It may be of a slightly lower register than alternatives like "other than" but it is often used in the same register as expressions like north of meaning more than.



outside of : except for something; besides something. Outside of the cost of my laundry, I have practically no expenses. Outside of some new shoes, I don't need any new clothing.




I think my preferred translation in this case would be: other than


present perfect - What is wrong with "have put" in "I have put the water in the freezer"?


How to talk about putting water in the freezer to become ice?



I have to tell the child that I have put the water in the freezer and after some time it will convert into ice.



https://ell.stackexchange.com/a/76262/26777




As a side note "have put" sounds a little weird here. Maybe someone can comment more formally why it's right or wrong. It's probably not technically ungrammatical, but it sounds stilted.



What is wrong with "have put" in "I have put the water in the freezer"?



Answer



Absolutely nothing is wrong with I have put the water in the freezer.


This is the present perfect, and the present perfect is formed by using have plus the past participle of the verb. The verb in question is put. The past participle of put is put. See the Cambridge dictionary. Notice also that the present tense and simple past tense are also put.


The very first example sentence from this dictionary use the present perfect:



Where have you put the ​keys?




It's true that the above is a question. But the basic meaning of to put as to move or to ​move something or someone into the ​stated ​place, ​position, or ​direction is the same. And using it in the present perfect is absolutely okay.


If someone did not hear what you said, they might ask



Where have you put the water?



or



Where did you put the water?




and you can answer



I have put the water in the freezer.



Some American English speakers might prefer the simple past tense



I put the water in the freezer



but the present perfect is absolutely correct.


It is also true that in spoken English we usually use contractions, so it would be




I've put the water in the freezer.



So, the uncontracted form could sound stilted. That is really the only reason I can think of. There is nothing wrong with it as far as the tense or definition.


grammar - "their having a mind"



What, according to the functionalist, is the difference between things which merely have functional roles and things whose functional roles amount to their having a mind?


Different people may interpret identical events or stimuli differently due to their having a mind that differs from your own.




Which part of English grammar stipulates using their in these sentences? For me it should be either "to them having a mind" or "to their having of a mind."



Answer



Both constructions are acceptable.


Indeed for most of the 20th century only the construction with their would have been acceptable in formal discourse: having was by many ‘authorities’ regarded as a nominal form (a gerund) which could not take a subject but only a "possessor".


Today we by and large have a better understanding of how the language works. However, there are still old-school folks around who may be tolerant of explicitly objective forms in this position, but are still uncomfortable with it. I recommend using the genitive with pronouns, as in your examples, NOT because it’s in any sense more correct but because it avoids jarring any of your readers. Consider that they’re mostly old farts like me and may be in Very Senior Positions, and wait another twenty years: they’ll all be dead by then, or retired, and then you can do it your way.


Would it be possible to change past perfect into simple past




  1. She invited me to dinner. But it _____ two years since I _____ to her house. So I lost my way.




The answer is "was", "had gone" but would it be possible to change "had gone" into "went" because if he lost his way, may be he only went to her house only one time and "went" refers to a single event.


https://www.englishtestsonline.com/mixed-tenses-advanced-level-test-quiz-online-exercise-with-answers-2/




gerunds - When to use infinitive and when to use present participle of a same word?


When to use infinitive and when to use present participle of a same word?



I like to play cricket.


To play cricket is fun.


I love playing cricket.





grammaticality - Can the preposition “in” be omitted , in sentence, “you expect to rule the city the way you rule other city.”


I have a question in below sentence.



You expect to rule the city the way you rule other city.



I think the correct sentence is




You expect to rule the city in the way you rule other city.



why can the preposition "in" be omitted?


if possible, the grammatical explanation is better for me to understand.



Answer



A noun phrase headed by way — that is, the noun way plus any adjectives, determiners, relative clauses, etc. — can be used adverbially. For example:



He did it the way she asked.
Either way, we're out of time.

Look both ways before crossing the street.
She came in through the back door, and left the same way.



So although it's fine to use in in your example, it's also completely fine to leave it out. (Personally, I think it sounds better without the in.)


Way is rather unusual in this respect, but not absolutely unique. The same happens with many nouns relating to time:



They go to church every week that they're in town.
She tried it three times before giving up.
He's moving away next month.




Saturday, December 29, 2018

conditional constructions - "Should" instead of "were to"


Can we use "should" instead of "were to" and vice versa? I've noticed that mostly they mean the same thing in the subjunctive and the conditional clauses. Especially when the "were to" isn't in the if-clause but an inverse conditional clause instead.


What I mean to say is that these mean the same:



  • Should we get more money next month, we would be able to buy an oven.

  • Were we to get more money next month, we would be able to buy an oven.



But my British friend says that "should + would" is incorrect grammar and "will" should be used instead. I cannot find a way to prove that my examples are correct. And he says the inversion is too formal and best be avoided. His variants are:



  • If we should get more money next month, we will be able to buy an oven.

  • If we were to get more money next month, we would be able to buy an oven.


That makes them completely different in meaning.




american english - “Can you do this?” vs. “Can you please do this?”



When someone asks me



Can you do this?



I feel that it is missing the “please”.


Is “please” already implied by “can”, or is it proper to ask



Can you please do this?





shaders - What are some good resources for learning HLSL?



The last time I tried learning HLSL, I made a few shaders and mostly understood what I was doing, but I still felt like I was stumbling in the dark. Most of what I learned I got from various blog posts that didn't explain things very well.



Also, the documentation on MSDN seems to be more of a function reference.


Where can I learn to not only write HLSL, but learn techniques for writing shaders?




Friday, December 28, 2018

3d meshes - matrix to transform unit cube to space defined by 8 arbitrary points


I asked a question relating to similar to this already, but I think this is a clearer objective of what Im trying to achieve.. or whether its possible at all!


Im trying to find a transformation (matrix ideally) which would transform the 8 points of a 3d unit cube to 8 arbitrary points in space.


The 8 target points have no known structure.


e.g: example xform


My gut feeling is that a matrix is unable to provide this xform since the cube faces vertices can be concave.. but are there any other methods of transformation? Thanks!




pied piping - When to use 'which' or 'in which' or 'that' (as relative pronouns)?


I am confused about when to use: 'which' vs 'in which' vs or 'that'?


Would you please explain it as a writing rule? Here I have an example:




Authors reported shortened growth period and slower radial growth rate for low soil water potential which is directly attributed to the decrease in water potential, rather than to the constraints on carbon availability.





architecture - Dictionary of common names for code objects



I'm looking for a common dictionary of terms (much like design patterns have a common language for how things interact) that are specific to games.


For instance, if I'm making a game of pong with a high level of complexity, I want to name things accordingly.


I've seen some visual objects that a user can interact with called a widget, some non-interactive ones called a doodad (back when I played with starcraft map editor anyway). Is there a proper name for the frame rate clock? Is there a proper name for the game clock (the clock that is about the movement of objects in the world but not the visual drawing)?


I just want a dictionary so I can speak the same language and not make up things as I go. I'm concerned I'm going to create things named doodads, whosits, whatsists, and flim-flams... and I don't want to do that.





ai - Space Invaders-type game: Keeping the enemies aligned with each other as they turn around?


OK, so here's the lowdown of the problem I'm trying to solve.


I'm developing a game in PyGame that's a cross between Space Invaders and Columns. I'm trying to make the motion of the enemies similar to that of the aliens in Space Invaders; that is, they're all clustered in a grid, and if even one hits the side of the screen, the entire formation moves down and turns around. However, the motion of these aliens is continuous (as continuous as a monitor can be, anyway), not on a discrete grid like in the original.


The enemies are instances of an Enemy class, and in turn they're held by a 2D array in a enemysquadron module (which, if you don't use Python, is in this case essentially a singleton due to the way Python modules work).


Inside the Enemy class I have a class-scope velocity vector that is reversed every time an Enemy object touches the edge of the screen. This won't do, though, because as time goes on the enemies just become disorganized and jumbled (i.e. not in a grid as planned). I haven't implemented the Enemies going downward yet, so let's not worry about that right now.


Any tips?




Answer



Basically, the question is, why are your enemies getting disorganized and jumbled? You only describe one factor controlling their movement, so unless there's more relevant information you're not telling us, the only scenario I can think of where they'd lose alignment is one where you're flipping the vector right there in the middle of the movement code as soon as one of them hits the edge. This would cause loss of alignment because you're partway through processing your movement when you change vectors, so some of them have moved with the old vector and some will now move with the new vector.


If that's the case, try this instead: when an enemy hits the edge, turn on a flag, and at the end of your movement cycle, check if the flag is on; if it is, flip the vector and turn off the flag.


present perfect - what I have been reading vs what I have read


Can anyone explain to me why several book review sites are called "what I have been reading" when they describe books the reviewer has read? why aren't they called "what I have read"?




meaning - Adjective, if adjective: eg "pointed, if fatherly"




They were pointed, if fatherly, remarks that echoed the themes he has stressed in his papacy but ones that resonated all the more in a newly renovated cathedral surrounded by the luxurious shops of Fifth Avenue.


New York Times



I'm not sure the meaning of the phrase "if fatherly" in the above sentence.


I'm not familiar with the syntax using the structure 'adjective, if adjective'.



Answer



It's as sumelic and DRF mentioned: it's probably the best (for learners who are unfamiliar with this structure) to read this if as although.


Your sentence:



They were pointed, if fatherly, remarks that echoed the themes ...

(= They were pointed remarks, although (they were) fatherly ones, that echoed the themes ...)





Practical English Usage by Michael Swan explains this if-structure, like this:



261.13 if meaning 'although'


In a formal style, if can be used with a similar meaning to although. This is common in the structure if + adjective (with no verb). If is not as definite as although; it can suggest that what is being talked about is a matter of opinion, or not very important.
   His style, if simple, is pleasant to read.
   The profits, if a little lower than last year's, are still extremely healthy.
[...]




marketing - How can I promote my game?



I am a beginning indie developer, and I want to get the word out about my game. What sites can I go to to ask about reviews of my game, and where might I be able to talk about and get feedback on my game from players?




hyphens - Should I hyphenate "Thank You"


When writing in English I am often told that Thank-You is incorrect.


Contradictory to this many dictionaries have it hyphenated, such as:




My question is which is the correct way?


Thank You



Answer



Ah, I presume you mean you looked up thank-you, which is an existing noun but not the same thing at all as the common idiom thank you.


Merriam-Webster tells us:



Full Definition of THANK-YOU


: a polite expression of one's gratitude


Origin of THANK-YOU


from the phrase thank you used in expressing gratitude

First Known Use: 1792



Now, the phrase “thank you” is indeed always written without a hyphen.


But when we transform phrases into nouns, we use (often) hyphens to indicate that those words belong together as a set phrase, and together they become a noun:



After the wedding they sent thank-yous to the guests.



As with many nouns, we can use thank-you attributively ("as an adjective") to modify another noun:



I sent her a thank-you note.




Thursday, December 27, 2018

2d - How can I find a projectile's launch angle?


I am making a 2d game in which units fire arrows at each other. I know the shooter's and the target's position and the initial velocity of the projectile. I want to know the angle the projectile should have in order to land on the target. The target could be at a different height than the shooter.



To sum up I know v0, R and g and I need to find the angle (or the height ?).


I read http://en.wikipedia.org/wiki/Projectile_motion ,but I can't find something related to what I need.



Answer



The formula to find the angle is


Formula


where v is initial launch speed, g is the gravity constant, x and y are the target's distance and height.


The two roots of this equation give you two possible angles. If the results are imaginary then your initial velocity is not great enough to reach the target (if you want to calculate the angle of reach read this). It's up to you which angle is selected. It would make sense to choose the most direct path i.e. the smaller angle.


You can see a GIF of this equation below with different target values and a constant launch velocity.


Formula graphed as animated GIF


Resources from this wikipedia article



punctuation - Can the comma be used to create a pause in a (long) sentence?


I'm studying for TOEFL and saw some punctuation rules online. Some sources mention the pause for comma, while others don't. Is there a canonical source for questions like this?





collision detection - How can I cancel a contact in a b2ContactListener?



To know when contacts happen we can derive from b2ContactListener and implement our own solution which is great. I'm wondering is there anyway we can cancel a contact, that is to say when we hit begin contact we call a function or do something to destroy the contact before it has a chance to be resolved?


My game logic relies on setting any number of collision groups (which are basically integers). Collision groups can have settings to interact with one another, for example collision group 41 and 13 may be set to never collide while group 41 and 56 will collide. Some groups which are set not to collide are still meant to generate an OnContact callback (but will obviously never get to end contact).



Answer



Use PreSolve rather than BeginContact. From the Box2D documentation:



Pre-Solve Event


This is called after collision detection, but before collision resolution. This gives you a chance to disable the contact based on the current configuration. For example, you can implement a one-sided platform using this callback and calling b2Contact::SetEnabled(false). The contact will be re-enabled each time through collision processing, so you will need to disable the contact every time-step. The pre-solve event may be fired multiple times per time step per contact due to continuous collision detection.



Wednesday, December 26, 2018

Anti-cheat Javascript for browser/HTML5 game


I'm planning on venturing on making a single player action rpg in js/html5, and I'd like to prevent cheating. I don't need 100% protection, since it's not going to be a multiplayer game, but I want some level of protection.


So what strategies you suggest beyond minify and obfuscation?


I wouldn't bother to make some server side simple checking, but I don't want to go the Diablo 3 path keeping all my game state changes on the server side.


Since it's going to be a rpg of sorts I came up with the idea of making a stats inspector that checks abrupt changes in their values, but I'm not sure how it consistent and trusty it can be.


What about variables and functions escopes? Working on smaller escopes whenever possible is safer, but it's worth the effort?


Is there anyway for the javascript to self inspect it's text, like in a checksum?


There are browser specific solutions? I wouldn't bother to restrain it for Chrome only in the early builds.



Answer




The short answer is you can't do it. Anything that runs client side, especially from source, can be modified to defeat your tactics trivially. If you put in place a client side checker to look for abrupt changes, a user can just disable the checker.


The good news is that, generally, there is very little cheating on single-player games. The only major exception being for games that have large "youtube highscore" communities like Line Rider, where players compete with each other over YouTube.


If you are aiming for that, or are just too stubborn to accept that people might cheat in the game, or are keeping high-scores yourself (which is a form of multiplayer) then what you must do is all of the calculations server-side. Yes, everything that matters. You can't even repeat the calculation client side to try to give the user the score and then 'verify' it with the server because the user can then just disable the check and disable any system that ensures there are checks.


I wish there was a better answer to this, but there isn't.


That said, there are things you can do to make it a little harder to cheat. They will not stop anyone serious from doing it and releasing a toolkit to cheat, but it will slow them down:



  • Minify and Obfuscate your JS, which absolutely will make the code harder to read. You can de-minify and sort-of de-obfuscate but you can never get back the right variable and function names, nor comments.

  • Bake in values with a different language. In this case you can use PHP or other server side languages to handle static setup variables. If the jump distance is always supposed to be 2 spaces, normally you'd define a jump distance for the player object. Don't, handle that with PHP so that the JS source ends up with 2s plastered all over the code in a million places. This has the happy additional side effect of being able to speed up your JS too.

  • With some practice, you'll get proficient with the mix and you can even custom-build your JS for each player. Which is another way to prevent cheating. If each player's code is different somehow, then it is harder to write a cheat that can be part of a toolkit.

  • Finally, you can checksum the source based on the player's identity. Say their IP address and/or username. You know what the player-specific version of the JS will be, you can bake in a checksum and require that it be the same on the other end. Easy to disable like any client-side JS, but once again makes it a little harder to make a toolkit.



So. As you see, it is probably not worth it to go this route. It is hard. Requires a lot of really silly coding practices to do, and is ultimately still relatively easy to defeat. You'll need to do all the calculations server-side to prevent cheating. Or let go, and accept that cheating will happen.


game mechanics - Bubble shooter falling algorithm


To complete this question about the same color search algorithm, I would like to know if someone knows which is the best implementation for making other bubbles fall when they are no longer attached. More precisely, how can I detect islands of isolated bubbles.


My data structure is a NxM matrix.



Answer



Every bubble that isn't floating must have some path going back to a top bubble (are we assuming the side walls aren't "glue"?). Apply a flood fill algorithm for every bubble found in the top row. Doing this for every top bubble is essential because it'll work flawlessly in any case, in particular if there are several columns of bubbles hanging from the top but not touching each other.


Flag all "filled" bubbles for each iteration of the algorithm, and skip any already filled bubbles in the top row to save time.


When all top bubbles are filled, drop the bubbles that haven't been flagged.


suffixes - Use of the suffix -ish



He is a nice enough boy - Rather Jimmy Olesenish I thought.


He's an honest man, rather Lincolnesque in his manner.


She has an unreal figure, rather Barbieish in its proportions!



Can anyone explain the usage? I am very confused by -ish in such situations.



Answer



This -ish suffix itself isn't actually "informal" (foolish, childish, devilish, for example, are well-established).


According to OED, the usage extended from nouns such as fool, child, devil centuries ago, to include adjectives - initially with colours (bluish, greenish, etc.), but "in later use also with other adjectives, and now, in colloquial use, possible with nearly all monosyllabic adjectives, and some others".



OED's definition for the suffix when applied to a noun says...



Of or belonging to a person or thing; of the nature or character of.
...
In recent colloquial and journalistic use, -ish has become the favourite ending for forming adjs. for the nonce (esp. of a slighting or depreciatory nature) on proper names of persons, places, or things, and even on phrases, e.g. Disraelitish, Heine-ish, Mark Twainish, Micawberish, Miss Martineauish, Queen Annish, Spectator-ish, Tupperish, West Endish; all-over-ish, at-homeish, devil-may-care-ish, how-d'ye-doish, jolly-good-fellowish, merry-go-roundish, out-of-townish, and the like.



Obviously some of the more "unusual" versions could well be called "informal", and because there's often the possibility of a more "scholarly" alternative (Micawberesque rather than Micawberish, for example), some people may feel it's inherently a bit informal. But I don't really think so - it's just that the suffix is so "productive" people naturally make use of it to informally create nonce words as and when they want.




As OP seems to have discovered, rather is often used conjunction with -ish forms (including "rather childish" as well as "rather Barbieish"). Usually, it will have the sense of to some extent, or in some way, but in some contexts it might have more of the "comparative" meaning to a greater extent...




"I wouldn't say she's 'Barbieish' - rather 'Dolly Partonish', to my mind."





EDIT: Because it's become increasingly common in recent years, I'll just make special mention of -ish as used to impart a certain "vagueness" to times...



"Drop by my office tomorrow afternoon. Three-ish would be fine."
"I've nearly finished coding the new app. It should be ready for testing Wednesday-ish"



In fact, this usage has become so common, the suffix can sometimes be used on its own...




"Hi. I'm just calling to make sure you're coming early to help prepare for my party tonight."
"Stop worrying! I told you before I'll definitely be there"
"Great! See you at 6 then!"
"Ish." [hangs up]



(where that final word effectively means "I'll arrive about 6, but probably later than you're expecting.")


adverbs - The So and Such Choice


We can say:



I know such a good place



I heard we could also say:



I know a so good place




OR



I know so good a place



Is it true or not and how would it be if not and if yes and so on=)




legal - Does it require any license to use soccer players and teams names in a paid or free game?


I would like to know if any license is required to use Fifa registered team names and player names in paid or free games (e.g. Spanish League teams, Messi, Cristiano Ronaldo names etc).


I'm currently developing an interactive soccer game for mobile platforms (iOs and Android specifically) and I was wondering if it there is any legal issue on using this information. I suppose that if I publish it as a paid-app, it is maybe ilegal without a Fifpro License or something like that. But would it be ilegal if I publish the game for free, and charge for special items in the game?




Tuesday, December 25, 2018

meaning - blonde or blond


https://www.lingq.com/learn/en/preview/item/431401/



I was on my bike, and I saw the thief as I cycled past. It was quite dark, but I could tell he was old, at least 35, with blonde hair. He was wearing jeans and a hoodie.



I guess there is a mistake in the above context. Because blonde should be used for females.Am I right or not?



Answer



When talking specifically about hair color, "blonde" and "blond" are alternate spellings and can be used interchangeably. However, when referring to a person (with a particular hair color) you are correct and "blonde" is for females, while "blond" could be for either male or female.




blonde
(adjective) 1. (of a woman or girl) having fair hair and usually fair skin and light eyes.
(noun) 2. a woman or girl having this coloration.


(Example) Among famous actresses, Marilyn Monroe is probably the most well-known blonde.



See also brunette


"whose" vs "that its" in English


I'm an English learner and today I faced a question where I was supposed to fill in the missing blank. The question was:



The large family _____ house had been destroyed by the storm was invited to stay at a hotel.



There were multiple options including:



i) whose


ii) that its


Can someone explain why option (ii) is wrong while option (i) is correct?


What is the grammar involved here?




Monday, December 24, 2018

grammar - How about someone do something?


Can "how about" be used in this way? I heard it in an episode of Grey's Anatomy:




  1. How about we don't talk to her anymore?



Because from what I've learned after "how about" we're supposed to use a gerund:





  1. How about not talking to her anymore?



But, for me, both of these options seem right. But what if we want to use it to refer to a "he" or a "she"?





  1. How about she goes to the park?





  2. How about her going to the park?





Also, I feel like in the sentence "How about not talking to her anymore?" there is a "us" that is omited. Am I right? Could someone clear this up for me?



Answer



The full-clause form


You are correct: how about can also take a full clause with a subject of its own. A common sort of example is “How about we eat at Sparky’s Diner?” Judging by this graph, this phrasing only started becoming common in print around 1980, and in speech it might be only about 100 years old. The gerund form with an explicit subject (see below) is older and more formal, although that appears to be changing.


In How about subject verb {objects}?, the verb is in the subjunctive mood, but usually people put it in the indicative even though the meaning is subjunctive. Here are two examples in the subjunctive mood:




How about dad pay for the car?


How about dad not pay for the car?



Notice that the negation is done in the usual way for the subjunctive: by putting not in front of the verb, without adding an auxiliary verb. In the indicative mood, these sentences would be:



How about dad pays for the car?


How about dad doesn’t pay for the car?



Here, negation works as usual for the indicative mood.


The gerund form



The gerund form can also take a subject, usually in the possessive case:



How about your taking out the trash?


How about dad’s paying for the car?



This explains the missing “us” you noticed. Made explicit (as is almost never done), that would be:



How about our not talking to her anymore?



Notice that negation works as usual for gerunds (that is, without an auxiliary verb).



The present-participle form


You can also say:



How about dad paying for the car?


How about dad not paying for the car?


How about you taking out the trash?



Notice that negation works as usual for participles (that is, without an auxiliary verb). You can even do this:



How about us not talking to her anymore?




Why all this makes sense


The above all makes sense and doesn’t come across as ungrammatical, even in the rarer forms, because how about x simply raises x for consideration or to get an answer from the listener. The x can be anything: a physical object, a fact, or an unrealized possibility.


“How about this necklace?” asks for the listener’s thoughts about the necklace in regard to whatever the current topic of interest is. Depending on context, the meaning could be equivalent to “How would you like to wear this necklace?” or “How about I wear this necklace?” or “Do you think this is a remarkable necklace?” or even “Admit that this necklace would not have been found in your suitcase if you weren’t cheating on me!”


Raising an unrealized possibility or a fact for comment is really no different than raising an object for comment. The full clause or gerund clause still functions as a noun.


If it’s an unrealized possibility, like “How about you take out the trash?” or “How about taking out the trash?”, then it’s probably a suggestion or proposal.


Subjects are optional on gerunds, so both of these are grammatical: “How about taking out the trash?” and “How about your taking out the trash?”


You can also describe a possibility by naming an object and giving it an imagined adjective such as a present participle, as in: “How about you taking out the trash?” (As a strong hint to take out the trash, this form definitely comes across as informal and disrespectful.)


If it’s an actual fact, like “How about your missing all but two games last season?”, then you can’t use the full-clause form. That would contradict the subjunctive mood inherent in the full-clause form.


I can’t think of any other situations where a full clause can be the object of about. For example, you can’t say “He’s talking about we hire John.” Maybe this is why you haven’t come across it in books or classes about English. (Most likely, books and classes skip it because it’s relatively new.)



The only form that you really can’t use is the infinitive:



How about me pay for the car?



terminology - What is the difference between curly braces and curly brackets?


I'm really confused about it, sometimes I read something and it refers to {} as curly braces and sometimes to curly brackets, what is the difference between those two terms? Are they referring to the same thing?




Answer




Braces: (also known as curly brackets, or curly braces)


enter image description here



Yes, they are the same thing.


And, actually, there are many names for it. According to Wikipedia,



{ } — braces (UK and US), flower brackets (India), French brackets, curly brackets, definite brackets, swirly brackets, curly braces, birdie brackets, Scottish brackets, squirrelly brackets, gullwings, seagulls, squiggly brackets, Tuborg brackets (DK), accolades (NL), pointy brackets, or fancy brackets




licensing - "I end up studying English" vs. "I end up to study English"


Why is it that we have to use the gerund form for the first example? I have been told that it is not grammatical to use the infinitive form.


For some verbs, it's okay:




I wanted to study English.
I had to study English.
I needed to study English.
I tried to study English.
I traveled to study English.



But, for some verbs, it's incorrect:



I ended up to study English.




Why is that the case?




c++ - Best way to get elapsed time in miliseconds in windows


I'm trying to do it using two FILETIMEs, casting them to ULONGLONGs, substracting the ULONGLONGs, and dividing the result by 10000. But it's pretty slow, and I want to know if there is a better way to do it.I use c++ with visual studio 2008 express edition. This is what I'm using:


FILETIME filetime,filetime2;
GetSystemTimeAsFileTime(&filetime);
Sleep(100);
GetSystemTimeAsFileTime(&filetime2);
ULONGLONG time1,time2;
time1 = (((ULONGLONG) filetime.dwHighDateTime) << 32) + filetime.dwLowDateTime;
time2 = (((ULONGLONG) filetime2.dwHighDateTime) << 32) + filetime2.dwLowDateTime;

printf("ELAPSED TIME IN MS:%d",(int)((time2-time1)/10000));

Answer



Use QueryPerformanceCounter.


long long milliseconds_now() {
static LARGE_INTEGER s_frequency;
static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
if (s_use_qpc) {
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return (1000LL * now.QuadPart) / s_frequency.QuadPart;

} else {
return GetTickCount();
}
}

// Somewhere else...
// ...
long long start = milliseconds_now();
// ....
long long elapsed = milliseconds_now() - start;

difference - Are "when/whenever/where/wherever possible" synonyms?



This Macmillan dictionary suggests that the when/whenever/where/wherever possible are synonyms:



when or where you have an opportunity to do something. I relax with a good book whenever possible.



However, I've seen this answer (it seems from a native speaker) on this forum.wordreference.com post:



It seems obvious to me that "when" refers to time and "where" to place.


Call me when possible. (= call when you have time)


Walk where possible. (= walk wherever you can or are allowed to)


In the above exercise the obvious answer should be "when" because it refers to time, unless I'm missing something.




It suggests that they are different. I'm confused. I've also seen this example from the Potter book:



Always brought people in alive where possible.



In this case, can we put: Always brought people in alive when/whenever/wherever possible.? Would they mean the same thing?



Answer



where can refer to context or situation.



Where there's an indication of domestic abuse, the clinician must inform the authorities.




That phrase is synonymous with "In situations where..."


Consider the word situation itself, which comes into English from medieval Latin and medieval French. By that time it is figurative, since it doesn't really refer to a place (Medieval Latin situare) but to a set of circumstances. Oops, now you must consider the word circumstances, whose meaning is itself founded on a spatial metaphor.


c++ - Cbuffer Padding Error



In my cbuffer in DirectX, I send 2 variables over to my HLSL shader called Light & Roughness. If I remove the Roughness variable my program compiles fine but as soon as I introduce Roughness I get the error: Exception thrown at 0x00007FFDDEFA0030 (d3d11.dll) in Eagle Engine.exe: 0xC0000005: Access violation reading location 0x00000000000000C0.


On the HLSL side the light variable contains it's defined value that was set in C++ and works fine without Roughness. If anyone could help me that would be great, I've included the necessary code below.


effects.fx


#include "Common.hlsl"

struct Light
{
float3 dir;
float4 ambient;
float4 diffuse;

};

cbuffer cbPerFrame
{
Light light;
float Roughness;
};

cbuffer cbPerObject
{

float4x4 WVP;
float4x4 World;
};

Texture2D ObjTexture;
SamplerState ObjSamplerState
{
Filter = ANISOTROPIC;
MaxAnisotropy = 16;
AddressU = Wrap;

AddressV = Wrap;
};

struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float2 TexCoord : TEXCOORD;
float3 normal : NORMAL;
};


float3 DirectDiffuseBRDF(float3 diffuseAlbedo, float nDotL)
{
return (diffuseAlbedo * nDotL);
}

VS_OUTPUT VS(float4 inPos : POSITION, float2 inTexCoord : TEXCOORD, float3 normal : NORMAL)
{
VS_OUTPUT output;

output.Pos = mul(inPos, WVP);


output.normal = mul(normal, World);

output.TexCoord = inTexCoord;

return output;
}

float4 PS(VS_OUTPUT input) : SV_TARGET
{

input.normal = normalize(input.normal);

float4 textureColor = ObjTexture.Sample(ObjSamplerState, input.TexCoord);

float nDotL = saturate(dot(input.normal, light.dir));

float3 diffuseLighting = textureColor * light.ambient * light.diffuse * Roughness;
diffuseLighting += saturate(DirectDiffuseBRDF(textureColor, nDotL));

return float4(diffuseLighting, textureColor.a);

}

In my Main.cpp


constbuffPerFrame.light = light;
constbuffPerFrame.Roughness = 1.0f;

devcon->UpdateSubresource(cbPerFrameBuffer, 0, NULL, &constbuffPerFrame, 0, 0);
devcon->PSSetConstantBuffers(0, 1, &cbPerFrameBuffer);

Header.h



struct Light
{
Light()
{
ZeroMemory(this, sizeof(Light));
}
XMFLOAT3 dir;
float pad;
XMFLOAT4 ambient;
XMFLOAT4 diffuse;

XMFLOAT4 specular;
};

struct cbPerFrame
{
Light light;
float Roughness;
};

Light light;

cbPerFrame constbuffPerFrame;

Answer



You are not padding after the roughness in the C++ side structure. You need to add 3 more floats of padding after roughness so that the buffer size is a multiple of 16 bytes.


On MSDN you can read a more complete explanation.


software engineering - What are the legal considerations about making a game with a dynamic age restricted content?


What I mean by this is - is it legal to make a game which asks (or proves) your age during install or on initial load, and then dynamically sets the content to the players age.
For example if the players is under-age then all swear word assets are replaced with there PG13 equivalents.
Or the same with blood and gore.


Does this make sense?
Also what are the communities opinions or feelings about this?
(note for locality I am referring to UK law but laws and opinions for any other country is encouraged!)



(ps i can't create tags)



Answer



IANAL but you can certainly ask the player to enter their age and set up some options as a result, or just give the players options for gore & language that they can manually set. Several games do this already allowing you to turn off, or at least tone down blood.


However if you are asking if you can get a lower rating from PEGI/ESRB for this I'm going to make an educated guess of "No". They are going to rate you based on the fully enabled gore/language version of your game. If you look at it from their perspective, even if your game does really tone down elements when given the correct information, there is no way to be sure that players will be honest. So if they put a lower restriction on the title and then little Jimmy says he's an adult and gets full gore, parents will not be happy.


Sunday, December 23, 2018

expressions - Is miscarriage or stillborn a better choice stylistically of an idea?


I used an expression for describing a really bad idea that already from start was bound to fail:



...that was a miscarriage for an idea...



In an answer, a person pointed out that he'd prefer another expression:



...that was a stillborn idea...




Both of us are admittedly non NSE and I under how those two compare in terms of rawness and wittiness. Are there an even better choice instead of those two? I lean towards AmEng, in case there's a cultural deviation.



Answer



Both can be used, but imply different things. A "miscarriage" would apply to a project that failed to reach completion for some reason. A "stillborn" project is one that can metaphorically be said to have "died in the womb" as it neared completion, and looked at afterwards as not useful for its intended purpose.


Both are similar, but "miscarriage" is more of an active term, and is generally used when talking about the results. Perhaps the project it had a team of incompatible people working on it, who fought so much they didn't have time to make meaningful progress before the deadline. Perhaps funding was inadequate to produce the list of required features. Or perhaps management interfered so often by changing requirements that the project never had a chance to get off the ground.


Meanwhile "stillborn" might be used for a project that was flawed from the start and never had a chance to deliver its desired result.


Naturally the metaphor may be distasteful, or at least uncomfortable, without the appropriate tone (and, naturally this is not limited to English, as it would likely be the same in many other languages). To use this it would be best to convey a tone of regret, as with something very important to you that nevertheless failed to properly mature.



The team declared the project "stillborn" after they realized their initial hypotheses were inherently flawed, and decided to work on a different approach.


Although they had been making steady progress, the project suffered a miscarriage in its second year when the lead researcher had to drop out for medical reasons, and eventually the company was forced to cancel their funding.




In terms of your linked question, I agree that "stillborn" works better, as it's an idea that will never quite work. It didn't fail, but rather it had already failed, or was a failure from the start.


Some alternate metaphors:



dead on arrival (D.O.A): The project was declared DOA after their competitor beat them to market with a superior product.


(did not) bear fruit: Although the researchers tried every possible combination they could think of, their efforts did not bear fruit as they were unable to produce a significant result.



(Edit) I should qualify "stillborn" in response to your comment: You can talk about something being "stillborn" after the event. A "stillborn" idea is one that was figuratively born with no chance of being viable. For example, I might (humorously) conceive of an idea of training an army of cybernetic chimpanzees by training them with banana-flavored weaponry, only to be told it's a waste of time -- effectively "stillborn" -- because chimps prefer mangoes to bananas.


Similarly, you would describe a project as "stillborn" from the perspective of when it was "birthed", and assuming it had no chance to succeed because it was flawed from the start.


Double preposition?


I am reading a journal and found a sentence which seems wrong. The sentence is,



It is apparent that the errors originate from outside the model.



This sentence used from and outside together which are supposed to be preposition here. I guess double preposition is not allowed in the English Grammar. May someone clarify this point for me? Moreover, I rewrote the sentence. May anyone check whether my modification makes the sentence correct?


The modified sentence:




1.) It is apparent that the errors originate outside the model.
2.) It is apparent that the errors originate from the outside of the model.



Any help are appreciated!


UTC +8:00 12/13/2013 4:05 PM


Follow-up question:


So double preposition is not incorrect. But in this example, it seems redundant to use "from outside". Like my 1st alternative, just "outside" is enough to express all the meaning. Should we avoid double preposition in this case? Or does it express some specific meaning that I have not understood yet?



Answer



I don't recognise the idea that there might be something wrong with "double prepositions" in English. Obviously it's not true in general, but I can't even guess why anyone would think it true in any context.


For the specific usage OP asks about, it's just a matter of whether we normally speak of things originating somewhere, or originating from somewhere. As this NGram shows, we actually use the first form 2-3 times more often, but there's nothing wrong with the second in originate from outside.



That NGram also shows how rarely we use OP's suggested originate from the outside. What this doesn't tell you is that the outside would be extremely unlikely in OP's exact context, because when we include the article before outside, we're normally referring to the outer surface (of a container, for example).


past tense - "Ago" at present perfect simple?


Are there any instances in which the use of "ago" in Present Perfect Simple Tense would be deemed correct? For example:




I've (just) finished reading 5 minutes ago.



From my perspective, the adverbial phrase "five minutes ago" suggests that the action is recent, and, thus, it wouldn't make sense to use past tense simple. What's your opinion on this?



Answer



One of the main rules of tense usage is that the simple past is used for finished actions and especially also with specific expressions of time/in time that point to a specific occasion.



  • Five minutes ago

  • Ten years ago

  • Last week, month, year, yesterday etc.

  • Specific dates: October 1st, etc.



For example. There is zero continuity of any kind with the simple past.


Without getting into all the complexity of the present perfect, it is much easier to know, generally speaking, when to use the simple past.


Five minutes ago calls for the simple past. All expressions with ago and time (five months ago, etc.) call for simple past.


Of course, you can also use: I've just finished my work, but not with five minutes ago.


I sincerely hope this simple rule is clear. When I say rule, I am not talking about standard or non-standard. Even uneducated native English speakers would not mix these up.


subject verb agreement - "Macaroni and cheese (is/are) on the lunch menu"


Is the sentence "“Macaroni and cheese is on the lunch menu.” correct?
I mean there 'is' is used as verb because two item means one unit. Or 'are' will be used?



Answer



Is is appropriate here, since "macaroni and cheese" refers to a single menu item, ordered as a unit. A similar pair might be "spaghetti and meatballs."


Two completely separate items would use are. For example, "Steak and chicken are on the menu."


Other options for a meal might use either verb, depending on how they are being discussed.


Lunch Menu
1. Hamburger and Fries

2. Fish and Chips



A hamburger and fries are on the menu.
A hamburger and fries is one option from the menu.



In the second sentence, the message is set up to emphasize that "hamburger and fries" are a single item with multiple parts.


Fish and chips would be closer to macaroni and cheese in the US, as we don't refer to this style of fried potatoes as chips except in this context, when paired with fried, battered white fish. Because these are grouped, you'd be more likely to hear someone say, "Fish and chips is on the menu" even though it would entirely appropriate to order them separately. "Fish and chips are on the menu" would also be entirely acceptable.


meaning - Awake or Awaken Which one is correct?




  • Were you awaken at 1 am yesterday?


Is this grammatically correct? Can you tell me meaning of awake properly? How is it used as Adj., and as verb by giving some examples?



  • I awoke at 11 am today.


Is this correct? Actually, What is the difference between wake and awake? I have searched a lot on Google but all in vain. I am not getting their difference.



Answer



Awake has two meanings:





  • As an adjective it describes a person or animal's state. It may only be used as a predicate adjective, in the predicate of a clause, not as an attributive adjective before a noun:



    ok John is awake and at work.
    ∗  Awake John is at work.





  • As a verb it is intransitive—it takes no object—and means “to become awake (adj)”. It is an irregular verb, with the past form awoke; two different past/past participles are in use, awoken and awaked:




    I awake at four o'clock most mornings.
    I awoke at six o’clock this morning.
    I have awoken/awakened early only twice this month.





Awaken is a transitive verb requiring a direct object. It means “cause [someone or something] to become awake”. It is a regular verb: both the past and past participle forms are awakened:



My wife awakens me if I oversleep.
My wife awakened me at seven o’clock.

He was awakened by a loud crash.



The verb wake, woke, woken/wakened is also used in both transitive and intransitive senses.



I woke at four o’clock.
My wife woke me at four o’clock.
I was wakened at four o’clock.



In pre-20th-century texts wake may also have another meaning: to “stay awake”.


These verb uses are fairly complicated; but it is simplified by the fact that none of them are used much in colloquial English today (which is one reason why the past and participle forms are so variable). Instead, the phrasal verb wake up (past woke, past participle woken) is used in both transitive and intransitive senses:




I wake up at four most mornings.
My wife woke me up at seven o’clock.
He was woken up by a loud crash.



You will need to recognize the different forms and meanings in your reading; but for your own work you can use wake up in any context or register.




∗  marks an utterance as ungrammatical


Saturday, December 22, 2018

sound - Interactive music games


I've been seeing lots of simple interactive programs popping up all over the internet that generate basic music, usually quite nice sounding, from simple interactions from the user. Otomata is one recent popular example; on the iDevices there are a variety of programs, like Bloom.


I'm just wondering how these programs work. How do they generate the music live? Are there established APIs for doing this? I'm interested in the technical aspects of how this is implemented. My knowledge is so lacking here I'm honestly not sure how to better phrase the question. Ask if anything isn't clear!



Answer



Your question can be broken down into 2 components:


1. How do I generate musical sounds and timbres, and then play that through the speaker?


This is even a 2-parter:


1.1. How do I generate any kind of sound and play it back through the speaker?



Audio data is frequently represented and processed in 32 bit floating point numbers ranging from -1.0 to 1.0, representing. Open up an audio file in Audacity and zoom in to the sample level to see individual pieces of data. When you write data either to a sound file or to an audio buffer that goes out to the sound card, you typically map these -1.0 to 1.0 values to a fixed scale (no fractional values) of 0 to 65536 (for 16 bit depth) or 0 to 16777216 (for 24 bit depth).


Once you have your buffer constructed, you feed it to your sound device. This is library and platform-specific.




  • Flash 10 added support for dynamically generating sound via the SampleDataEvent of the Sound class. You create a Sound object, but don't load any data into it. When you call Sound.play(), it will fire the SampleDataEvent, and the data member of SampleDataEvent will be a bytearray you can feed samples into. Read the docs for details.




  • XNA recently gave you the option of using DynamicSoundEffectInstance, which is similar to Flash's sampleDataEvent.





  • iOS seems to support AudioUnits, which are a standard way of generating sound in Cocoa (disclaimer: haven't used them myself). You could use this in a Mac application as well. (example: http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html)






1.2 How do I make my generated sound musical?


For a sound wave to have a sense of pitch, it must be generally periodic (obviously sound waves from instruments are not perfectly periodic, but we're talking broad strokes here). Any periodic wave can be constructed by adding together multiple waves of different frequencies and phases.


An spectrum analysis will show that the frequency with the greatest amplitude will generally be the pitch that the sound is perceived as. See this figure. To add depth, you also add waves with frequencies that are integer multiples of the base frequency (see the overtone or harmonic series).




2. How do I use my new robot zombie sounds to generate music on the fly?


This is a really open ended question, and is half of the fun of computer music. You can start somewhere as basic as selecting notes at random from a predefined scale, and then from there implement random rhythm variation as another step.



People do everything from selecting portions of music from a database of pre-written compositions (there's a really really thick book on a project to get a program to write 2-part Inventions in the style of Bach), to applying genetic algorithms to an initial interval vector and apply the results to different starting pitches.


Eventually you'll want to think about how to create larger movements of smaller, randomly generated musical components. As you start building up, this is where you can begin to insert game hooks. Maybe the angle of the mobile device can alter the range of notes, and when bad guys arrive you change the set of pitches in the scale to closer resemble a minor rather than a major scale, or adjust other properties such as attack envelopes and frequency of note events.


Timing can be tricky, because you don't want to be polling the elapsed time of your audio source, but you also want to be accurate. Relying on "sound complete" type of events will generally be much too slow. In Flash you can get away with musical timing for long sound cues if a 50ms delay is acceptable and it wouldn't be too obvious if you faded out one sound then started it again on another channel in sync with everything else. The catch is you need to check Channel.position on every frame update, unless you're manipulating your own sample data, in which case you're crunching a lot of data anyway just copying stuff to the SampleDataEvent buffer. Performance aside, just use basic ratios to figure out beat and tempo to millisecond interval conversions.




There's a whole wide world of audio programming fun out there


A book that I haven't managed to read much of yet (damn school) is The Audio Programming Book by Richard Boulanger and Victor Lazzarini. The first 60-70 pages are a basic C primer wrapped up in music-specfic examples and may get a little boring, but they get to the good stuff later on like oscillators and filters.


There's a lot of popular visual tools, libraries, and mini programming languages for creating or prototyping computer music:



The newfangled "creative computing" frameworks like Processing, OpenFrameworks, and Cinder all have some basic audio capability as well, but nowhere near what you get with these dedicated tools. A classmate of mine models HRTFs in SuperCollider to simulate environments in a basic 3d environment. Another fun thing is to pipe OSC out of Unity and let it control a MaxMSP patch.


prepositions - Expressing a purpose with for + gerund?


The question is simple but I would like to understand the principle governing the choice of prepositions in the following examples.


I know it is not correct to say, for example


1) *I have come here for starting a business. (should be - to start)


2) *I have come here for telling you about it. (should be - to tell)



However, these are fine (I suppose, correct me if I am wrong)


3) I have come here for fishing.


4) I have come here to fish.


Why is it that it is wrong to say "have come here for starting a business" and why is it that 3) and 4) are OK? Do 3) and 4) mean different things?




american english - Problem listening to foreign accents




From the beginning I had some problems listening to foreign accents. Like when someone from my native country (India) speaks English I understand it at once, but if someone from a foreign country especially US speaks English, I have to make them repeat the sentence several times to understand it. Also, I have noticed I have more problems when watching movies, talking than when watching lectures. I am having lot of trouble these days because of it.


So how can I solve this problem? Also, is there is particular term for this state?




legal - Do I need licensing to use real city names in my game?


I want to allow people to go to real places (Seattle Washington, Portland, Maine, etc.) in my game. Will I need licensing to make those places and use their names?




physics - Collision detection logic


Edit 2


enter image description here



In the following picture sprite1 (the red square) is hitting the platform from the left, so:


 sprite1_rightEdge>platformSprite leftEdge

would be true, so I can simply reposition sprite1 to align it with the left edge of the platform. So....


sprite1X=platformSpriteX-platformSpriteWidth

This is fine, however, lets say that sprite1 hits from the right, the problem I have here is that the first condition (above) is still true. So....


sprite1_rightEdge>platformSprite leftEdge

So my sprite1 still gets positioned at the left edge of the platform......



The same also happens in reverse....


Using velocity


I've had some success with velocity, but again I'm not clear on how this works properly.


For example, if I say something like:


if (Sprite1 moving right at time of collision)

Then I can assume it's hit the platform from the left. This works, but what if the sprite is 'falling' from the top and lands on the platform while also moving right? It will again get re-positioned at the left edge of the platform.


partial sucess


So far, I managed to get this working (although not fully implemented yet), by saving the old position of Sprite1, repositioning it and checking the old position, so if the old position was to the left of the platform, then I can assume it came in from the left.


If someone could let me know the best way to proceed it would be much appreciated.



Just to clarify what I'm asking - I have 2 objects - 1 is a platform and the other is the main character, I wish to make the player stop regardless of which side he hits the platform (from the top, bottom, left or right) - I will definitely be moving at distances of more than 1 px at a time).


I've attempted using velocity but this doesn't seem to work correctly as well as double checking x/y positions once a collision has happened but again I get some very off results. Some pseudo code of how to detect which side a sprite has hit would be much appreciated :-)


I have researched this and have seen pretty much every Q&A on this site regarding this subject (as far as I know) but the answers are either not relevant to my particular query or I simply don't understand them.


Original question


I understand the basic principles of collision detection for squares / rectangles


i.e.,


(Pseudo code)


public boolean testCollision(){



if (bottom of sprite1return false;

if(top of sprite1>bottom of sprite2)
return false;

if(left edge of sprite1 > right edge of sprite2)
return false;

if(right edge of sprite1 < left edge of sprite2)

return false;

return true;
}

I also know that I can stop my sprite going off the edge of the screen like so:


if(spriteX<0){spriteX=0};

However using something akin to the first method above for detecting collision between 2 specific objects, how can I make my 1st sprite actually stop so he can't pass through it?


At the moment, although I can detect when the two are touching, I'm unsure how to make it so that they can't actually pass through each other.



A push in the right direction would be a great help - thanks!



Answer



Demonstration:


Crude but functional collision detection and response


Video: https://vimeo.com/64923588


The idea is that the player controlled sprite (actually a 32x32 pixels red box) can raise the speed of its next move, but it cannot go back to original speed except if it collide with something. Also if speed is enough the green wall can be "damaged" until it finally is destroyed. Gravity can be disabled. This situation shows AABB in action.


In the video, the red text shows some game variables, penx y peny are the lengths of penetration vectors into each axis (of the player sprite into other objects).


T.x and T.y are the coordinates of the 2d vector that go from the center of a box to the one again it is tested. If you go for AABB as I recommend, you will need T.


The formula used for T is:


T = PlatformAABB.position - PlayerAABB.position


Vector from Platform to Player.


If you do not want to use an structure/class to represent vectors, then another option is to use separate variables for x and y elements:


Tx = platform.x - player.x
Ty = platform.y - player.y

Note that the position of each AABB is measured from its center, not from top, left corner. So if you are positioning your sprites like me, using left and top to mean the upper left corner of the rectangle containing the sprite, then you may need to calculate the AABB center like this: PlayerAABB.position.x = player.left + player.width / 2. And the same for y but replacing left for top and width for height.


Tx = (platform.left + platform.width / 2) - (player.left + player.width / 2)
Ty = (platform.top + platform.height / 2) - (player.top + player.height / 2)


If your x and y coordinates are taken from the center of each sprite then don't worry simply apply the first formula.


To detect if boxes overlap


if (absolute(T.x) > (currentSpr.width / 2) + (otherSpr.width / 2)) stop here;
if (absolute(T.y) > (currentSpr.height / 2) + (otherSpr.height / 2)) stop here;

Is enough to know that T is greater in one axis than the sum of the length of the two relevant half extents of each involved box to know that there is no overlapping. Then you can stop and assume no collision.


Logic to detect collision finalizes here for most games. If your objects are moving really fast, more than its width or height in a single game tick, then you will need a more complex method, like divide the movement in small steps (less than the box dimensions) and then do the collision check. Remember the previous position is useful for this.


What to do when colliding?


For the case of Player Sprite vs Platform. Assuming Platforms never move, whatever impacts them.


If collision is positive, then you will have to find penetration vector to move the player sprite back. We are using AABB to make that task simple. You want the sprite to remain in touch with the platform, not to go back to its previous position, that may be far away.



We already calculated T, and used it to find overlapping, now we will use it again:


Formula for penetration vectors lengths. (We don't know direction yet).


penx = (currentSpr.width / 2) + (otherSpr.width / 2) - absolute(T.x);
peny = (currentSpr.height / 2) + (otherSpr.height / 2) - absolute(T.y);

Now, we choose the lesser of them to displace the sprite back. If you want to understand why the lesser, do the opposite, run your program and have some fun watching the result.


And we need a direction too, we know that we are always axis aligned but we still have 2 choices, left or right, up or down.


if (peny <= penx)
{
if (T[1] < 0) spr1.top += peny;

else
if (T[1] > 0) spr1.top -= peny;
} else
{
if (T[0] < 0) spr1.left += penx;
else
if (T[0] > 0) spr1.left -= penx;
}

(formula edited to make it more readable)



I have to do some extra calculations because of the left, top, system. I hope this does not make it to look more complicated than it really is.


What to do when colliding to another thing than a platform?


Be creative. You can divide the penetration vector by 2 and displace both sprites but in opposite directions. Or simply destroy the player. Or think in something more complex. Articles for "friction" in games exists.


Notes:


To return absolute values in C++ use fabs() function. In javascript use Math.abs(). Other languages have their owns.


I think that you don't need a vector library for this, as only basic operations were used.


Depending how you iterate through objects in your scene, the player sprite will not always be at the left (currentSpr in the examples) and the platforms may not always be at the right (otherSpr) in the calculations, beware of not applying the penetration vector to a platform by mistake.


Original answer:


Save the previous position of the sprite before move to the next position is what I'm doing for my game and I see no shame on that. I like the solution.


Now that you have previous position and current position, the vector giving you the direction of movement when colliding with other non movable objects (platforms, walls) has its tail in current position, and its head in previous position.



The question that remains to be answered is how much the colliding object should retreat. You don't want it to move back to previous position in all cases, specially when the speed of a given movement is too high. You probably want the object to remain in contact to the platform without trespassing its borders.


The SAT (Separating Axis Theorem) is what I would use in this case:


1 - Find penetration vector using SAT


2 - Move the penetrating sprite back by apply the penetration vector


Please, see this: http://www.metanetsoftware.com/technique/tutorialA.html


For this specific problem read sections, 0, 1 and 2.


Separating Axis Theorem for AABBs is what you need for this specific case.


Note the case where two character sprites collide is another story. You can use SAT too for detect penetration vector, but you probably want some kind of physics acting in both sprites, and alter the position of both. Depending on the game, maybe destroy the player sprite is enough, in this case no penetration vector needed.


Friday, December 21, 2018

What type of document for game design?



What type of support/format do you use to store and diffuse your game design documentation? Wiki? Doc files? Files in Repository? Shared folder? Google Doc?


Please provide pros and cons for each one.



Answer



I'm using Google Docs because all I really need is a text editor that's online. I can collaborate with people online with relative ease and I know my information is secure there in case my computer crashes.


Another option worth looking at is using Dropbox. Drop a Word document in there and you instantly have a collaborative environment with version control.



mathematics - 2D helicopter game, how to create corridor walls?


I'm looking into adapting the classic "helicopter" game (i.e. http://www.addictinggames.com/helicopter.html), but I haven't yet figured out how to create the walls-generation engine.


Any pointers into the pseudocode? I'm not so interested in the objects in the middle- only the methodology for generating the sides in a way which increases with difficulty (closes in more, has more unexpected curves) as the game progresses.



Answer



You could use 1D Perlin noise for that. Here's an image of 2D noise. I took samples where the red line is and multiplied them with some constant to get the green line.


2D noise with 1D section


The constant you multiply the values with is going to determine the height of the noise. So you could easily ramp up the difficulty. Another benefit of Perlin noise is, that it can generate tileable noise, so that you can build a seemingly endless level.


If you want to create a bottom and a ceiling, it's important that you don't generate any impassable areas. The easiest way would simply be to use the "upper" part of the noise (eg. 1.0 - noiseValue) as ceiling and the lower part (noiseValue) for the bottom (with some offset in between of course). If that's looking too dull, you could also consider two close samples, eg. imagine another red sample line one or two pixels up or down. This will give a similar, but not identical wave.



subject verb agreement - 'Country have' vs 'country has'





1) Australia has won the World Cup Cricket.


2) Australia have won the World Cup Cricket.



Which sentence is correct? Also, I would like to know more contexts where 'country has' and 'country have' are used.



Answer



It depends on whether the speaker understands the team from Australia to be a plural or singular noun. I've answered this question in another context, here, but to reiterate:


"Many group nouns can take either take a singular or plural conjugation depending on the dialect of the speaker. These include things like band, group, and pair."


This use of Australia is metonymy, when a thing is referred to using a related noun that represents it. In this case, Australia represents the Australian team. A common use you may know is using "the White House" to mean the American government.


For something like metonymically referred-to countries, getting the actual values for which dialects use "are" or "is" is really hard, because there's no way to distinguish between meaning literally "the country of Australia" (which is always singular) and "the team/government/people of Australia" (which can be plural or singular).



In general, however, the UK and Ireland prefer "are" and the rest of the Commonwealth + America prefer "is" for nouns that can be plural or singular.


Here are a few examples of both usages:



Portugal have a great team on their hands. (i.e. the people of Portugal)
Sweden has passed a new law. (i.e. the Swedish government)
China have decided to withdraw from the treaty. (i.e. the Chinese government)
Rwanda has tied with Morocco. (i.e. the Rwandan team)



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