• What Are You Working On? - December 2014
    1,204 replies, posted
C standard says: [quote] If the value of argc is greater than zero, the string pointed to by argv[0] represents the program name; argv[0][0] shall be the null character if the program name is not available from the host environment. [/quote]
[img]http://i.imgur.com/TtLmScE.png?1[/img] Write a sort of game for ludum dare and get stucked by AI but learned alot. ~.~
You should be using wmain (in console apps), wstring and wchar_t on Windows. If you need to convert a wstring to utf8 or utf8 to wstring you can use the STL converter in <codecvt>. MAX_PATH also doesn't refer to a maximum path length in a Unicode configuration, 4096 is a number I usually use if I require a path buffer.
Dunno, I just felt like I could post some code for public use. I hope google spider picks this data up so it really becomes public. The code is used in Unity, so it might have Unity dependicies! This is code that extracts number from string which also contains text! I use it for numberating NPCs in the game (Unity3D), and the npcs are named like "1NPC", "NPC2", whatever, it just needs number somewhere. If no number found, it returns 0. [code] public static int GetNumber(this string text) { var regex = @"(\d+)"; var exp = new Regex(regex); // find a sequence of digits could be \d+ var matches = exp.Matches(text); if (matches.Count == 1) // if there's one number return that { int number = int.Parse(matches[0].Value); return number; } else if (matches.Count > 1) { Debug.LogError("ERROR"); return 0; } else return 0; } [/code] String interpolation! Interpolate between strings with interval [0..1]. [code] public static string strlerp(string from, string to, float value){ //extremely fast PCs breed inefficient algorithms List<char> newStr = new List<char>(); int len = (from.Length > to.Length) ? from.Length : to.Length; for (int i = 0; i < len; i++){ //both is default space char str1chr = ' '; char str2chr = ' '; //from char if(i < to.Length) str2chr = to[i]; //to char if (i < from.Length) str1chr = from[i]; char resultchr = (char)(int)Mathf.Lerp((float)str1chr, (float)str2chr, value); newStr.Add(resultchr); } //clears spaces at end :) return new string(newStr.ToArray()).TrimEnd(new char[]{' '}); } [/code] Apply lambda / anonymous function recursively on game objects. This means you can Oh, this one extends GameObject.. :) [code] public delegate void gameObjectDelegate(GameObject go); static public void ApplyRecursively(this GameObject gObject, gameObjectDelegate GameObjectAction) { GameObjectAction(gObject); for (var i = 0; i < gObject.transform.childCount; i++) { var child = gObject.transform.GetChild(i); child.gameObject.ApplyRecursively(GameObjectAction); } } [/code] Pick random object between the two, you input two options and it returns one of two. [code] public static T PickRandom<T>(T _1, T _2) { var random = Random.value; if (random > 0.5f) return _1; return _2; } [/code] Hope, it is useful for anyone :)
Making some real progress on my character models. [img]http://i.imgur.com/ZHU8rNm.png[/img]
[QUOTE=cartman300;46660569][img]http://i.imgur.com/ySvO4an.png[/img] Finally! (this time without using freetype, but with C#'s built in Graphics) Now if only when i made the window fullscreen borderless, OpenTK didn't make the viewport a bit smaller than the client size.[/QUOTE] Have fun with measuring strings.
[QUOTE=Darwin226;46662737]Have fun with measuring strings.[/QUOTE] ??? [img]http://i.imgur.com/U6ADX0f.png[/img] [code] Vector2 Sz = Txt.MeasureString("Hello World!"); Txt.Print("Hello World! - W" + Sz.X + " H" + Sz.Y, Color.White); Txt.Print("0123456789", Color.White, Sz); [/code]
[QUOTE=esalaka;46631462]I guess it's technically not programming, but I can't see any other suitable place to complain about TeX. It produces lovely output but goddamn is it awful to write. [editline]4th December 2014[/editline] I'm writing something for school and as it involves formulae and graphs and MikTeX is pretty much the only suitable software package I had installed, I'm using LaTeX.[/QUOTE] This is extremely late, but [URL="http://www.lyx.org/"]Lyx[/URL] is a pretty good LaTeX WYSIWYG editor.
[QUOTE=cartman300;46662797]??? [img]http://i.imgur.com/U6ADX0f.png[/img] [code] Vector2 Sz = Txt.MeasureString("Hello World!"); Txt.Print("Hello World! - W" + Sz.X + " H" + Sz.Y, Color.White); Txt.Print("0123456789", Color.White, Sz); [/code][/QUOTE] Did you have fun though?
[QUOTE=Berkin;46662710]Making some real progress on my character models. [img]http://i.imgur.com/ZHU8rNm.png[/img][/QUOTE] Berking, what the hell, you just cannot be un-funny.
[QUOTE=ECrownofFire;46640812]Same argument applies.[/QUOTE] No it doesn't. Consider libraries under the LGPL, if the whole thing has to be recompiled users can't patch the library themselves if there's an update.
[thumb]http://i.imgur.com/EHM63lE.png[/thumb] Implementing WinForms as OpenGL GUI library because why the fuck not.
[QUOTE=cartman300;46662797]??? [img]http://i.imgur.com/U6ADX0f.png[/img] [code] Vector2 Sz = Txt.MeasureString("Hello World!"); Txt.Print("Hello World! - W" + Sz.X + " H" + Sz.Y, Color.White); Txt.Print("0123456789", Color.White, Sz); [/code][/QUOTE] Good. Now render Arabic.
[QUOTE=Fourier;46663060]Berking, what the hell, you just cannot be un-funny.[/QUOTE] Adding this to my resume: [I]"SKILLS: I'm so funny, a mathematician who has been dead for 184 years rose from his grave to tell me how hilarious I am."[/I]
[QUOTE=ECrownofFire;46663335]Good. Now render Arabic.[/QUOTE] [IMG]http://nabile.duckdns.org/media/Arabic%20font%20rendering.png[/IMG] [sp]I'm also using System.Drawing.[/sp]
[QUOTE=cartman300;46662797]??? [img]http://i.imgur.com/U6ADX0f.png[/img] [code] Vector2 Sz = Txt.MeasureString("Hello World!"); Txt.Print("Hello World! - W" + Sz.X + " H" + Sz.Y, Color.White); Txt.Print("0123456789", Color.White, Sz); [/code][/QUOTE] Sooner or later. You'll see. (I can't remember what's wrong with it, but there certainly is something)
Gave up on the winforms gui thingie (input is a bitch), interesting concept though. Anybody know any good modern OpenGL compatible GUI libraries that aren't GWEN?
Try spaces at the end
[img_thumb]http://i.imgur.com/31SLSt5.png[/img_thumb] I saw Duktape on HN and decided it'd be neat to try and do something a bit like I did for TCC ([url]https://github.com/benpye/TCCSharp/[/url]). ~180 P/Invoke signatures later and I have their example running, though it's hardly usable.
[QUOTE=Nabile13;46663501][IMG]http://nabile.duckdns.org/media/Arabic%20font%20rendering.png[/IMG] [sp]I'm also using System.Drawing.[/sp][/QUOTE] That doesn't look right though. The characters should be run together in a smooth line, not separated like that.
So I'm sure you guys remember that crazy messy code diagram I posted here a while back? Well, I just [URL="https://github.com/Sidneys1/StackingEntities/releases"]marked the first release on GitHub[/URL]. Not sure if any of you play Minecraft, but I would definitely appreciate feedback and bug reports :D
[QUOTE=Nabile13;46663501][IMG]http://nabile.duckdns.org/media/Arabic%20font%20rendering.png[/IMG] [sp]I'm also using System.Drawing.[/sp][/QUOTE] 90% this is wrong, arabic goes from right to left
Playing with sines and cosines [img]http://i.imgur.com/bDPya56.png[/img] [code] #INCLUDE "fbgfx.bi" USING FB SCREENRES 800,800,8 FOR I AS INTEGER = 0 TO 20 FOR Q AS DOUBLE = 1 TO 26.5 STEP 0.0001 LINE((COS(Q/4)*(I*10))+400,(SIN(Q/4)*(I*10))+400)-(((COS(Q/4)*((I*10)+10))+400),(SIN(Q/4)*((I*10)+10))+400),I+39 NEXT NEXT SLEEP [/code] [img]http://i.imgur.com/Du73rKT.png[/img] [code] #INCLUDE "fbgfx.bi" USING FB SCREENRES 800,800,8 FOR I AS INTEGER = 0 TO 20 FOR Q AS DOUBLE = 1 TO 26.082 STEP 0.0001 LINE((COS(Q/4)*(I*10))+400,(SIN(Q/4)*(I*10))+400)-(((COS(Q/4)*((I*10)+5))+400),(SIN(Q/4)*((I*10)+5))+400),I+39 NEXT NEXT SLEEP [/code] [img]http://i.imgur.com/mDAlVbz.png[/img] [code] #INCLUDE "fbgfx.bi" USING FB SCREENRES 800,800,8 FOR I AS INTEGER = 0 TO 20 FOR Q AS DOUBLE = 1 TO 26.082 STEP 0.0001 LINE((COS(Q/4)*(I*10))+400,(SIN(Q/4)*(I*10))+400)-(((COS(Q/4)*((I*10)))+400),(SIN(Q/4)*((I*10)))+400),I+39 NEXT NEXT SLEEP[/code] Not sure about this one... [img]http://i.imgur.com/qKbnqqP.png[/img] [code] #INCLUDE "fbgfx.bi" USING FB SCREENRES 800,800,8 FOR I AS INTEGER = 0 TO 20 FOR Q AS DOUBLE = 1 TO 26.5 STEP 0.0001 LINE((COS(Q/4)*(I*10))+400,(SIN(Q/4)*(I*10))+400)-(((COS(Q/4)*((I*10)))+400),(SIN(Q/4)*(((I*10)+(I/10)+400)))),I+39 NEXT NEXT SLEEP [/code]
[QUOTE=Bumrang;46664109]90% this is wrong, arabic goes from right to left[/QUOTE] Copy-pasting from Firefox to VS messed up the exclamation mark position for some reason. I had already taken the screenshot when I noticed it. Compare the pic with this: [URL]https://translate.google.com/#en/ar/Hello%20world![/URL]
[img]http://i.imgur.com/y8Wal1m.png[/img]
[QUOTE=Nabile13;46664137]Copy-pasting from Firefox to VS messed up the exclamation mark position for some reason. I had already taken the screenshot when I noticed it. Compare the pic with this: [URL]https://translate.google.com/#en/ar/Hello%20world![/URL][/QUOTE] You still have the wrong positioning :v:
[QUOTE=proboardslol;46664209][img]http://i.imgur.com/y8Wal1m.png[/img][/QUOTE] My retinas itch.
[QUOTE=proboardslol;46664209][img]http://i.imgur.com/y8Wal1m.png[/img][/QUOTE] Now as a seamless tiling texture: [url]https://dl.dropboxusercontent.com/u/8478604/Tiling%20descent%20into%20madness.png[/url]
[QUOTE=ECrownofFire;46664266]You still have the wrong positioning :v:[/QUOTE] Better now ? :v: [IMG]http://nabile.duckdns.org/media/Arabic.png[/IMG]
[QUOTE=Crayz;46658090]Whipped up a basic RTS scene today in unity [url]https://dl.dropboxusercontent.com/u/96502721/S/2014-12-06-2131-55.mp4[/url] Might keep working on it, kinda fun.[/QUOTE] Added formation control after realizing the solution isn't that complex. Find the midpoint of all units currently selected, find the offset of each unit's position from the midpoint, alter the unit's destination by that offset. [url]https://dl.dropboxusercontent.com/u/96502721/S/formation.mp4[/url]
Sorry, you need to Log In to post a reply to this thread.