Emeralis00 she/her Posted June 4, 2011 Posted June 4, 2011 (edited) I wasn't sure if I could put the game I made here, but this is the creator's corner so... Ten Stones is a game where the player tries to get a ten stones or more in their stockpile before the opponent (in this case the computer). Yeah, I know that is in DOS format and looks ugly, I am still working on learning GUIs. Tell me what you think about it please. (P.S. run the batch file, not the jar.) EDIT: new version available. not much changed, except now it is easier on the eyes and easier to read. TenStones.zip Edited July 29, 2011 by Emeralis00
Sprouts Posted July 28, 2011 Posted July 28, 2011 I've been learning C++ for a while so I'm used to the DOS format. As all my programs are in that format as well. The game is simple but fairly entertaining. You should definitely clear the screen more so that the text doesn't just scroll down forever.
Emeralis00 she/her Posted July 28, 2011 Author Posted July 28, 2011 I've been learning C++ for a while so I'm used to the DOS format. As all my programs are in that format as well. The game is simple but fairly entertaining. You should definitely clear the screen more so that the text doesn't just scroll down forever. Thank you. Unfortunately, Its in Java and Java lacks the ability to use DOS commands that C++ has, so I can't use the cls command. That is why I have been meaning to look into GUI coding. Its either that, or : for (int i= 0; i < 400; i++){ system.out.println " "; } Which just makes a massive amount of space between the segments. Do you have any Java skill? I can share the source code with you.
Sprouts Posted July 28, 2011 Posted July 28, 2011 I have very little experience with Java, less than my small amount of experience with C++. So I can't help you much on that one, sorry... However I decided to look around and found this. Not sure if it will work, as I don't know what it means. But it says it clears the DOS screen in Java. http://wiki.answers.com/Q/How_to_clear_dos_screen_in_JAVA
Emeralis00 she/her Posted July 28, 2011 Author Posted July 28, 2011 I have very little experience with Java, less than my small amount of experience with C++. So I can't help you much on that one, sorry... However I decided to look around and found this. Not sure if it will work, as I don't know what it means. But it says it clears the DOS screen in Java. http://wiki.answers...._screen_in_JAVA sorry, no. It is an escape sequence that outputs an ASCII character code. The person who answered the question has no idea what he is talking about. Thanks for looking though
Eerongal he/him Posted July 28, 2011 Posted July 28, 2011 To clear the command line in java, you should do this, i believe: Runtime.getRuntime().exec("cls"); Note: It's been about 7 years or so since i've really done any java. If you need any help programming games, i'd be more than happy to help. I constantly start new side projects on my own making small, simple games and stuff, I'm actually currently working on one in vb.net because I've never used vb.net before, so I figured it'd be a good bit of practice to give it a shot.
Emeralis00 she/her Posted July 29, 2011 Author Posted July 29, 2011 To clear the command line in java, you should do this, i believe: Runtime.getRuntime().exec("cls"); Note: It's been about 7 years or so since i've really done any java. It gives this when used: unreported exception java.io.IOException; must be caught or declared to be thrown If you need any help programming games, i'd be more than happy to help. I constantly start new side projects on my own making small, simple games and stuff, I'm actually currently working on one in vb.net because I've never used vb.net before, so I figured it'd be a good bit of practice to give it a shot. Thanks! I'll share any projects that I am working on if I'm stuck, though currently I haven't been doing much. I learned a little bit of vb, but not much to really do anything with it.
Eerongal he/him Posted July 29, 2011 Posted July 29, 2011 It gives this when used: unreported exception java.io.IOException; must be caught or declared to be thrown And i believe i see exactly why. I omitted a part of it. Try this on for size. Runtime.getRuntime().exec("cmd /c cls"); edit: also - the command in the quotation marks varies based on operating system. The above command should work on all windows machines above 95 or 98 (i dont remember which. at some point they changed it from "command" to "cmd" for the command prompt) Thanks! I'll share any projects that I am working on if I'm stuck, though currently I haven't been doing much. I learned a little bit of vb, but not much to really do anything with it. Yeah, VB is pretty easy. I've known VB for some time, but I never got into vb.net, but im quickly finding that vb.net is so stupidly similar to vb that I should have just said I know VB.net in the first place. Also, in so far as game programming goes, just from my personal experience with it, java is kinda "chunky", and if the game is overly complex, it'll really bog the system down. However, it offers a myriad of benefits (cross platform compatibility being one major one) so take from that what you will. Personally, i really like microsoft's XNA game platform (uses C#), and it has the benefit of working on PC (windows only, though, which most gaming happens on windows machines anyways) and on the 360. It has a lot of nifty tools that really helps streamline everything. Also, i mostly deal with 2D games, i've never tried my hand at 3D.
Emeralis00 she/her Posted July 29, 2011 Author Posted July 29, 2011 Unfortunately, I get the same error. Oh well, its not like it is all that necessary. I am kinda limited to Java as of right now, but I have all the stuff I need to learn more. It just takes me longer without a teacher. I do occasionally dabble with Gamemaker, its an object-orientated language, but even more so than VB. As for 3D, I have a friend who is good at it, but I get cross-eyed when he talks about emitters and stuff (he is not a really good teacher).
Eerongal he/him Posted July 29, 2011 Posted July 29, 2011 Unfortunately, I get the same error. Oh well, its not like it is all that necessary. I am kinda limited to Java as of right now, but I have all the stuff I need to learn more. It just takes me longer without a teacher. I do occasionally dabble with Gamemaker, its an object-orientated language, but even more so than VB. As for 3D, I have a friend who is good at it, but I get cross-eyed when he talks about emitters and stuff (he is not a really good teacher). yeah, well, the command may have also changed on me or something. Remember, i'm working off of java knowledge circa 2004 or so here. I haven't really kept up with it that much, though i do go back and dabble with it occasionally. However, actually looking at the error message now, I think you may need to just enclose the statement in a try...catch block to make it work (java makes you sorround things in try...catch blocks if they have a chance of throwing either checked or unchecked exceptions, i dont remember which, but this may be an instance of that) In regards to object orientation and VB, all versions of VB prior to VB.net were not object oriented languages, but were CLOSE to being object oriented (they lacked inheritance and maybe one or two other small features of full OOP languages), but vb.net is indeed fully object oriented (which i think is where the people who come off saying the vb to vb.net change is pretty significant get it from). I've never used gamemaker, but i've met a few people who swear by it.
Emeralis00 she/her Posted July 29, 2011 Author Posted July 29, 2011 (edited) However, actually looking at the error message now, I think you may need to just enclose the statement in a try...catch block to make it work Darn it. That was a chapter that I didn't get to in my programming class. Everyone was too slow and couldn't keep up so the teacher had to spend an extra week on arrays. *grumbles at the unfairness* I'll try (hehe) using a try...catch block. Edited July 29, 2011 by Emeralis00
Eerongal he/him Posted July 29, 2011 Posted July 29, 2011 Darn it. That was a chapter that I didn't get to in my programming class. Everyone was too slow and couldn't keep up so the teacher had to spend an extra week on arrays. *grumbles at the unfairness* I'll try (hehe) using a try...catch block. heh, don't worry, try...catch isn't hard. A brief synopsis (that actually applies to most programming languages): A try-catch block consists of two parts. A "try" part and a "catch" part. what this is used for is error trapping. the "try" part is the part of the code that you're afraid may throw some kind of error. The "catch" part is what the program does when it does indeed encounter an error. for the previous line of code, we would want to do something like this: try{ Runtime.getRuntime().exec("cmd /c cls"); } catch (IOException e) { System.out.println(e.getMessage()) } what this will do is tell it to "try" executing that line of code. If it has an error, go into the catch block and print out, to the console, the error message Edit: also, feel free to hit me up on aim or something with questions if you have them or anything, it would probably be quicker for you to get answers that way than through posts like this if you're in the middle of trying to work it out
Emeralis00 she/her Posted July 29, 2011 Author Posted July 29, 2011 I will keep that in mind. Right now, I have no pressing need for help, so I don't need quick answers. ...Well, it gets rid of the error messages, but then it doesn't do what it is supposed to do. btw: you have a syntax error. there should be a semi-colon after System.out.println(e.getMessage())
Eerongal he/him Posted July 29, 2011 Posted July 29, 2011 huh. well, im not sure why that doesnt work, but another thought is instead of doing a println a large number of times, build a string like: strClear = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; and print that to the screen instead. \n is the new line character, so if you do it all in one go it should "clear" the screen by forcing everything up in one jump instead of a large number of individual jumps. Still a sort of a work around, but visually it should look better.
Joe ST he/him Posted July 29, 2011 Posted July 29, 2011 even better, to clear the terminal you should use the form feed character '\f' 0x0D
Emeralis00 she/her Posted July 29, 2011 Author Posted July 29, 2011 huh. well, im not sure why that doesnt work, but another thought is instead of doing a println a large number of times, build a string like:strClear = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; and print that to the screen instead. \n is the new line character, so if you do it all in one go it should "clear" the screen by forcing everything up in one jump instead of a large number of individual jumps. Still a sort of a work around, but visually it should look better. I'll try that too. even better, to clear the terminal you should use the form feed character '\f' 0x0D What?
Eerongal he/him Posted July 29, 2011 Posted July 29, 2011 even better, to clear the terminal you should use the form feed character '\f' 0x0D i thought the form feed character was for printers only, and it forced it to eject a page? I've never used it, so i can't vouch for it
Joe ST he/him Posted July 29, 2011 Posted July 29, 2011 What? The Form Feed character ('\f' or 0x0D) clears the page (which in the case of printers, spits the page out).This is more portable than the newline solution since it doesnt matter how many lines are on display (ie, if the window's height is changed, the number of lines on display goes up and thus would break the '\n' version
Emeralis00 she/her Posted July 30, 2011 Author Posted July 30, 2011 The Form Feed character ('\f' or 0x0D) clears the page (which in the case of printers, spits the page out). This is more portable than the newline solution since it doesnt matter how many lines are on display (ie, if the window's height is changed, the number of lines on display goes up and thus would break the '\n' version Can you show me some code for it please?
Eerongal he/him Posted July 30, 2011 Posted July 30, 2011 Can you show me some code for it please? System.out.println("\f");
Emeralis00 she/her Posted July 30, 2011 Author Posted July 30, 2011 System.out.println("\f"); Tried that. it didn't work. I t displayed the number 13.
Eerongal he/him Posted July 30, 2011 Posted July 30, 2011 Tried that. it didn't work. I t displayed the number 13. huh, that's weird. I just checked and confirmed on sun's java documentation, and \f is indeed the escape character for form feed. (relevant link) you didn't accidentally change your command prompt to unicode somehow, right (in which case you'd need to use the unicode escape for it instead, which i dont know what that is)? edit: apparently the unicode escape is: \u000c
Joe ST he/him Posted July 30, 2011 Posted July 30, 2011 apparently the unicode escape is: \u000c you sure? cause ASCII should be mapped directly to the first part of unicode, which would mean it was \u000d... try System.out.print('\f'); rather than println. and make sure it's a character rather than a string (which would need to be doubly escaped?)
Eerongal he/him Posted July 30, 2011 Posted July 30, 2011 you sure? cause ASCII should be mapped directly to the first part of unicode, which would mean it was \u000d... try System.out.print('\f'); rather than println. and make sure it's a character rather than a string (which would need to be doubly escaped?) that's what that java page i i linked earlier said. \u000d appears to be the unicode for \r it says. EscapeSequence: \ b /* \u0008: backspace BS */ \ t /* \u0009: horizontal tab HT */ \ n /* \u000a: linefeed LF */ \ f /* \u000c: form feed FF */ \ r /* \u000d: carriage return CR */ \ " /* \u0022: double quote " */ \ ' /* \u0027: single quote ' */ \ \ /* \u005c: backslash \ */ further edit: also, this random unicode chart i just looked up listed it as such too linky
Joe ST he/him Posted July 31, 2011 Posted July 31, 2011 damnation, indeed I'm wrong... ASCII Table is great for this kinda thing, sorry. Joe
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now