Question about a connect-four style system...

Blitz3D Forums/Blitz3D Beginners Area/Question about a connect-four style system...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Coorrae:
That was a gr8 piece of code m8. I like it, do you care if I use it in my puzzle game, I am going to make a function out of it, and pass in the piecex,piecey of the grid piece the player just shot, and also the identifying number of that piece, and have your code check the 7 dirs from that piece, and then setup if statements outside the loop for 4,3,2 hit combo's and then return the point values.

This is a very easy and efficient piece of code if it will work like I think it will. Here is how I modified it:

function checkpiece(newpiecex,newpiecey,number)
local points
For dir=0 To 7
	x=newpiecex
	y=newpiecey
	amount=1
	Repeat
		x=x+Ceil(Cos(dir*45))
		y=y+Ceil(Sin(dir*45))
		If fruitarray(x,y)\number<>number Then Exit
                if fruitarray(x,y)\number=number then
		  amount=amount+1
                  hideentity fruitarray(x,y)\item
                endif
	Forever
    
        if amount = 4 then 
          points = fruit\points * 4 + 500
          return points
        endif
        if amount = 3 then 
          points = fruit\points * 3 + 250
          return points
        endif
        if amount = 2 then 
          points = fruit\points * 2 + 100
          return points
        endif
        if amount = 1 then
          points = fruit\points
          return points
        endif
Next


What Ya Think ? Will it work ? I am going to call it in my player shoot function, when the player hits an item, take that item x,y coords and its number value, call this function, to test for combos, and return points, for the one the player did hit + any combos connected to it.

Ooops forgot one thing.. need to remove the other combo items connected as well. Soo.. Let me update this.

Okay I edited the code, can someone tell me if they think this will work right ? I am currently at work.

For additional info, the grid I use is 6x6 with items laid out in rows and columns. Will this work ?