• What are you working on? v16
    5,004 replies, posted
[QUOTE=The Inzuki;28376214]I would also like a nice cave/terrain generating algorithm, if anyone would be kind enough to show me one.[/QUOTE] The cave generator I have uses [url=http://pixelenvy.ca/wa/ca_cave.html]cellular automata[/url]. [editline]1st March 2011[/editline] [QUOTE=BlkDucky;28374272]If you remove all of the individual blocks that stand out on their own it would look more natural.[/QUOTE] Done. It looks a lot nicer, thanks. I limited the FOV, so it runs faster, but it runs a little too fast (like noclip in GMod vs. normal walking). I also need to figure out how to render the enemies while they're on the screen.
I was thinking of making a text-based adventure game for my mom for Mother's Day. She's a programmer, so I think she'd really like a program like that. I also just thought of making an infinite loop that says "I love you! Happy Mother's Day!"
[QUOTE=HiredK;28364772]OBJ loading again (scaling and uv this time) [img_thumb]http://i56.tinypic.com/2ef0s2o.png[/img_thumb][/QUOTE] Ogod yes Ocarina of Time
[QUOTE=Penultimate;28377219]I was thinking of making a text-based adventure game for my mom for Mother's Day. She's a programmer, so I think she'd really like a program like that. I also just thought of making an infinite loop that says "I love you! Happy Mother's Day!"[/QUOTE] Ok. [code] @echo off :start cls echo I love you! @ping 127.0.0.1 -n 2 -w 10 > nul @ping 127.0.0.1 -n %1% -w 10> nul cls echo Happy Mother's Day! @ping 127.0.0.1 -n 2 -w 10 > nul @ping 127.0.0.1 -n %1% -w 10> nul goto :start [/code] paste in notepad > Save as: whatever.bat, and save as "all files" > put on her desktop edit: Hey. Why the dumb's?
Enemies and wall collisions work. I still need to fix the problem with going too fast since it's going to cause controllability problems. Right now, I'm testing out enemy movement. [media]http://i920.photobucket.com/albums/ad43/Portal2121/enemies.png[/media]
[QUOTE=Penultimate;28377219]I was thinking of making a text-based adventure game for my mom for Mother's Day. She's a programmer, so I think she'd really like a program like that. I also just thought of making an infinite loop that says "I love you! Happy Mother's Day!"[/QUOTE] Your mom's a programmer? [u]Dude[/u]
92 line one-time pad encryption/decryption algorithm. [code] import java.util.Scanner; import java.io.FileInputStream; import java.io.FileOutputStream; import java.security.MessageDigest; import java.util.Arrays; public class Main { public static void main(String[] args) { try { System.out.println("Enter E to encrypt, or D to decrypt."); Scanner in = new Scanner(System.in); char choice = in.next().toLowerCase().charAt(0); switch (choice) { case 'd': System.out.println("Decrypting 'ciphertext.txt' with 'key.txt'"); decrypt(); System.out.println("Decrypted!"); break; case 'e': System.out.println("Encrypting 'in.txt'"); encrypt(); System.out.println("Encrypted!"); break; default: System.out.println("Invalid choice. Exiting."); break; } in.close(); } catch (Exception e) { e.printStackTrace(); } } private static void encrypt() throws Exception { FileInputStream fis = new FileInputStream("in.txt"); byte[] data = new byte[fis.available()]; fis.read(data); fis.close(); byte[] hash = new byte[data.length]; int numFrames = (int)Math.ceil((double)data.length/64d); //how many times do we need to hash MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); //64 byte output (or 512 bits) for (int frame=0;frame<numFrames;frame++) { int start = frame*64, end = Math.min(start+64, data.length); byte[] frameData = Arrays.copyOfRange(data, start, end); byte[] digestData = sha512.digest(frameData); System.arraycopy(digestData, 0, hash, start, frameData.length); } FileOutputStream keyFos = new FileOutputStream("key.txt"); keyFos.write(hash); keyFos.close(); byte[] cipherText = Arrays.copyOf(data, data.length); for (int i=0;i<hash.length;i++) cipherText[i] -= hash[i]; FileOutputStream cipherTextFos = new FileOutputStream("ciphertext.txt"); cipherTextFos.write(cipherText); cipherTextFos.close(); } private static void decrypt() throws Exception { FileInputStream cipherTextFis = new FileInputStream("ciphertext.txt"); byte[] cipherTextData = new byte[cipherTextFis.available()]; cipherTextFis.read(cipherTextData); cipherTextFis.close(); FileInputStream keyFis = new FileInputStream("key.txt"); byte[] keyData = new byte[keyFis.available()]; keyFis.read(keyData); keyFis.close(); byte[] outData = Arrays.copyOf(cipherTextData, cipherTextData.length); for (int i=0;i<keyData.length;i++) outData[i] += keyData[i]; FileOutputStream outFos = new FileOutputStream("out.txt"); outFos.write(outData); outFos.close(); } } [/code] I figure it's not nearly as secure as a commercial algorithm--but it's as secure as SHA-512. Which is apparently pretty secure. The basic idea is that the key and ciphertext are the same size as the plaintext file. It works flawlessly. Encrypted a 50 megabyte file in 6 seconds, decrypted in less than one second.
Just rolled out this bitchin' menu system, based on the one I made for Grid. [img]http://f.anyhub.net/1_C7[/img] I almost gave up due the amount of methods I'd need to write for each menu, blah, blah blah... Then I found out about anonymous delegates. :pcgaming: [editline]1st March 2011[/editline] Also, new skin that took an hour to make, featuring wrapping diagonal lines. It took quite a lot of work to get them to line up, but it's worth it. :downs:
I'm working on a Json parser for C++. How does it look? [cpp] #include <Jzon.h> int main() { Jzon::Object root; root.Add("name", Jzon::Value("value")); root.Add("number", Jzon::Value(20)); root.Add("anothernumber", Jzon::Value(15.3)); root.Add("stuff", Jzon::Value(true)); Jzon::Array listOfStuff; listOfStuff.Add(Jzon::Value("json")); listOfStuff.Add(Jzon::Value("more stuff")); listOfStuff.Add(Jzon::Value()); listOfStuff.Add(Jzon::Value(false)); root.Add("listOfStuff", listOfStuff); Jzon::FileWriter::WriteFile("file.json", root); return 0; } [/cpp] Result: [code] { "name": "value", "number": 20, "anothernumber": 15.3, "stuff": true, "listOfStuff": [ "json", "more stuff", null, false ] } [/code] (I manually formatted the result) So, generating is basically done and I've just finished parsing, but I'm still working on the interface for getting values.
[QUOTE=Penultimate;28377219]I was thinking of making a text-based adventure game for my mom for Mother's Day. She's a programmer, so I think she'd really like a program like that. I also just thought of making an infinite loop that says "I love you! Happy Mother's Day!"[/QUOTE] [code]while(true) MessageBox(0, (LPCWSTR)L"Happy Mothers Day!", (LPCWSTR)L"Hey!", MB_OK);[/code]
Has anyone here used TCL before? I'm trying to play with the [url=http://wiki.tcl.tk/21708]bubble-generator program[/url] that was written to generate the syntax diagrams for sqlite, but it's an absolute brain fuck. The exact same syntax, in two different locations: one generates an error, and one generates my desired output. :downs:
Wrote a tokenizer [code]--input: Int a = 42 Int aA/*comment*/==4/*heh*/2 //another comment Int Nothin --output: Keyword: Int Identifier: a Operator: = Literal: 42 ExpressionEnd: Keyword: Int Identifier: aA Operator: == Literal: 4 Literal: 2 ExpressionEnd: Keyword: Int Identifier: Nothin ExpressionEnd: [/code] So far so good :unsmith:
This is how you read Json files with my parser.. [cpp] #include <Jzon.h> #include <iostream> int main() { Jzon::NodePtr rootNode = Jzon::FileReader::ReadFile("file.json"); Jzon::Array &stuff = rootNode->AsObject().Get("listOfStuff").AsArray(); for (unsigned int i = 0; i < stuff.GetCount(); ++i) { std::cout << stuff.Get(i).AsValue().AsString() << std::endl; } return 0; } [/cpp] file.json: [code] { "name": "value", "number": 20, "anothernumber": 15.3, "stuff": true, "listOfStuff": [ "json", "more stuff", null, false ] } [/code] Output: [code] json more stuff null false [/code] I don't really like how verbose it got (i.e rootNode->[b]AsObject()[/b].Get("listOfStuff").[b]AsArray()[/b]), but I don't know how to get around that right now. I'm probably going to implement iterators too. You can also pass a default value to return if the node wasn't found. root.Get("name", Jzon::Value("Unknown"));
[QUOTE=Smashmaster;28378794]92 line one-time pad encryption/decryption algorithm. [code] import java.util.Scanner; import java.io.FileInputStream; import java.io.FileOutputStream; import java.security.MessageDigest; import java.util.Arrays; public class Main { public static void main(String[] args) { try { System.out.println("Enter E to encrypt, or D to decrypt."); Scanner in = new Scanner(System.in); char choice = in.next().toLowerCase().charAt(0); switch (choice) { case 'd': System.out.println("Decrypting 'ciphertext.txt' with 'key.txt'"); decrypt(); System.out.println("Decrypted!"); break; case 'e': System.out.println("Encrypting 'in.txt'"); encrypt(); System.out.println("Encrypted!"); break; default: System.out.println("Invalid choice. Exiting."); break; } in.close(); } catch (Exception e) { e.printStackTrace(); } } private static void encrypt() throws Exception { FileInputStream fis = new FileInputStream("in.txt"); byte[] data = new byte[fis.available()]; fis.read(data); fis.close(); byte[] hash = new byte[data.length]; int numFrames = (int)Math.ceil((double)data.length/64d); //how many times do we need to hash MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); //64 byte output (or 512 bits) for (int frame=0;frame<numFrames;frame++) { int start = frame*64, end = Math.min(start+64, data.length); byte[] frameData = Arrays.copyOfRange(data, start, end); byte[] digestData = sha512.digest(frameData); System.arraycopy(digestData, 0, hash, start, frameData.length); } FileOutputStream keyFos = new FileOutputStream("key.txt"); keyFos.write(hash); keyFos.close(); byte[] cipherText = Arrays.copyOf(data, data.length); for (int i=0;i<hash.length;i++) cipherText[i] -= hash[i]; FileOutputStream cipherTextFos = new FileOutputStream("ciphertext.txt"); cipherTextFos.write(cipherText); cipherTextFos.close(); } private static void decrypt() throws Exception { FileInputStream cipherTextFis = new FileInputStream("ciphertext.txt"); byte[] cipherTextData = new byte[cipherTextFis.available()]; cipherTextFis.read(cipherTextData); cipherTextFis.close(); FileInputStream keyFis = new FileInputStream("key.txt"); byte[] keyData = new byte[keyFis.available()]; keyFis.read(keyData); keyFis.close(); byte[] outData = Arrays.copyOf(cipherTextData, cipherTextData.length); for (int i=0;i<keyData.length;i++) outData[i] += keyData[i]; FileOutputStream outFos = new FileOutputStream("out.txt"); outFos.write(outData); outFos.close(); } } [/code] I figure it's not nearly as secure as a commercial algorithm--but it's as secure as SHA-512. Which is apparently pretty secure. The basic idea is that the key and ciphertext are the same size as the plaintext file. It works flawlessly. Encrypted a 50 megabyte file in 6 seconds, decrypted in less than one second.[/QUOTE] I'm not sure why you're comparing your encryption algorithm to a hashing algorithm
[QUOTE=Dotmister;28382796]I'm not sure why you're comparing your encryption algorithm to a hashing algorithm[/QUOTE] Well, take a look at the algorithm. I'm not comparing it to SHA, I'm implementing SHA. The file is broken up into 512 bit "frames" which are each hashed using SHA-512. The hash codes are subtracted from the frames to give the ciphertext. The key is the assembled 512 bit hash codes.
[QUOTE=Z_guy;28382673]This is how you read Json files with my parser.. [cpp] #include <Jzon.h> #include <iostream> int main() { Jzon::NodePtr rootNode = Jzon::FileReader::ReadFile("file.json"); Jzon::Array &stuff = rootNode->AsObject().Get("listOfStuff").AsArray(); for (unsigned int i = 0; i < stuff.GetCount(); ++i) { std::cout << stuff.Get(i).AsValue().AsString() << std::endl; } return 0; } [/cpp] I don't really like how verbose it got (i.e rootNode->[b]AsObject()[/b].Get("listOfStuff").[b]AsArray()[/b]), but I don't know how to get around that right now.[/QUOTE] I think you could add a constructor to Jzon::Array to be constructed from rootNode->AsObject().Get("listOfStuff") to eliminate the need for additional function. Also type casts could be implemented to avoid verbose commands in some cases.
[QUOTE=bootv2;28382972]but... how would one decrypt a hash? since you're implementing a hashing algorythm in encryption. how would decrypting be possible? the data is just missing.[/QUOTE] The cipthertext is merely the hash subtracted from the data. You simply add the hash to the ciphertext to get the original data. And what I mean by adding or subtracting is to add/subtract each byte respectively to every other byte, with logical wrap-around. EDIT: Crap, I didn't say that very well. Bytes only add or subtract from their respective byte in the other file. So if the a key byte has a value of 35, and its corresponding ciphertext byte has a value of -10, the original value would be 25.
I have an Off-Topic question, if Notch would have written Minecraft in C++ would it run faster?
[QUOTE=commander204;28383113]I have an Off-Topic question, if Notch would have written Minecraft in C++ would it run faster?[/QUOTE] No, because Minecraft doesn't run slow because it's made in Java. It runs slow because Notch can't code high-performance game engines.
[QUOTE=commander204;28383113]I have an Off-Topic question, if Notch would have written Minecraft in C++ would it run faster?[/QUOTE] It really depends on how he codes it. Bad Java code is as slow as bad C++ code. Yes, there's a minor difference between native code and interpreted code (less so if it's JITted), but if he were to directly port his code to C++, it would probably be just as slow. And either way any language's OpenGL bindings find their way down to the native OpenGL drivers to do all the actual rendering.
[QUOTE=Smashmaster;28383143]No, because Minecraft doesn't run slow because it's made in Java. It runs slow because Notch can't code high-performance game engines.[/QUOTE] I wouldn't exactly say it runs badly, Notch gets a lot more citisism than he deserves, primarily I expect from people envious of his luck and wealth.
[QUOTE=Jallen;28383323]I wouldn't exactly say it runs badly, Notch gets a lot more citisism than he deserves, primarily I expect from people envious of his luck and wealth.[/QUOTE] on one update right before Beta, I had it running at 20-30fps on a C2Q @ 2.83GHz and with a GTX260. It takes the same power to run Crysis on high with that framerate on my desktop. Of course, it was patched.. but meh
[QUOTE=Jallen;28383323]I wouldn't exactly say it runs badly, Notch gets a lot more citisism than he deserves, primarily I expect from people envious of his luck and wealth.[/QUOTE] I think he deserves everything he gets. The money and the criticism. Minecraft is a great game, and I play it all the time. It's also poorly optimized.
The game gets framerates below the 5 when more than 10 TNT blocks go off at the same time.
[QUOTE=Jallen;28383323]I wouldn't exactly say it runs badly, Notch gets a lot more citisism than he deserves, primarily I expect from people envious of his luck and wealth.[/QUOTE] Maybe. But it's undeniably [b]really[/b] badly optimised.
I agree with BlkDucky. It doesn't run badly as such, but it definitely doesn't run as fast as a game of its calibre should. Notch needs to stop taking so many vacations and start optimising his engine a lot.
[QUOTE=Chris220;28383697]I agree with BlkDucky. It doesn't run badly as such, but it definitely doesn't run as fast as a game of its calibre should. Notch needs to stop taking so many vacations and start optimising his engine a lot.[/QUOTE] But he's been working for 5 hours straight, he's not a machine damnit! /sarcasm
[QUOTE=Chris220;28383697]I agree with BlkDucky. It doesn't run badly as such, but it definitely doesn't run as fast as a game of its calibre should. Notch needs to stop taking so many vacations and start optimising his engine a lot.[/QUOTE] I don't want to seem like a fanboy here, but really we should be grateful for what notch does. The majority of people who become millionaires just ditch work and do whatever the fuck they want. Fortunately notch seems to have a passion for game development.
Plenty of wiggle space inbetween the JVM's performance and native, though - Sun's JVM's a pretty serious piece of VM tech.
That is even worse, if he knows that people pay for it he should make it even better.
Sorry, you need to Log In to post a reply to this thread.