Severe help needed

Blitz3D Forums/Blitz3D Programming/Severe help needed

Rook Zimbabwe(Posted 2004) [#1]
I finished and it is 90% all my own code. Thats why it doesn't seem to work or it works really weird. I am posting it here to see if someone on this board... who I would gladly buy a round for... can figure out the error of my ways.

I think it is commented pretty well. All it tries to do is set up 10 rows and put colored bits on them.

When you click your mouse it puts a 0 at that row and location...

Then it makes a new colored bit and pops it in the location

Then it checks for 3 in a row of the same color

If there are 3 in a row of the same color it ZEROs them and pops a new set of colors in those locations...

Simple really

So why does it not work!

EDIT:: I went back to a 2D array... the speed is MUCH improved bu still slooooowwwww on mousepick and the incorrect coords are returned... Row and col must be from 0 to 9 bot 10!!!

-Rook


Bot Builder(Posted 2004) [#2]
whoah jeez. ugly code no offense... I'll try to make it smaller so its easier to see the problem. I would recommend trying to use arrays to a better extent. and loops. (I just had to get in the first post - I'm gonna go make it better now :P)


Rook Zimbabwe(Posted 2004) [#3]
Yes yes yes... ugly... new code posted now... isn't really more beautiful!!! cleaner though... compared to first version!!!


Bot Builder(Posted 2004) [#4]
Oh ok. Yeah. that's better. How about putting you pieces into an array? that would be easy so instead of

do this...
Function put_row()
	For row = 0 To 9
		For col=0 To 9
			obj=CopyEntity(Piece(Board(row,col)))
			PositionEntity obj,row*10-45,4,col*10-45
		Next
	Next
End Function


Much more neat and no more nead for boardx(),boardy() arrays. Piece is an array that holds handles of the different objects.

Also, you may notice its really slow (this is probably also your problem) - you aren't deleting the objects. You are doing it like a 2d game - creating objects every frame (drawimage), but in 3d they don't go away. I would recommend just leaving the objects their, and deleting/adding as necessary.

Also, in check zero you can do Rand(1,12) instead of Rand(11)+1


Rook Zimbabwe(Posted 2004) [#5]
I did clean the code quite a bit. You had several good sugestions... posted new code above...

Do have 1 q???
I would recommend just leaving the objects their, and deleting/adding as necessary.
You mean just plop the peices on the board and instead of plopping NEW pieces... I should just change the colors of those pieces???

You know I have rewritten this game three times... learning more about how Blitz handles arrays each time. I supose that each piece would just have to have a unique handle.

I am just going to have to get back in to types... {sigh} I like them but I don't understand how to modify them yet.


Bot Builder(Posted 2004) [#6]
[quote]You mean just plop the peices on the board and instead of plopping NEW pieces... I should just change the colors of those pieces???p/quote] Definitly, if that's an option. If you want to change the model as well, you'll have to delete the piece and then add another. You could have somthing like this:
Dim Entity(9,9)

Function SetPiece(Row,Col,ID)
	FreeEntity Entity(Row,Col)
	Entity(Row,Col)=CopyEntity(Piece(ID))
	PositionEntity Entity(Row,Col),row*10-45,4,col*10-45
End Function


Then, whenever you change somtrhing in the board array, use the SetPiece function to set the 3d visuals.