Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms



We keep some of our unique code below



RECUSRION, RECURSION, RECUSION!!!
This working code is from the game Block Drop that you can play now right here Xpounded Block Drop

Goal: given an m x n matrix filled with N colored balls and a specific ball selected, find a chain of all the balls that are the same color and connected to the origional selected ball by an unbroken path of matching colors.

113
213
411

There are 4 directions to check for every color match found - Up, Down, Left, Right.
All checks are simmilar - only the first will be annotated.

Only two functions and two arrays are required for the solution:
mtrx is a 1-dimensional matrix representing a 2-dimensional board.
adj is a 1-dimensional matrix used to store the board location of a chain member.
findAdj2( ) recurses through the board locations looking for color matches
indexIsNew( ) cheks a location for uniqueness in a chain
[START...]
function findAdj2(index){
	var checkIndex = 0		//checkIndex is used to hold board location being examined 
	checkIndex = index-10		//check the location above the current location
	if(checkIndex>0){
		//if the color of the new location is the same AND 
		//the new location has not been added to the chain...
		if((mtrx[checkIndex]==mtrx[index]) && indexIsNew(checkIndex)){
			adj[adjCount++]=checkIndex;	//a new match is found, add it to the chain 
			findAdj2(checkIndex);		//do it all over for the new matching location
		}
	}
	if((checkIndex%10)!=0){
		checkIndex = index-1	//check the location to the left of the current location
		if(checkIndex>0){
			if((mtrx[checkIndex]==mtrx[index]) && indexIsNew(checkIndex)){
				adj[adjCount++]=checkIndex;
				findAdj2(checkIndex);
			}
		}
	}
	if((checkIndex%10)!=9){
		checkIndex = index+1	//check the location to the right of the current location
		if(checkIndex<100){
			if((mtrx[checkIndex]==mtrx[index]) && indexIsNew(checkIndex)){
				adj[adjCount++]=checkIndex;
				findAdj2(checkIndex);
			}
		}
	}
	checkIndex = index+10		//check the location below the current location
	if(checkIndex<100){
		if((mtrx[checkIndex]==mtrx[index]) && indexIsNew(checkIndex)){
			adj[adjCount++]=checkIndex;
			findAdj2(checkIndex);
		}
	}
}

//Used to chack for chain membership.
//returns true if the location is not already in the chain
function indexIsNew(candidateIndex){
	var addNewIndex=true		//Initiate to return a new location
	for(i=0;i<adj.length;i++){
		if(adj[i]==candidateIndex){	
			addNewIndex=false	//the location is already in the chain.
		}
	}
	return addNewIndex	//return either true (new location) or false (location already in chain)
}	

[...END]

You will need to supply your own sound effects and bullet graphics for this one.
This object is a complete shooter for any page,
It displays a clip full of bullets,
When the mouse is cliked it plays a shot sound and
plays an explosion animation at the current cursor position,
and follows up by puttinf a bullet hole,
removes bullet graphics from the clip as they used,
and offers a reload option when the bullets are gone.
See Xpounded Shooter for a working demostration.
[START...]

//Add these two soundes to your page body (this is the only step absolutely required)
//<embed name='shooting' src="effects\splam.wav" loop=false autostart=false mastersound hidden=true width=0 height=0 volume=70></embed>
//<embed name='empty' src="effects\emptyClip.wav" loop=false autostart=false mastersound hidden=true width=0 height=0 volume=70></embed>

//make sure you call makeClip(xpos,ypos) to initialize bullets
//function init(){
//	makeClip(bullits,posX,posY)
//}

//you need to add shootBuulit to your onclick routine like so...
document.onclick = function rhsbullits(){
	shootBullit()
}
var bullit = new Array()
var numBullits = 5
var bullits = numBullits
var reloadDiv
var explosionCounter = 0
var explosions = new Array()
var bh = "../images2/bullitHole.gif"
var explode = new Array()
explode[0] = "../images2/gexpl1.gif"
explode[1] = "../images2/gexpl2.gif"
explode[2] = "../images2/gexpl3.gif"
explode[3] = "../images2/gexpl4.gif"
explode[4] = "../images2/gexpl5.gif"
explode[5] = "../images2/gexpl6.gif"
explode[6] = "../images2/gexpl7.gif"
explode[7] = "../images2/gexpl8.gif"
function makeClip(bull,px,py){
	numBullits = bull
	bullits = numBullits
	for(i=0;i<=numBullits;i++){
		bullit[i] = document.createElement("IMG")
		bullit[i].src = "../images2/bullit.gif"
		bullit[i].style.position = "absolute"
		bullit[i].style.visibility = "visible"
		bullit[i].style.left = px + i*10
		bullit[i].style.top = py
		bullit[i].width = "10"
		bullit[i].height = "40"
		document.body.appendChild(bullit[i])
	}
	reloadDiv = document.createElement("DIV")
	reloadDiv.id = "reload"
	reloadDiv.style.position = "absolute"
	reloadDiv.style.top = py
	reloadDiv.style.left = px
	reloadDiv.style.cursor = "hand"
	reloadDiv.style.width = 50
	reloadDiv.style.visibility = "hidden"
	reloadDiv.style.background = "beige"
	reloadDiv.setAttribute("onclick",function anonymous(){reloadGun()})
	reloadDiv.style.fontWeight = "bold"
	reloadDiv.innerText = "RELOAD"
	document.body.appendChild(reloadDiv)
}
function shootBullit(){
	if(bullits>-1){
		bullit[bullits--].style.visibility = "hidden"
		explosions[explosionCounter] = new oneShotSprite("explosion" + explosionCounter,explode)
		x = window.event.x - 40
		y = window.event.y - 40

		var oo = document.elementFromPoint(x+40,y+40)
		if(oo!==null){
			if(oo.id!=""){
				jsobjectmessaging(oo)
			}
		}

		explosions[explosionCounter].start("explosions[" + explosionCounter++ + "]",70,x,y)
		shooting.play()
		if(explosionCounter>10) explosionCounter=0
		if((oo!=null) && (oo.target=="true")){
			//do nothing
		}
		else{
			var d = document.createElement("IMG")
			d.src = bh
			d.style.position = "absolute"
			d.style.left = x + 24
			d.style.top = y + 24
			document.body.appendChild(d)
		}
	}
	else {
		empty.play()
		reload.style.visibility = "visible"
	}
}
function reloadGun(){
	for(i=0;i<=numBullits;i++){
		bullit[++bullits].style.visibility = "visible"
	}
	window.event.cancelBubble = true
	reload.style.visibility = "hidden"
}
//copy this messaging function and use it to control what events to respond to
//function jsobjectmessaging(obj){
//}

Below is the oneshotsprite object code (for one shot animation) used by the bullit object above.
The anim argument is an array of images used for the animation

function oneShotSprite(sid,anim){
	this.anim = anim
	this.image = document.createElement("IMG")
	this.image.style.position = "absolute"
	this.image.style.posLeft = -100
	this.image.style.posTop = -100
	this.x = -100
	this.y = -100
	this.image.src = anim[0]
	this.inanim=false
	this.frames = anim.length
	this.frame = 0
	this.put = putAnim
	this.run = animate
	this.start = startaction
	this.stop = stopaction
	document.body.appendChild(this.image)
	function putAnim(px,py){
		this.image.style.posLeft = px
		this.image.style.posTop = py
	}
	function animate(){
		this.frame++;
		if(this.frame > this.frames){
			this.frame=1;
			this.image.src=this.anim[this.frame-1]
			this.stop()
			this.put(-100,-100)
			this.inanim = false
		}
		else	this.image.src=this.anim[this.frame-1];
	}
	function startaction(f,t,px,py){
		if(!this.inanim){
			this.put(x,y)
			this.inanim = true
			var func = f + ".run()"
			this.iTimer = setInterval(func,t)
		}
	}
	function stopaction(){
		clearInterval(this.iTimer)
	}
}

[...END]

Linear Motion
[START...]

	this.radius += increment;
	this.x = this.origX + Math.floor(this.radius*Math.cos(angle))
	this.y = this.origY + Math.floor(this.radius*Math.sin(angle))
	this.image.style.left = this.x
	this.image.style.top = this.y

[...END]

VBS QuickDev IDE is great when it comes to getting results fast
Below is the complete VBS QuickDev IDE 34 line source that generates a XSL Muliple Document Translation Application.
[START...]

Sub translateFiles(fle)
	Dim sst
	sst = extractName(fle)
	stAll = stAll & "______________________________________________" & vbcrlf & sst & vbcrlf 
	vell = readFile(fle)
	firstLine="Unknown"
	vvv=split(vell,vbcrlf)
	for i = 0 to ubound(vvv)
		if vvv(i)<>"" then
			firstLine = vvv(i) & vbcrlf & vvv(i+1)
			exit for
		end if
        next
	stAll = stAll & "Start Of File: " & firstLine & vbcrlf
	stAll = stAll & ValidateXML(fle) & vbcrlf
End Sub
'*************
Dim gcount, tcount, stAll, resFile
gcount = 0
tcount = 0
gPath = folderDialog("XML Folder",desktop)
If gPath <>"" Then
	g2Path = openDialog(desktop,"XSL Files|*.xsl") 
	If g2Path <> "" Then
		forallfiles gPath, "translateFiles"
	End If
End If
If stALL<>"" Then
	stALL = gcount & " out of " & tcount & " files validated successfully." & vbcrlf & stALL
	resFile = g2Path & "Validation Results.txt"
	saveFile resFile, stALL
	runWithArg "notepad",resFile
Else
	msgbox "No Translations",vbokonly,"No Work Was Done"
End If

[...END]

Thanks for viewing.
- Copyright 2003 Xpounded -
All JS code developed by Xpounded is developed in RHSCoder.
All VBS code developed by Xpounded is developed in VBS QuickDev IDE, or RHSCoder.
Privacy Statement
Feedback