Jump to content
  • Advertisement

Lucky Ace Card

Member
  • Content Count

    126
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Lucky Ace Card

  • Rank
    Member
  1. *EDIT* Sorry, I fixed it. But I can't delete the topic. It was a NullPointer. [Edited by - Lucky Ace Card on December 28, 2006 9:22:15 PM]
  2. Lucky Ace Card

    Question on C#/C++

    I'm currently learning Java for AP Computer Science class. However, I also want to learn another language at the same time. I began on C#. Pretty simple to start with. However, I want to learn a language that would be more geared towards games. For example, 2D side scrolling platformers/shooters. Y'know. Is C# really a wise choice for things like those? Or should I check out C++ instead? I'm leaning towards C++, but I wanted to hear some opinions on this. Any help is appreciated.
  3. I didn't really find any good online material comparing C++ and C#, but I did manage to contact my friend's dad who has a good position at Microsoft. And he gave me some information on it. If anyone else wants to help a little and give their insight on the difference between C++ and C#, it's be appreciated. =)
  4. Is there any popular opinion on which language is stronger for game development? Or is that a very debateable issue?
  5. I didn't know C++ and C# were so different. Odd. I'll have to research more as to which I want to study right now. I'm pretty confident I could handle learning multiple languages, especially if they are relatively similar. I'll give it a shot. But yeah, knowing multiple languages really would help anyone become more marketable. I'll probably find some books on C++ or C#, whichever it is I'm gunna study now. Can anyone help me out on whether I should look at C++ or C#? I guess I'm not too sure of how C# is different.
  6. I'm a senior in High School taking AP Computer Science, which covers Java. I've already read the whole school text book, skimmed over some others, and I plan to keep learning Java throughout the school year. However, I'm also interested in other languages, specifically C++/C#. They seem to be more game oriented than Java, and I'd really like to know multiple programming languages. Now, is it a good idea to study both Java and C++/C# at the same time? I'm not sure if that would be too hard or confusing or what. Any opinions on that? Thanks for any help.
  7. Lucky Ace Card

    How can I improve this java code?

    So I think I've written a decent check method and implemented it into the main method. I deleted all the useless methods like checkLeft and moveLeft, etc. import java.util.Scanner; public class Maze12 { public static final int RIGHT = 0; public static final int UP = 1; public static final int LEFT = 2; public static final int DOWN = 3; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int currentRoom = 3; String choice = ""; int index1 = 110; System.out.println("This program is a test version of a maze."); System.out.println("==============================================================="); System.out.println("Welcome to the maze game. Type the direction you wish to travel or type 'map' to see the map."); System.out.println("Type 'quit' to quit."); System.out.println(); System.out.println("================================================================"); System.out.println("================================================================\n\n"); System.out.println(); while (choice.equalsIgnoreCase("quit") != true) //Until user types quit { choice = ""; int[] details = {}; String desc = getRoomDesc(currentRoom, index1); //Get room info. System.out.println(desc); System.out.print("\nEnter a choice: "); choice = scan.nextLine(); //Get user's choice while (choice.equalsIgnoreCase("")) { System.out.print("Enter a choice: "); choice = scan.nextLine(); //Continue prompt while invalid input } choice = choice.toLowerCase(); if (choice.equalsIgnoreCase("left")) //If left { details = move(LEFT, currentRoom, index1); //Move you left currentRoom = details[0]; //Creates new currentRoom value that user has moved to index1 = details[1]; //Creates a new place to draw 'You' } else if (choice.equalsIgnoreCase("right")) { details = move(RIGHT, currentRoom, index1); //Move you left currentRoom = details[0]; //Creates new currentRoom value that user has moved to index1 = details[1]; //Creates a new place to draw 'You' } else if (choice.equalsIgnoreCase("down")) { details = move(DOWN, currentRoom, index1); //Move you left currentRoom = details[0]; //Creates new currentRoom value that user has moved to index1 = details[1]; //Creates a new place to draw 'You' } else if (choice.equalsIgnoreCase("up")) { details = move(UP, currentRoom, index1); //Move you left currentRoom = details[0]; //Creates new currentRoom value that user has moved to index1 = details[1]; //Creates a new place to draw 'You' } else if (choice.equalsIgnoreCase("map")) viewMap(currentRoom, index1); //Prints map else if (choice.equalsIgnoreCase("quit") != true) System.out.println("Sorry, that's not a valid choice."); } } public static String getRoomDesc(int currentRoom, int index1) { viewMap(currentRoom, index1); String desc = "You are in room " + currentRoom + ".\nYou may move:\n"; if (check(RIGHT, currentRoom)) desc+="Right\n"; if (check(LEFT, currentRoom)) desc+="Left\n"; if (check(DOWN, currentRoom)) desc+="Down\n"; if (check(UP, currentRoom)) desc+="Up\n"; return desc; } public static void viewMap(int currentRoom, int index1) { String plain = "____________________________\n" + "| | | | |\n" + "| 0 | 1 | 2 | 3 |\n" + "| | | | |\n" + "|______|______|______|_____|\n" + "| |X X X |X X X |X X X|\n" + "| 4 |X 5 X |X 6 X |X 7 X|\n" + "| |X X X |X X X |X X X|\n" + "|______|______|______|_____|\n" + "| | | | |\n" + "| 8 | 9 | 10 | 11 |\n" + "| | | | |\n" + "|______|______|______|_____| "; char arrayMap[] = plain.toCharArray(); arrayMap[index1] = 'Y'; arrayMap[index1+1] = 'o'; arrayMap[index1+2] = 'u'; System.out.println(); System.out.println(arrayMap); } public static int[] move(int direction, int currentRoom, int index1) { boolean canMove; int currentRoomChange; int index1Change; final int[] currentRoomChanges = {1, -4, -1, 4}; final int[] index1Changes = {7, -116, -7, 116}; if (check(direction, currentRoom)) { currentRoom += currentRoomChanges[direction]; index1 += index1Changes[direction]; } else { System.out.println("You can not move that way. Try another direction."); } int list[] = {currentRoom, index1}; return list; } public static boolean check(int direction, int currentRoom) { //0=right //2=left //1=up //3=down boolean goodMove; boolean[] RIGHT = {true, true, true, false, false, false, false, false, true, true, true, false}; boolean[] LEFT = {false, true, true, true, false, false, false, false, false, true, true, true}; boolean[] UP = {false, false, false, false, true, false, false, false, true, false, false, false}; boolean[] DOWN = {true, false, false, false, true, false, false, false, false, false, false, false}; switch (direction) { case 0: goodMove = RIGHT[currentRoom]; break; case 1: goodMove = UP[currentRoom]; break; case 2: goodMove = LEFT[currentRoom]; break; case 3: goodMove = DOWN[currentRoom]; break; default: goodMove = false; break; } return goodMove; } } Any more suggestions? Because this topic has taught me a lot about writing clean code. The main method looks a little clunky, don't ya think..?
  8. Lucky Ace Card

    How can I improve this java code?

    Zahlman, are you like.... a Computer Science professor or something? You're amazing. And what you did actually makes perfect sense to me now that you've explained it. As soon as I finish all this work for other classes, I'm gunna give the check() method a shot. Thanks a lot for the help! I'll check back here a little later with how it's coming along.
  9. Lucky Ace Card

    How can I improve this java code?

    Alright, here's a newer version of what I have now. I mainly changed the way the word "you" is drawn, as I made it dynamic. import java.util.Scanner; public class Maze8 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int currentRoom = 3; String choice = ""; int index1 = 110; System.out.println("This program is a test version of a maze."); System.out.println("==============================================================="); System.out.println("Welcome to the maze game. Type the direction you wish to travel or type 'map' to see the map."); System.out.println("Type 'quit' to quit."); System.out.println(); System.out.println("================================================================"); System.out.println("================================================================\n\n"); System.out.println(); while (choice.equalsIgnoreCase("quit") != true) //Until user types quit { choice = ""; int[] details = {}; String desc = getRoomDesc(currentRoom, index1); //Get room info. System.out.println(desc); System.out.print("\nEnter a choice: "); choice = scan.nextLine(); //Get user's choice while (choice.equalsIgnoreCase("")) { System.out.print("Enter a choice: "); choice = scan.nextLine(); //Continue prompt while invalid input } choice = choice.toLowerCase(); if (choice.equalsIgnoreCase("left")) //If left { details = moveLeft(currentRoom, index1); //Move you left currentRoom = details[0]; //Creates new currentRoom value that user has moved to index1 = details[1]; //Creates a new place to draw 'You' } else if (choice.equalsIgnoreCase("right")) { details = moveRight(currentRoom, index1); currentRoom = details[0]; index1 = details[1]; } else if (choice.equalsIgnoreCase("down")) { details = moveDown(currentRoom, index1); currentRoom = details[0]; index1 = details[1]; } else if (choice.equalsIgnoreCase("up")) { details = moveUp(currentRoom, index1); currentRoom = details[0]; index1 = details[1]; } else if (choice.equalsIgnoreCase("map")) viewMap(currentRoom, index1); //Prints map else if (choice.equalsIgnoreCase("quit") != true) System.out.println("Sorry, that's not a valid choice."); } } public static boolean checkUp(int currentRoom) { boolean check; if (currentRoom == 0 || currentRoom == 1 || currentRoom == 2 || currentRoom == 3) check = false; else if (currentRoom == 9 || currentRoom == 10 || currentRoom == 11) check = false; else check = true; return check; } public static boolean checkLeft(int currentRoom) { boolean check; if (currentRoom == 0 || currentRoom == 4 || currentRoom == 8) check = false; else check = true; return check; } public static boolean checkDown(int currentRoom) { boolean check; if (currentRoom == 1 || currentRoom == 2 || currentRoom == 3) check = false; else if (currentRoom == 8 || currentRoom == 9 || currentRoom == 10 || currentRoom == 11) check = false; else check = true; return check; } public static boolean checkRight(int currentRoom) { boolean check; if (currentRoom == 3 || currentRoom == 4 || currentRoom == 11) check = false; else check = true; return check; } public static String getRoomDesc(int currentRoom, int index1) { viewMap(currentRoom, index1); String desc = "You are in room " + currentRoom + ".\nYou may move:\n"; if (checkRight(currentRoom)) desc+="Right\n"; if (checkLeft(currentRoom)) desc+="Left\n"; if (checkDown(currentRoom)) desc+="Down\n"; if (checkUp(currentRoom)) desc+="Up\n"; return desc; } public static int[] moveLeft(int currentRoom, int index1) { if (checkLeft(currentRoom) == true) { currentRoom -= 1; index1 -= 7; } else System.out.println("You can not move that way. Try another direction."); int[] list = {currentRoom, index1}; return list; } public static int[] moveRight(int currentRoom, int index1) { if (checkRight(currentRoom) == true) { currentRoom += 1; index1 += 7; } else System.out.println("You can not move that way. Try another direction."); int[] list = {currentRoom, index1}; return list; } public static int[] moveDown(int currentRoom, int index1) { if (checkDown(currentRoom) == true) { currentRoom += 4; index1 += 116; } else System.out.println("You can not move that way. Try another direction."); int[] list = {currentRoom, index1}; return list; } public static int[] moveUp(int currentRoom, int index1) { if (checkUp(currentRoom) == true) { currentRoom -= 4; index1 -= 116; } else System.out.println("You can not move that way. Try another direction."); int[] list = {currentRoom, index1}; return list; } public static void viewMap(int currentRoom, int index1) { String plain = "____________________________\n" + "| | | | |\n" + "| 0 | 1 | 2 | 3 |\n" + "| | | | |\n" + "|______|______|______|_____|\n" + "| |X X X |X X X |X X X|\n" + "| 4 |X 5 X |X 6 X |X 7 X|\n" + "| |X X X |X X X |X X X|\n" + "|______|______|______|_____|\n" + "| | | | |\n" + "| 8 | 9 | 10 | 11 |\n" + "| | | | |\n" + "|______|______|______|_____| "; char arrayMap[] = plain.toCharArray(); arrayMap[index1] = 'Y'; arrayMap[index1+1] = 'o'; arrayMap[index1+2] = 'u'; System.out.println(); System.out.println(arrayMap); } } Zahlman, I just read your code, and it's a bit too advanced for me. =P Mine's ugly, and I have trouble understanding some of your concepts. I understand what you do as I read it (for the most part), but I have some work to do before I can fully understand how to make it work like that without simply copying it and pasting it. My AP Computer Science teacher (who's forte isn't really java...) says the next step I should take is to make the walking character into a class so he can be a separate object. I guess that'd be a good idea. He could hold his own attributes like what room he is in, what room he was previously in, and it could even lead to having multiple characters in the same maze. I'm not exactly sure how to go about implementing an object from another class I write (I know the syntax and all that, just never actually used this concept yet). I suppose I'll go try it out.
  10. Lucky Ace Card

    How can I improve this java code?

    Thanks guys. Those are good suggestions. I think I'll try some of them out! =) About classes, I really don't know much of how I would be able to use them in this program efficiently. I've never really done it before.
  11. I made a simple "maze" program. It only has 1 map, which is a U shaped map. I originally had the viewMap method print a different map for each case, but I recently replaced it with a default map that gets written over with "You". I also had tons of else if's that I made into case. But how else can I improve the code? Any suggestions would be appreciated, since I'm pretty new to Java, and I don't feel like I can write clean code. import java.util.Scanner; public class Maze4 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int currentRoom = 3; String choice = ""; System.out.println("This program is a test version of a maze."); System.out.println("==============================================================="); System.out.println("Welcome to the maze game. Type the direction you wish to travel or type 'map' to see the map."); System.out.println("Type 'quit' to quit."); System.out.println(); System.out.println("================================================================"); System.out.println("================================================================\n\n"); System.out.println(); while (choice.equalsIgnoreCase("quit") != true) { choice = ""; String desc = getRoomDesc(currentRoom); System.out.println(desc); System.out.print("\nEnter a choice: "); choice = scan.nextLine(); while (choice.equalsIgnoreCase("")) { System.out.print("Enter a choice: "); choice = scan.nextLine(); } choice = choice.toLowerCase(); if (choice.equalsIgnoreCase("left")) currentRoom = moveLeft(currentRoom); else if (choice.equalsIgnoreCase("right")) currentRoom = moveRight(currentRoom); else if (choice.equalsIgnoreCase("down")) currentRoom = moveDown(currentRoom); else if (choice.equalsIgnoreCase("up")) currentRoom = moveUp(currentRoom); else if (choice.equalsIgnoreCase("map")) viewMap(currentRoom); else if (choice.equalsIgnoreCase("quit") != true) System.out.println("Sorry, that's not a valid choice."); } } public static boolean checkUp(int currentRoom) { boolean check; if (currentRoom == 0 || currentRoom == 1 || currentRoom == 2 || currentRoom == 3) check = false; else if (currentRoom == 9 || currentRoom == 10 || currentRoom == 11) check = false; else check = true; return check; } public static boolean checkLeft(int currentRoom) { boolean check; if (currentRoom == 0 || currentRoom == 4 || currentRoom == 8) check = false; else check = true; return check; } public static boolean checkDown(int currentRoom) { boolean check; if (currentRoom == 1 || currentRoom == 2 || currentRoom == 3) check = false; else if (currentRoom == 8 || currentRoom == 9 || currentRoom == 10 || currentRoom == 11) check = false; else check = true; return check; } public static boolean checkRight(int currentRoom) { boolean check; if (currentRoom == 3 || currentRoom == 4 || currentRoom == 11) check = false; else check = true; return check; } public static String getRoomDesc(int currentRoom) { viewMap(currentRoom); String desc; if (currentRoom == 3) { desc = "\nYou are in room 3."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 2) { desc = "\nYou are in room 2."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 1) { desc = "\nYou are in room 1."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 0) { desc = "\nYou are in room 0."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 4) { desc = "\nYou are in room 4."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 8) { desc = "\nYou are in room 8."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 9) { desc = "\nYou are in room 9."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 10) { desc = "\nYou are in room 10."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else if (currentRoom == 11) { desc = "\nYou are in room 11."; if (checkLeft(currentRoom)) desc += "\nYou may move left."; if (checkRight(currentRoom)) desc += "\nYou may move right."; if (checkDown(currentRoom)) desc += "\nYou may move down."; if (checkUp(currentRoom)) desc += "\nYou may move up."; } else desc = "\nInvalid room number."; return desc; } public static int moveLeft(int currentRoom) { if (checkLeft(currentRoom) == true) currentRoom -= 1; else System.out.println("You can not move that way. Try another direction."); return currentRoom; } public static int moveRight(int currentRoom) { if (checkRight(currentRoom) == true) currentRoom += 1; else System.out.println("You can not move that way. Try another direction."); return currentRoom; } public static int moveDown(int currentRoom) { if (checkDown(currentRoom) == true) currentRoom += 4; else System.out.println("You can not move that way. Try another direction."); return currentRoom; } public static int moveUp(int currentRoom) { if (checkUp(currentRoom) == true) currentRoom -= 4; else System.out.println("You can not move that way. Try another direction."); return currentRoom; } public static void viewMap(int currentRoom) { String plain = "____________________________\n" + "| | | | |\n" + "| 0 | 1 | 2 | 3 |\n" + "| | | | |\n" + "|______|______|______|_____|\n" + "| |X X X |X X X |X X X|\n" + "| 4 |X 5 X |X 6 X |X 7 X|\n" + "| |X X X |X X X |X X X|\n" + "|______|______|______|_____|\n" + "| | | | |\n" + "| 8 | 9 | 10 | 11 |\n" + "| | | | |\n" + "|______|______|______|_____| "; char arrayMap[] = plain.toCharArray(); switch (currentRoom) { case 3: { arrayMap[110] = 'Y'; arrayMap[111] = 'o'; arrayMap[112] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 2: { arrayMap[103] = 'Y'; arrayMap[104] = 'o'; arrayMap[105] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 1: { arrayMap[97] = 'Y'; arrayMap[98] = 'o'; arrayMap[99] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 0: { arrayMap[90] = 'Y'; arrayMap[91] = 'o'; arrayMap[92] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 4: { arrayMap[205] = 'Y'; arrayMap[206] = 'o'; arrayMap[207] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 8: { arrayMap[321] = 'Y'; arrayMap[322] = 'o'; arrayMap[323] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 9: { arrayMap[329] = 'Y'; arrayMap[330] = 'o'; arrayMap[331] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 10: { arrayMap[336] = 'Y'; arrayMap[337] = 'o'; arrayMap[338] = 'u'; System.out.println(); System.out.println(arrayMap); break; } case 11: { arrayMap[343] = 'Y'; arrayMap[344] = 'o'; arrayMap[345] = 'u'; System.out.println(); System.out.println(arrayMap); break; } default: System.out.println("Invalid map."); break; } } }
  12. Lucky Ace Card

    [java] Help: Guess my Number GUI

    Yes, I'm running exactly that version. Perhaps I'll try another environment. I've tried compiling in both JCreator and command prompt's javac, and running them in each. Same effect. I'll try it on the school computers tomorrow I suppose.
  13. I want to show my brother a program I've made in Java. However, the only way I know how to run it is to open it in JCreator and click Run. Now, if I send the class file over to him, how can he run it? His computer doesn't have stuff like javac and JCreator. Sounds like a really stupid question. But could anyone help? Thanks.
  14. Lucky Ace Card

    Ahhhh keyboard failure. Help?

    Okay, thanks for your help Sneftel. I've had this problem for a long time and nobody has known how to fix it. So you're a genius.
  15. Lucky Ace Card

    [java] Help: Guess my Number GUI

    I've tried to run the debugger in Jcreator many times, and I've still never gotten it.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!