![]() |
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.
|
Nice... :)
|
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.
|
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? :D
|
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. |
Assignment doc:
Code:
Task The world to be loaded and cursors, to move Dozo Processes:
Object properties change and objects on screen change accordingly Functions: See Processes |
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.
|
1) Main program:
Set the board up and allow loading a world 2) Loading a world:
|
How do you like to set up coordinates?
|
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.
|
into an array which contains two ints = multidimensional array?
|
First int is for x-coordinate, second for y-coordinate, so that it'll read like (x,y)
|
This topic seems more appropriate here.
|
Quote:
Create pseudo code of move. For example: move_up: -- do this -- check this -- do this From this you will get all needed functions to make a simple move Note: you can move, without pushing, if I'm not mistaken. Note 2. there was a game on PC Engine that is very similar to this. Very interesting and challenging game. |
Move_Dozo
|
Something is not right. :blink:
Try to complete couple things at once. |
Huh? :blink:
|
Woo! Was nozing through the example files given with this thing, and got the moving to work, along with loading the board. Nothing 'bout loading the world itself yet though :whistle:
|
steps you wrote are not exactly in the best order.
you should use part of logic for that other game you had (at least to calculate win position) post here your prograss ps. as you can see, i'm kind of busy myself, but will try to help ya if I can. :bye: |
's Alright :)
Right now, I've got this: The walking works, it can read a world-file and interprete the first line. I'm working on at least getting the loop for drawing the world on the playfield done today, so the big chunks're done and I can focus on the game itself. |
Tadaa! Loop works fine, except that it draw black spots instead of the boxes, but it knows where they have to come. Probably just named them wrong. Borders of any level are set too. Now the next part: Giving properties to each part (so that he won't walk through walls anymore)
|
|
you have to post the code trough forum. I have only VJ.net on this computer.
Also, can you explain in plain english what you like to accomplishe. While you do this, here is my recomendation for code (In example I'll write the pseudo code): [code] move up: check if cell is empty if yes, just move up if no, check if is the end of the world (:D) if yes, don't move, put something , or play some bad sound (perhaps fart :D) if no, check what colort is the first box you hitting check the next box if is empty, move only that one box if is not empty, check if next box is same color if it is, do the same check with next cell if not, play that bad sound again. in this checks, you should also make sure that you don't move world's blocks. also, can you tell how do you check win situation |
Well, that already works fine (but I like the fart-sound thing :D ) Main problem now is the winning condition. This's the code:
Code:
import bvp.*; |
Can you explain what are you trying to accoplish with each code?
|
Code:
import bvp.*; Code:
String bestandsnaam; Code:
// ******************************** Code:
// ****************************************************************** Code:
// ************************* Code:
// ***************************
You might notice some confusing thing in the array index... this formula: (y*dimX)+x. It's because before, when I just used x*y for the array index, x = 2, y = 5 had the same index as x = 5, y = 2, x = 1, y = 10 and x = 10, y = 1, as example. Too buggy. This formula's kinda the same as Row*maxColumns + Column from the Connect Four assignment (with difference that this matrix's point 0 is at the top left, not the bottom left) Code:
// ********************* Code:
// ********************************************* |
The move part has to be done in different way.
You have to have a lot of if statements. You start to move (no mather of direction) 1 - if is floor, move 2. if is not floor - check if is the wall 3. if is wall, don't move 4. if is box, check next space now same procedure (same stuff) with next box 1. if is floor, move 2. if is not floor, check if is the wall 3. if is wall, don't move 4. if is box, check the color 5. if is same color go to next box 6 if is different color color, don't move You can move only in 4 directions, this make it easy! |
Uhhhmmm... the moving works smoothly... everything's just fine, except for the winning condition.
|
how big is the world?
|
It's dimX, dimY big. It should be able to read any world-file. A world-file looks like this:
DIM 10 6 -> Defines the dimensions, in this case x = 10, y = 6 ...######. -> . = floor ..#.....#. -> # = wall .#@.B.R..# -> @ = player #BB..R..R# -> B = Box 1 (or box 2, I don't remember off the top of my head) #R.....B.# -> R = Other type of box ########## Of course, the comments to the right aren't included. It should be able to read worlds of 2x3 dimensions as well as worlds of 1234567890x1234567890 dimensions (which it can... tested that :D If it's 12345678901, it gives an error) Edit: just tested that world. It's impossible to win. That's what you get for throwing those characters around randomly :D |
do this....
Code:
for (numC = 0; numC <+ 3; numC ++) Some explanation: box1 = W --- box1 is the cooridinate of the first box, and if is equal to the color you are checking first loop ( 0 to 3) makes this code check if you have 3, 4, 5 or 6 blocks in the row ( make changes as you need, you need two separate functions to check win situation, one is from 4 - 6, second is from 3 - 4). NOTE: I just noticed that I mixed 3 and 4 boxes win situation. I don't have a time to fix it now. Gicve me an houd and I'll make this code look a bit better, I have to run to do something. |
's Alright. Thanks for the help :)
|
This is code for color that needs at least 4 boxes to desapear
Code:
for (numC = 0; numC <= 2; numC ++) simillar loop have to exist for 3 boxes: Code:
for (numC = 0; numC <= 1; numC ++) note, to win with 4 colored color, you can have 3+1, 3 + 2 or 3+ 3 boxes together. (you move 3 boxes, and there are already 3 staying, so when you connect them, you can have 6 boxes) |
Have you finish it? :blink:
|
Not yet. This thing makes me want to smash my head into the monitor. Your code'd work fine if it weren't for the groups having to exist out of at least 3 boxes for one type and at least 4 for the other. That code works for exactly 3 boxes and exactly 4, it seems. Wouldn't work for take 8 boxes linked together.
Right now, I changed some things to my code. That big-behind formula's changed and position's stored with coordinates. Spelbord's a double array now, like this: spelbord[x][y]. I also made it so that I know exactly how many boxes of each type are in the game, and got an algorythm to store their coordinates. x is stored in groupX[counter], y in groupY[counter], where counter is the amount found. Max. of those two arrays, is the amount of boxes of that type in total. Up to there, it works fine. The checking itself's still a giant pain in the behind and it's starting to frustrate me to no end that nothing I try even works the slightest. |
Quote:
For one of the boxes max you can have is 6 (one that needs 4 to disappear) and that is accomplished by moving 3 boxes and adding them on the group of 3. Other one (3 needed to disappear) can be 4 max. (2 moved to 2 standing unit). Reason for this is that you should not be able to have 4 or 3 boxes standing on the board, as they should already disappear. Do you understand this? Another suggestion, keep a world, boxes and player in array. (if you are not) |
Well, with 4 boxes to form a group, the max is 9. If the boxes are set up like this:
____B ____B BBB_B ___B_ ___B_ ___B_ If they push the lowermost row of three up one spot, all boxes'll have to disappear. Same when they push the horizontal row one more to the right. In the same way, the max for a group formed with at least 3 is 6. |
You mean in this case
Code:
___B_ Do this: Create additional array in which you will store coordinates of boxes that should disappear. Create 4 functions (2 for each case) that will go and check if there are boxes set that have met the criteria. In my code, change this: Code:
for (numC = 0; numC <= [B]2[/B]; numC ++) Code:
* * * if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W and box6 = W and box7 = W) Instead of boxes disappear function, add boxes coordinates to array. Run all 4 search functions, and after you done, create function that will go trough array with boxes that should disappear and delete them. Try this and let me know if it worked! |
Alright, let's see if it works.
|
Ok, added, but when compiling, it tells me box1, box2, etc aren't declared, and probably'll do the same for W. If I know what they're supposed to be, I can quickly change it... I hope.
Really don't understand much of the code yet. Looks to me like it won't be able to get something like BB BB _B or B__B BBBB Edit: reread the first post with the code and will get the Box1, etc right. Hold on... Edit edit: It works fine with a horizontal row, it seems, but vertical, or in a tetris-block... doesn't work yet. Code:
if (object == 1) { |
You should reuse same logic, just instead of *world width* use *world height*, and when you calculate wins, you use Y instead of X.
Same rule apply here. *you can have max 7 or 5 boxes* |
Now vertically works fine too, but a combination doesn't... it can't check this:
__B BBB Yet that's a good group too, just like: _B__ BBBB or BB BB |
what do you mean it can't check?
|
It won't recognize such groups as ready for removal.
|
Quote:
|
Yep.
Taken from the assignment doc... Following blocks are grouped correctly: http://www.filespace.org/Kon-Tiki/Assignment1.png These blocks aren't: http://www.filespace.org/Kon-Tiki/Assignment2.png |
Ok, made a recursive class... it works fine, but has one little quirk. It seems to take the first If-block that turns out to be true, does what's stated in there, then ignores the If-blocks after that one, hence it'll ignore certain boxes.
Code: Code:
public static void Checker(int doos1, int object, int[][] spelbord, int[] groepX, int[] groepY, int g, int teller, int[] CheckedX,int[] CheckedY) { |
what this code suposed to do? :blink:
|
It's supposed to check in each direction of the current object if there's an object of the same type, then do the same for that one, if it's not checked yet, while checking further.
|
THat would be to big code. What do you need is code simillar to ona you already have.
Just scatch all options, and always start from the bottom left, make range you can make with that code (for example 4 boxes made of 2 by 2 you can check from bottom left by going 1 to right, and then top line also first and one to right box, and you don't need code for the last column or row, as from there you can't make 4 boxes that way. So all you neeed is just same code, made for all possible solutions. |
Ok, got the recursive thing done, and the removal of the boxes. Sent it in, too, so no use in changing it now to make it better. It's got a couple of bugs left in though.
1) It still refuses to check the other directions after finding a direction that works fine. 2) The boxes'll only be removed when you walk past one box in the group. 3) Pushing a box into a wall'll get an index out of bound in an array somewhere. 4) I got weird results when trying to see if you won or not, so I left that out (as it wasn't obligatory anyways :whistle: ) |
The current time is 10:46 PM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.