Go Back   Forums > Community Chatterbox > Tech Corner
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 10-12-2004, 02:43 PM   #31
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

do this....


Code:
for (numC = 0; numC <+ 3; numC ++)
{
 *for( numX = 0; numX < 'width of wold' - 3 - numC; numX++)
 *{
 * * for( numY = 0; numY < 'height of world'; numY ++)
 * * {
 * * * *if( numC = 0 )
 * * * *{
 * * * * * *if( box1 = W and box2= W and box 3 = W)
 * * * * * *{
 * * * * * * * * BoXeS desapear function
 * * * * * * }
 * * * *}
 * * * *if( numC = 1 )
 * * * *{
 * * * * * *if( box1 = W and box2= W and box3 = W and box4 = W)
 * * * * * *{
 * * * * * * * * BoXeS desapear function
 * * * * * * }
 * * * * }
 * * * *if( numC = 2 )
 * * * *{
 * * * * * *if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W)
 * * * * * *{
 * * * * * * * * BoXeS desapear function
 * * * * * * }
 * * * * }
 * * * * if( numC = 3 )
 * * * *{
 * * * * * *if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W and box6 = W)
 * * * * * *{
 * * * * * * * * BoXeS desapear function
 * * * * * * }
 * * * * }
 * *}

 *}
}
This is function that calculates horisontally if boxes should desapear. You can use select case statement in inner for loop, which will make code work better.

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.
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 10-12-2004, 02:54 PM   #32
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

's Alright. Thanks for the help
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 10-12-2004, 03:57 PM   #33
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

This is code for color that needs at least 4 boxes to desapear
Code:
for (numC = 0; numC <= 2; numC ++)
{
 *for( numX = 0; numX < 'width of wold' - 3 - numC; numX++)
 *{
 * *for( numY = 0; numY < 'height of world'; numY ++)
 * *{ * * * * * 
 * * *if( numC = 0 )
 * * *{
 * * * *if( box1 = W and box2= W and box3 = W and box4 = W)
 * * * *{
 * * * * *BoXeS desapear function
 * * * *}
 * * *}
 * * *if( numC = 1 )
 * * *{
 * * * *if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W)
 * * * * *{
 * * * * * *BoXeS desapear function
 * * * * *}
 * * * *}
 * * *if( numC = 2 )
 * * *{
 * * * *if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W and box6 = W)
 * * * *{
 * * * * *BoXeS desapear function
 * * * *}
 * * *}
 * *} *// for numY loop ends
 *} *// for numX loop ends
} *// for numC loop ends
This code checks boxes in if loop. Box1 is the first one (start point), Box2 = cooridinate of box next to the box1. (Increase x value in cooridinate) etc.

simillar loop have to exist for 3 boxes:

Code:
for (numC = 0; numC <= 1; numC ++)
{
 *for( numX = 0; numX < 'width of wold' - 2 - numC; numX++)
 *{
 * *for( numY = 0; numY < 'height of world'; numY ++)
 * *{ * * * * * 
 * * *if( numC = 0 )
 * * *{
 * * * *if( box1 = W and box2= W and box3 = W)
 * * * *{
 * * * * *BoXeS desapear function
 * * * *}
 * * *}
 * * *if( numC = 1 )
 * * *{
 * * * *if( box1 = W and box2= W and box3 = W and box4 = W)
 * * * *{
 * * * * *BoXeS desapear function
 * * * *}
 * * *}
 * *} *// for numY loop ends
 *} *// for numX loop ends
} *// for numC loop ends
do the same for vertical

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)
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 11-12-2004, 06:54 PM   #34
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

Have you finish it? :blink:
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 11-12-2004, 07:25 PM   #35
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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.
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 11-12-2004, 07:37 PM   #36
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

Quote:
Originally posted by Kon-Tiki@Dec 11 2004, 03:25 PM
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.
You should not be able to link 8 boxes together!

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)
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 11-12-2004, 07:43 PM   #37
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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.
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 11-12-2004, 08:06 PM   #38
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

You mean in this case

Code:
___B_
___B_
___B_
BBB_BBB< move this box to left
___B_
___B_
___B_
Total 12 boxes that should disappear! :blink:


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 ++)
to 3, and add additional line to check 7 boxes in the line:

Code:
 * * * if( box1 = W and box2= W and box3 = W and box4 = W and box5 = W and box6 = W and box7 = W)
 * * * {
 * * * * BoXeS disappear function
 * * * }

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!
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 11-12-2004, 08:13 PM   #39
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

Alright, let's see if it works.
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 11-12-2004, 08:42 PM   #40
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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) {

 *CheckedX = new int[doos1];
 *CheckedY = new int[doos1]; *
 *
 *for (g = 0; g <= 3; g++) {
 *	for (int numX = 0; numX < ((dimX - 3) - g); numX++) {
 * *for(int numY = 0; numY < dimY; numY ++) {
 * *	if(g == 0) {
 * * *if (spelbord[numX][numY] == object && spelbord[numX+1][numY] == object && spelbord[numX+2][numY] == object && spelbord[numX+3][numY] == object) {
 * * *	System.out.println("Boxes disappear.");
 * * *}
 * *	}
 * *	if(g == 1) {
 * * *if(spelbord[numX][numY] == object && spelbord[numX+1][numY] == object && spelbord[numX+2][numY] == object && spelbord[numX+3][numY] == object && spelbord[numX+4][numY] == object) {
 * * *	System.out.println("Boxes disappear."); * *
 * * *}
 * *	}	
 * *	if(g == 2) {
 * * *if(spelbord[numX][numY] == object && spelbord[numX+1][numY] == object && spelbord[numX+2][numY] == object && spelbord[numX+3][numY] == object && spelbord[numX+4][numY] == object && spelbord[numX+5][numY] == object) {
 * * *	System.out.println("Boxes disappear.");
 * * *}
 * *	}
 * *	if(g == 3) {
 * * *if(spelbord[numX][numY] == object && spelbord[numX+1][numY] == object && spelbord[numX+2][numY] == object && spelbord[numX+3][numY] == object && spelbord[numX+4][numY] == object && spelbord[numX+5][numY] == object && spelbord[numX+6][numY] == object) {
 * * *	System.out.println("Boxes disappear.");
 * * *}
 * *	}

 * *}
 *	}
 *} *
	}
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Reply


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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 02:54 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.