07-12-2004, 01:43 PM | #1 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
w00t! Almost done with the tutorial. Then on to getting some experience and doing the assignment fast enough for it to be done in time.
|
||
|
|
07-12-2004, 02:06 PM | #2 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
Nice...
|
||
|
|
07-12-2004, 02:10 PM | #3 | ||
Join Date: Oct 2003
Location: Shella, Kenya
Posts: 1,578
|
I still want to learn Java but I don't have the time. Writing programs used to be fun back when I was still on an MSX.
__________________
Rabyd Rev -- 2 Timothy 2:15 |
||
|
|
07-12-2004, 02:22 PM | #4 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
Tutorial that only takes a few hours, and the more you know 'bout C++, the less time the tutorial'll take. What you need to do afterwards, is find a way to get experience in the coding. That's what I need to get now too. So... any suggestions to get my thinking right for this one?
|
||
|
|
07-12-2004, 02:58 PM | #5 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
Any programming (VB, C++, Java...) requires good planning. So if you prepare plan based on what you need to accomplish (this one is some sort of global plan), then create pseudo code (in your own language, what you like to do), your programming will then take minimum time, your code will look better, and it will be easier to fix problems.
I have not done much Java in last 2-3 years, but still remember of having a hard time with syntax. I had impression that visual part was also kind of unusual, but have to remember that programs were able to work on any kind of OS, which supports Java. To make sure that you will not end up debugging, start this process with this: Answer these questions: What program supposed to do? What is my input? What are my processes? What output should be? After that just write down (still in your language) all functions, modules (or whatever you call them) that you will need in this program. Then take a look if you can find Java commands that will do what you need. And final step will be writing the code, which at this point should be strait forward. And end will include testing and debugging. This is about what we had to learn in data structures and procedures class, which basically includes preparing plan and documentation for problem, and then apply plan to any programming language. (I liked mostly to use C++) When you done with documentation, post it here, so that we can see it. |
||
|
|
07-12-2004, 03:40 PM | #6 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
Assignment doc:
Code:
Task In this practicum, you'll have to program a game, using a simple graphicacl library. The Game The game situates in a 2-dimensional world, represented by a board, which is divided in an amount of cells. A cell can be empty or contain a box. Dozo is the actor in this game. He is controled by the player by using the cursors and can navigate through this 2D world this way. The goal of the game is to get as many boxes to disappear. Boxes disappear when they are grouped per 3 or per 4 (depending on the type of box). The game stops if all boxes are disappeared. Boxes Boxes can be moved by Dozo when he pushes them. Dozo can move 1 or more boxes at once in one direction this way, on condition that all boxes are of the same type and not placed against a wall. Dozo can, in other words, not move both a red and a blue box at once. When he does try this, he's meant to remain standing on the spot. Two boxes are connected if and only if they have one side in common. Two boxes x and y belong to the same group if x and y are connected or if a box z exists in such a way that x and z are connected and z and y belong to the same group. Red boxes have as characteristic that they disappear as soon as at least 3 such boxes are grouped. Blue boxes disappear as soon as they're grouped with at least 4. Walls A wall (black square on the figure) is immovable. You can assume in this practicum that Dozo's world is closed by walls. The boxes below are grouped correctly and will thus have to disappear * *<figure 2> Figure 3 shows configurations of boxes that aren't complete and thus don't disappear. * *<figure 3> Concrete A description of the world is saved in a file with extension .txt. The file exists out of a few rows that represent the world. The example below makes this clear. Dim 12 5 *The first rule defines a board of 12 cells wide and 5 cells high. ..########.. ..#.B.#R..#. . Empty cell ..#BB.B.R.@# # wall (immovable) ..#....R..#. B a blue box ...#######.. R a red box *@ Dozo You can assume that: * There's only one Dozo defined. * The board is closed. Dozo can't walk reach a cell that's at the edge of the board in any way. * Except for the first row, all rows in the file are equally long. To load a world from a file, you may use the class FileInput which you used in the previous practicum. Tips Although the previous is strictly seen enough to get you to work, we're giving some classes which can appear in your design. A possible implementation could use the following classes. Note, you're not obliged to follow these directions. Keep in mind that with the quoting, a fancy graphical userinterface won't be taken into concideration, but the quality of your design and implementation of it will. On Toledo, you'll find under "assignments", aside of a digital version of the task of this practicum, a library with which you can draw graphical components on the screen. This way, you can, for example, draw Dozo's world with the aid of the classe Bord. A couple of examples make the use of these classes clear. DozoWorld This class enables you to make and control an object which keeps a model of the 2D world in which Dozo navigates. Define a constructor that creates and initiates a DozoWorld using the rows that can be read from the file and give as paramenter the Board on which the world will be drawn. * public DozoWorld(String[] rows, Board bord) Next you can offer the next methods (this list isn't complete) * public Item getCel (int x, int y) Gives the item that is on that position (x,y). If there's no item on that position, you can, for example, have the method return the value null. * public void placeCel (int x, int y, Item item) Places the item on that position (x,y). * public void drawWorld() Draws the complete world, including Dozo, on the board. Item An object of the class Item can be attached to each cell. An item can, for example, be a box or a wall. Examples of interesting methods here are: * public boolean moveItem(int direction) This method tries to move the item in the given direction and returns whether or not this operation has succeeded. * public Item give Item(int direction) Gives the item that borders to the item on which the method has ran. * public int getX() Gives the x-coordinate back of the cell on which the item is. Wall You can define a Wall as subclass of Item. The method moveItem can be given a new implementation here. Dozo Dozo too can be defined as subclass of Item. Practical details Design your solution on an objectorientated manner. Keep in mind as well that your code has to be read and understood by other people: * Choose clear variable- and methodnames and keep yourself to the conventions concearning namegiving: names of variables and methods start with small letters, names of constants are fully in capitals, ... * Put structure in your code (indenting of blocks, ...) and add comments where needed. * Complicated methods can be best tested by using it in a different main of a different class and see if it has the right result. The world to be loaded and cursors, to move Dozo Processes:
Object properties change and objects on screen change accordingly Functions: See Processes |
||
|
|
07-12-2004, 04:09 PM | #7 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
OK, this would be a global plan. Now what's the plan for each of steps in process? Go to lovest level of code, but still in plain english.
|
||
|
|
07-12-2004, 04:40 PM | #8 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
1) Main program:
Set the board up and allow loading a world 2) Loading a world:
|
||
|
|
07-12-2004, 04:45 PM | #9 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
How do you like to set up coordinates?
|
||
|
|
07-12-2004, 04:49 PM | #10 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
Where the @ is in the world-file, it'll store the coordinates of that into an array which contains two ints. When doing the checking for the boxes, it'll copy this array and change the values. When Dozo moves, the array's values change too, to the new position.
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I need a Java tutorial... | Fubb | Programming | 12 | 13-04-2009 10:26 AM |
Java Software And Winxp Problems | Abi79 | Tech Corner | 13 | 17-08-2006 07:09 PM |
Java/html - Two Questions ... | swiss | Programming | 12 | 12-02-2006 10:57 AM |
How To Use Java Vm In Windows Xp? | The Fifth Horseman | Tech Corner | 19 | 27-07-2005 10:29 PM |
Java Game | Reaperman | Programming | 3 | 23-02-2005 02:27 PM |
|
|
||
  |