• What are you working on? v16
    5,004 replies, posted
So I wanted to be able to write to the console while still reading input without it blocking or writing over itself, and it got a bit out of hand. [img]http://i.cubeupload.com/poRJfL.png[/img] [cpp] #include "Console.hpp" #include "Command.hpp" void Help( Console* ccDebug, char** Args, char Argc ) { // Printa and Printaf (a is for attribute, f is for format), allows you to change the color of any future character using colors encased in square brackets. ccDebug->Printa( "Sorry [lime]buddy.\n\n\t[white]No [red]help [white]here!\n\n" ); } int main() { // Sets up the console so we can write all kinds of fancy things, and do so in different threads. Console* Con = new Console(); // Console command handler Command* Cmd = new Command( Con ); Cmd->AddCommand( "help", Help ); char sCmd[256]; while( true ) { // Read the console input if there is any into sCmd. This function is non-blocking. // It also handles scrolling and whatnot. if( Con->Read( sCmd ) ) { // Send the input to the console command handler that looks it up and calls it, if found. Cmd->Input( sCmd ); } } return 0; } [/cpp]
I have a IntPoint struct that is the same as Point except it only handles ints and I made a function that checks if two points are next to each other. [csharp] public bool Adjecent ( IntPoint Point ) { var temp = this - Point; temp.ToAbsolute(); return ( temp.x == 1 ^ temp.y == 1 ); }[/csharp] I think that's quite nice looking :D Edit: Needed to change it to this: [csharp] return ( ( temp.x == 1 && temp.y == 0 ) ^ ( temp.y == 1 && temp.x == 0 ) );[/csharp] Now it's ugly :(
Just some shit I'm making while in class: C# by the way. [code]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication12 { class Program { static void Main() { Console.WriteLine("Here, some random numbers for you."); Console.WriteLine(); Console.WriteLine(); Random r1 = new Random(123789); Random r2 = new Random(123456); Random r3 = new Random(123123); Random r4 = new Random(789123); Random r5 = new Random(456123); Random r6 = new Random(321123); Random r7 = new Random(654123); Random r8 = new Random(987123); Console.Write("Number-line 1: "); for (int i=1; i<=5; i++) Console.Write(r1.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 2: "); for (int i=1; i<=5; i++) Console.Write(r2.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 3: "); for (int i = 1; i <= 5; i++) Console.Write(r3.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 4: "); for (int i = 1; i <= 5; i++) Console.Write(r4.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 5: "); for (int i = 1; i <= 5; i++) Console.Write(r5.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 6: "); for (int i = 1; i <= 5; i++) Console.Write(r6.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 7: "); for (int i = 1; i <= 5; i++) Console.Write(r7.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 8: "); for (int i = 1; i <= 5; i++) Console.Write(r8.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Say thanks."); Console.ReadLine(); } } } [/code]
[QUOTE=jomt1234;28543778]Just some shit I'm making while in class: C# by the way. [code]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication12 { class Program { static void Main() { Console.WriteLine("Here, some random numbers for you."); Console.WriteLine(); Console.WriteLine(); Random r1 = new Random(123789); Random r2 = new Random(123456); Random r3 = new Random(123123); Random r4 = new Random(789123); Random r5 = new Random(456123); Random r6 = new Random(321123); Random r7 = new Random(654123); Random r8 = new Random(987123); Console.Write("Number-line 1: "); for (int i=1; i<=5; i++) Console.Write(r1.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 2: "); for (int i=1; i<=5; i++) Console.Write(r2.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 3: "); for (int i = 1; i <= 5; i++) Console.Write(r3.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 4: "); for (int i = 1; i <= 5; i++) Console.Write(r4.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 5: "); for (int i = 1; i <= 5; i++) Console.Write(r5.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 6: "); for (int i = 1; i <= 5; i++) Console.Write(r6.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 7: "); for (int i = 1; i <= 5; i++) Console.Write(r7.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.Write("Number-line 8: "); for (int i = 1; i <= 5; i++) Console.Write(r8.Next() + " "); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Say thanks."); Console.ReadLine(); } } } [/code][/QUOTE] You should read up on arrays, they make things like these a lot easier: [cpp] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main() { int[] Numbers = { 123789, 123456, 123123, 789123, 456123, 321123, 654123, 987123 }; Random[] Randoms; Randoms = new Random[8]; for (byte i = 0; i < 8; i++) { Randoms[i] = new Random(Numbers[i]); } Console.WriteLine("Here, some random numbers for you.\n"); for (byte k = 0; k < 8; k++) { Console.WriteLine("\nNumber-line " + k + ": "); for (byte i = 0; i <= 5; i++) { Console.WriteLine(Randoms[k].Next() + " "); } } Console.WriteLine("\n\nSay thanks."); while (Console.ReadLine() != "Thanks") { Console.WriteLine("Ahem.."); } } } } [/cpp]
You could make that run faster by using 32/64 bit types (depends on your data bus size).
[QUOTE=Tangara;28540950].NET Expression trees are incredibly awesome. I've never used them before, but it took literally 10 minutes to implement compilation in Tangaraular Grapher with them [img_thumb]http://ahb.me/25KT[/img_thumb][/QUOTE] Hi.
[QUOTE=DarkCybo7;28540220]Full in-game intro/teaser for my 2D C++/SDL/OpenGL/GLSL/Lua/FMOD/FreeType/Boost extravaganza. [media]http://www.youtube.com/watch?v=zUmzlxN5OnQ[/media] Whole intro was scripted in Lua and then parsed by the game.[/QUOTE] Nice, are you making any tutorials on your blog? BTW mind linking me to it i can never find it
Working on some more of my book. It has me parse and translate a stack-based vm language to an assembly language. Currently parsing is done, now for the translating.
While ago I tried to use Farseer Physics with SFML and I had problems with stuff being out of place. I gave up because I couldn't fix it. Today, after a month since I last time worked on it, I decided to give another shot on it. After 1 hour I finally managed to fix it. :)
[img]http://dl.dropbox.com/u/1085379/itsacruelworld.PNG[/img] Here's a screenshot of a platformer me and a partner pair programmed as part of our Java coursework over the last 2 weeks.
[QUOTE=Randdalf;28548538][img_thumb]http://dl.dropbox.com/u/1085379/itsacruelworld.PNG[/img_thumb] Here's a screenshot of a platformer me and a partner pair programmed as part of our Java coursework over the last 2 weeks.[/QUOTE] I just love that style of games.
[QUOTE=bootv2;28547388]Are you creating a D.R.O.D. remake? it is just so D.R.O.D.-like. I like it.[/QUOTE] Yeah it's DROD. I can't find a good way to implement tunnels :(
Anyone know about TCP hole punching? I have seen some games/programs do p2p without needing a port forwarded and was wondering if they did that or something else?
[QUOTE=Richy19;28546025]Nice, are you making any tutorials on your blog? BTW mind linking me to it i can never find it[/QUOTE] [url]http://dev.gaminghigh.com/[/url] He's not written any tutorials afaik, but his blog posts are still entertaining :v:
[QUOTE=high;28548857]Anyone know about TCP hole punching? I have seen some games/programs do p2p without needing a port forwarded and was wondering if they did that or something else?[/QUOTE] I thought hole punching only worked for UDP o_O
Hole punching only works for UDP. You can't do it with TCP because the port closes as soon as you finish sending the data to the common server.
You could use UPnP but that almost never works properly.
[QUOTE=esalaka;28549515]I thought hole punching only worked for UDP o_O[/QUOTE] [url]http://en.wikipedia.org/wiki/TCP_hole_punching[/url] Apparently it does unless I'm reading it wrong.
About that console.. [IMG]http://i.cubeupload.com/OxNG1W.png[/IMG] It's a little cryptic, but it does make sense.
[QUOTE=high;28549780][url]http://en.wikipedia.org/wiki/TCP_hole_punching[/url] Apparently it does unless I'm reading it wrong.[/QUOTE] YESSSSSS! Please say if you find anything more on this. And could someone explain to me what are the advantages of using auto-implemented properties in C#? The way I see it, it's just a public field with some extra letters. If I use normal accessors it's useful because I can do some extra stuff when getting and setting private fields but when I use the auto-implemented ones I can't do that since it automatically generates return privateVar and privateVar = value.
[QUOTE=Darwin226;28550116]YESSSSSS! Please say if you find anything more on this. And could someone explain to me what are the advantages of using auto-implemented properties in C#? The way I see it, it's just a public field with some extra letters. If I use normal accessors it's useful because I can do some extra stuff when getting and setting private fields but when I use the auto-implemented ones I can't do that since it automatically generates return privateVar and privateVar = value.[/QUOTE] My guess is its for libraries. That way if you ever want to add an accessor/mutator you can without breaking the programs that use it.
How does changing a public field into a private one and an accessor break the programs?
[QUOTE=Darwin226;28550580]How does changing a public field into a private one and an accessor break the programs?[/QUOTE] Because the program that uses it would be bound to a field and not to a property.
[QUOTE=Kopimi;28548998][url]http://dev.gaminghigh.com/[/url] He's not written any tutorials afaik, but his blog posts are still entertaining :v:[/QUOTE] Im sure h ha a different one, or one specifically for huey
[QUOTE=Kopimi;28548998][url]http://dev.gaminghigh.com/[/url] He's not written any tutorials afaik, but his blog posts are still entertaining :v:[/QUOTE] I haven't really written anything educational in a while on it, or anything at all really. But I may later. I'm contemplating remaking the whole style
[QUOTE=Darwin226;28550580]How does changing a public field into a private one and an accessor break the programs?[/QUOTE] Fields and properties are not binary compatible. The code is the same but the generated IL is different. If you use properties and decide to change the getter/setter, you don't need to update any binaries dependent on it.
[QUOTE=Darwin226;28550116]YESSSSSS! Please say if you find anything more on this. And could someone explain to me what are the advantages of using auto-implemented properties in C#? The way I see it, it's just a public field with some extra letters. If I use normal accessors it's useful because I can do some extra stuff when getting and setting private fields but when I use the auto-implemented ones I can't do that since it automatically generates return privateVar and privateVar = value.[/QUOTE] You can also do this, which is kinda cool and saves time: [csharp]public int ReadOnlyProperty { get; protected set; }[/csharp]
[IMG]http://i.imgur.com/3efpJ.png[/IMG] Finaly.. after a huge struggle, got block updates working, and water.. next step lava, then redwire... the water flows like notch's server, and if you murder the source, it dies out
[QUOTE=bromvlieg;28552077][img_thumb]http://i.imgur.com/3efpJ.png[/img_thumb] Finaly.. after a huge struggle, got block updates working, and water.. next step lava, then redwire... the water flows like notch's server, and if you murder the source, it dies out[/QUOTE] Is it supposed to do that? I don't know much about Minecraft and that seems kind of odd.
[QUOTE=geel9;28552114]Is it supposed to do that? I don't know much about Minecraft and that seems kind of odd.[/QUOTE] Yep, it does.
Sorry, you need to Log In to post a reply to this thread.