Saturday, November 17, 2018

iphone - Creating 2D waveform for Cocos2d game


I'd like to have a Waveform in my iPhone game that I am developing using Cocos2d v2.0.


Example Waveform


That's the ideal wave I'd like to achieve. A simpler wave which I would still be happy with is this one.


Example 2


Some people suggested me to use ParticleEffects ands ParticleDesigners like 71squared but I am not sure that this is the right approach.



Brainstorming, I think that at the end a wave is a plot of some function, and at each frame translate the wave points that where from the origin apart (-x and +x) and computes new wave points for the origin.


Something like this:


for (duration of effect)
compute wave point intensity at origin and display it
and
for each wave point before the center translate to -x and display it
and after the center translate to +x and display it

Let me know what you think and if you have any better solution. I was thinking to achieve the display point by colouring a particular pixel but I need to figure out how :)..



Answer




I asked the question also on the cocos2d-iphone forum and someone kindly replied. I thought I would share his answer to avoid duplicate effort:


Answer


I haven't yet tried them because I am struggling deciding what to learn first ES 1.0 vs ES 2.0 as I have just migrated my code to Cocos2d v2.0 and I don't fully understand all the implications, but judging Apple's AurioTouch example posted in the answer it looks promising.


xna - How do I draw non-smoothed fonts in MonoGame 3.5?


I don't want to smooth the tiny fonts I'm building but even disabling ClearType system wide doesn't let me create SpriteFont files with sharp characters. There doesn't seem to be an option for smoothing in the .spritefont file I could set to "disabled". Are there any configs that affect how spritefonts are generated?


I'm using MonoGame 3.5 with Visual Studio 2015 and building the spritefonts via Content.mgcb thing that is added automatically into a MonoGame project.


I tried using Give Your Fonts Mono(spacing) tool but it doesn't have an option to disable smoothing.



Trying to follow this tutorial with BMFont generator and added the reference in the example, but the MonoGame.Extended thing doesn't appear and instead of automatically recognized importer I get [missing] [null]. After that I tried adding some other packages that come with MonoGame pipeline DLLs but no luck.


Tried to use XNA Content Compiler but it throws me an exception with some important object contentBuilder being null. Installing XNA framework doesn't fix the issue.


If there are ways to draw text without using SpriteFonts that allow to use non-smoothed characters, I'd like to know how.




Friday, November 16, 2018

verb forms - scissors cut/cuts paper, which is correct?



First I'd apologize for I can't describe it clearly. I've heard that "scissors cut paper" is correct, but I found Sheldon said "scissors cuts paper" in The Big Bang Theory. Which is correct, or both of them?




Windows Form code not executing?


Ok, I've got a weird one here. I'm trying to make a basic tile engine using a windows form, but some of my code is just...not happening. I'll post the chunks in question.


private void MapEditor_Load(object sender, EventArgs e)
{
LoadImageList();
FixScrollBarScales();
cboCodeValues.Items.Clear();
cboCodeValues.Items.Add("ENEMY");
cboCodeValues.Items.Add("CHEST");
cboCodeValues.Items.Add("NPC");


for (int x = 0; x < 100; x++)
cboMapNumber.Items.Add(x.ToString().PadLeft(3, '0'));

cboMapNumber.SelectedIndex = 0;
TileMap.EditorMode = true;
backgroundToolStripMenuItem.Checked = true;
}

This should be called when the form loads, right? The code dives into LoadImageList(), which contains:



private void LoadImageList()
{
string filepath = Application.StartupPath + @"\Content\Textures\IndoorTileSet.png";
Bitmap tileSheet = new Bitmap(filepath);
int tilecount = 0;
for(int y = 0; y < tileSheet.Height / TileMap.TileHeight; y++)
{
for(int x = 0; x < tileSheet.Width / TileMap.TileWidth; x++)
{
Bitmap newBitmap = tileSheet.Clone(new System.Drawing.Rectangle(x * TileMap.TileWidth, y * TileMap.TileHeight,

TileMap.TileWidth, TileMap.TileHeight), System.Drawing.Imaging.PixelFormat.DontCare);
imgListTiles.Images.Add(newBitmap);
string itemName = "";
if(tilecount == 0)
itemName = "Empty";
if(tilecount == 1)
itemName = "Floor";
listTiles.Items.Add(new ListViewItem(itemName, tilecount++));
}
}

}

The bitmap loads correctly, but then the entire MapEditor_Load method just stops working. tileCount seems to be a local variable in the debugger, and its value is 0, but the debugger never executes the breakpoint on the line which it is assigned. I have absolutely no idea why it would do this, and it's driving me nuts. Any help? Oh, I put the bitmap load in a try/catch block just to see if it was handling an exception in a weird way, but I had no luck. It's not throwing an exception. I began having this problem immediately after replacing my IndoorTileSet with an updated version.




Google leaderboards, up to a maximum of 70?


I see in the doc that the limit for the number of leaderboards on Google Play Services is 70. However, I am able to create more than 70 leaderboards and they are all working when I test my app. Is this limit still up to date? Does this mean that if I publish my game some of the leaderboards will be deactivated or something?



Thank you in advance if you know the answer. I just want to make sure of what I can expect for when I publish my game.



Answer



Since the documentation says the limit is 70, you should rely on the limit being 70. That's about as official as you can get, in the general case.


To do otherwise is to rely on undocumented behavior that may only work during development or local testing -- such things are typical, for example you may be able to create more than 70 for testing purposes or over the lifetime of your application but can only have 70 active on the live services at a time. This facilitates debugging or retiring older leaderboards in favor of newer ones, et cetera.


Trying to have more will likely result in the extras being disabled, or possibly prevent your app from being available until the issue is corrected.


java - How can I move an object towards another along a straight line


How can I move an object (like a cube) towards another object?


Let's say that we have a red cube in the center of a floor, and a blue cube in another location, there aren't objects between this two, so the movement is along a line.


How can I move the blue cube towards the red one?



Answer




A basic solution to this problem, given the two positions of the objects (A and B):



  • Compute the normalized direction vector from A to B: v = normalize(B - A).

  • Every game logic update, add that vector v (scaled by the desired object speed) to the position of A: A += v * speed.

  • Stop doing this when A is within some desired tolerance of B.


A simple implementation of this might involve storing "movement destination" point with each object, representing where it is trying to get each frame. Apply the above logic every frame in the object's update method (pseudocode):


if (target is assigned && !position.isWithinToleranceOf(target)) {
v = normalize(target - position)
position += speed * elapsedTime * v;

}

A more involved solution would involve abstracting out the movement destination and handling into a more generic "orders" object which can be associated with an in-game entity, allowing you to build "movement order" objects and "attack order objects," all of which could be assigned to various in-game objects.


Choice of punctuation: Which is easier for the native speaker to read


Which of these sentences is easier to read and understand for the native speaker? I guess it should also be the most correct of these options. Please note that the question is directed at the punctuations here.


Option A


Looking into recent trends in engineering literature, advances in mechatronics; commerce and trade; agric and chemical engineering are expected to present new challenges thereby opening further opportunities.




Option B


Looking into recent trends in engineering literature, advances in mechatronics, commerce and trade, agric and chemical engineering are expected to present new challenges thereby opening further opportunities.




Option C



Looking into recent trends in engineering literature; advances in mechatronics, commerce and trade, agric and chemical engineering are expected to present new challenges thereby opening further opportunities.


Note: I would like to refer to commerce and trade as a single entity



Answer



Your sentence is very difficult to understand. I may have misunderstood it. But that's your fault, not mine. I would start over.


C is wrong. The clause that begins with Looking... is not a finite clause that can stand on its own as an independent clause, which is required when using the semi-colon to separate clauses.


A is wrong for the same reason.


B is best but not perfect.


The main clause is



public health and chemical engineering are expected to present new challenges




The preposition into has a list of items as its objects:



... recent trends in engineering literature, advances in mechatronics, commerce and trade



That last item should have an and before it:



... trends in engineering literature, advances in mechatronics, and commerce and trade



P.S. You could make it clearer by repeating the governing prepositions:




When we look at recent trends in engineering literature and at advances in mechatronics and in commerce and trade, it is clear that public health and chemical engineering will present new challenges, thereby opening further opportunities.



But I'm still not quite sure of the logic of the sentence: public health seems to come out of nowhere.


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