Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 1st, 2002, 10:32 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Cool A sure fire sign of boredom... the Matrix

I was bored, what more can I say? I was in a creation mood, and I had nothing to create. So I thought why not attempt something... so what I attempted was a Matrix kind of thing. You know, the classic, scrolling down the screen numbers things.

So here's what I came up with:

<html>
<head>
<script type="text/javascript">
var count = 0
var greens = new Array ('527B10','639C18','7BC618','94D639')
codeNumber = ""
for (x = 0; x < 30; x++) {
thisNumber = Math.floor(Math.random() * 10)
codeNumber += thisNumber.toString()
}
function breakCode() {
stop = false
thisDiv = document.createElement('div');
thisDiv.setAttribute ('id' , 'div' + count)
document.getElementsByTagName('body')[0].appendChild(thisDiv)

document.getElementById('div' + count).style.width = "100%"
page = "<table cellpadding='0' cellspacing='0' width='100%'><tr>"
codeAttempt = ""
for (x = 0; x < 30; x++) {
page += "<td align='center' "
page += "style='color:#" + greens[Math.floor(Math.random() * greens.length)] + ";"
Math.random() * 10 > 5 ? page += "font-weight:bold;" : page += "" ;
page += "'"
page += ">"
thisNumber = Math.floor(Math.random() * 10)
codeAttempt += thisNumber.toString()
page += thisNumber
page += "</td>"
}
page += "</tr></table>"
document.getElementById('div' + count).style.position = "absolute"
document.getElementById('div' + count).style.top = 0
document.getElementById('div' + count).style.left = 0
document.getElementById('div' + count).innerHTML = page
divs = document.getElementsByTagName('div')
for (x = 0; x < divs.length; x++) {
thisDiv = eval("document.getElementById('" + divs[x].id + "').style")
thisDiv.top = parseInt(thisDiv.top) + 20
if (parseInt(thisDiv.top) > document.body.offsetHeight - 40) {
thisDiv.display = "none"
}
}
count++
if (parseInt(codeAttempt) != codeNumber) {
setTimeout("breakCode()", 1)
} else {
document.getElementById('div' + count).style.backgroundColor = "#ff0000"
}
}
</script>
</head>
<body onLoad="breakCode()" style="background-color:black; font-size:14pt">
</body>
</html>

It works in IE6. As yet, it has no 'artificial intelligence' in otherwords it scrolls but doesn't actually do anything other than take random stabs at the 30 digit number it generates. I will be adding the intelligence soon, stay tooned!

P.S. I said I was bored.
__________________
- Sorted!

www.ppfuk.com - Free Photo Sharing

Reply With Quote
  #2  
Old May 1st, 2002, 11:16 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Okay, the updated version:

<html>
<head>
<script type="text/javascript">
var count = 0
var greens = new Array ('527B10','639C18','7BC618','94D639')
var codeNumber = ""
var brokenNumbers = new Array()
var codeLength = 10 // change this number to increase the code length
var timeNow = new Date
var startTime = timeNow.getTime()

for (x = 0; x < codeLength; x++) {
thisNumber = Math.floor(Math.random() * 10)
codeNumber += thisNumber.toString()
}
for (x = 0; x < codeLength; x++) {
brokenNumbers[x] = ""
}
function generateNumber() {
codeAttempt = ""
for (x = 0; x < codeLength; x++) {
thisNumber = Math.floor(Math.random() * 10)
codeAttempt += thisNumber.toString()
}
for (x = 0; x < codeLength; x++) {
if (brokenNumbers[x] != "") {
substr1 = codeAttempt.substr(0,x)
substr2 = codeAttempt.substr(x + 1, codeAttempt.length)
codeAttempt = substr1 + brokenNumbers[x] + substr2
}
}
return codeAttempt
}

function breakCode() {
stop = false
thisDiv = document.createElement('div');
thisDiv.setAttribute ('id' , 'div' + count)
document.getElementsByTagName('body')[0].appendChild(thisDiv)

document.getElementById('div' + count).style.width = "100%"
page = "<table cellpadding='0' cellspacing='0' width='100%'><tr>"
codeAttempt = generateNumber()
for (x = 0; x < codeLength; x++) {
page += "<td align='center' "
page += "style='color:#" + greens[Math.floor(Math.random() * greens.length)] + ";"
Math.random() * 10 > 5 ? page += "font-weight:bold;" : page += "" ;
page += "'"
page += ">"
thisNumber = codeAttempt.substr(x,1)
thisNumber == codeNumber.substr(x,1) ? brokenNumbers[x] = thisNumber : false ;
page += thisNumber
page += "</td>"
}
page += "</tr></table>"
document.getElementById('div' + count).style.position = "absolute"
document.getElementById('div' + count).style.top = 0
document.getElementById('div' + count).style.left = 0
document.getElementById('div' + count).innerHTML = page
divs = document.getElementsByTagName('div')
for (x = 0; x < divs.length; x++) {
thisDiv = eval("document.getElementById('" + divs[x].id + "').style")
thisDiv.top = parseInt(thisDiv.top) + 20
if (parseInt(thisDiv.top) > document.body.offsetHeight - 40) {
thisDiv.display = "none"
}
}
count++
for (x = 0; x < codeLength; x++) {
brokenNumbers[x] == codeNumber.substr(x,1) ? match = true : match = false ;
if (!match) {
break
}
}

if (!match) {
setTimeout("breakCode()", 1)
} else {
var timeNow = new Date
endTime = timeNow.getTime()
timeTaken = endTime - startTime
thisDiv = document.createElement('div');
thisDiv.setAttribute ('id' , 'div' + count)
document.getElementsByTagName('body')[0].appendChild(thisDiv)
document.getElementById('div' + count).style.position = "absolute"
document.getElementById('div' + count).style.top = 0
document.getElementById('div' + count).style.left = 0
document.getElementById('div' + count).style.color = '527B10'
document.getElementById('div' + count).innerHTML = "Match found.... code number is " + codeNumber + " (execution time: " + (timeTaken/1000) + " seconds)"
for (x = 0; x < divs.length; x++) {
thisDiv = eval("document.getElementById('" + divs[x].id + "').style")
thisDiv.top = parseInt(thisDiv.top) + 20
if (parseInt(thisDiv.top) > document.body.offsetHeight - 40) {
thisDiv.display = "none"
}
}
}
}
</script>
</head>
<body onLoad="breakCode()" style="background-color:black; font-size:14pt">
</body>
</html>

Reply With Quote
  #3  
Old May 1st, 2002, 11:26 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
That's pretty neat, makes me want to pick up more javascript. . . (though I just got out of therapy induced by trying to cross-browser debug it. . .)

Given my purist, control-freakish ways, I just naturally gravitate toward server-side stuff.

Pretty cool. . .

Reply With Quote
  #4  
Old May 1st, 2002, 02:46 PM
Keiichi Keiichi is offline
aHVoPw==
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2001
Posts: 1,058 Keiichi User rank is Lance Corporal (50 - 100 Reputation Level)Keiichi User rank is Lance Corporal (50 - 100 Reputation Level)Keiichi User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 15 h 24 m 31 sec
Reputation Power: 9
That's pretty cool
What exactly is that code matching thing?
Is it like generating a random string from the array and trying to match it or something?

You know what'd be cool? Do it all with 1's and 0's. Wasn't it done with them in that movie? I think *scratches head*
__________________
K1

Reply With Quote
  #5  
Old May 1st, 2002, 02:50 PM
caguru's Avatar
caguru caguru is offline
<insert title here>
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: at home
Posts: 405 caguru User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 59 sec
Reputation Power: 8
i likes
__________________
--the key to life is avoiding death--

Reply With Quote
  #6  
Old May 1st, 2002, 08:13 PM
roninblade's Avatar
roninblade roninblade is offline
// no comment
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2001
Posts: 1,639 roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level)roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level)roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level)roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level)roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level)roninblade User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 45 m
Reputation Power: 33
man, i wish i had a lot of time to kill like you do.

Reply With Quote
  #7  
Old May 2nd, 2002, 03:15 AM
NoXcuz's Avatar
NoXcuz NoXcuz is offline
Wiking
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Sep 2000
Location: Sweden
Posts: 3,608 NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 7 h 49 m 27 sec
Reputation Power: 21
binky, which pill did you take, the red one or the blue one?

Impressive though...

//NoXcuz
__________________
UN*X is sexy!
who | grep -i blonde | date; cd ~; unzip; touch; strip; finger; mount; gasp; yes; uptime; umount; sleep

Reply With Quote
  #8  
Old May 3rd, 2002, 04:35 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Maybe that was why I was off work with a headache though, thinking that one through was tough.

It just generating a number itself, the length of the number is controlled by a variable, then it randomly tries numbers until it finds the correct ones.

Suppose it stands to reason that it was 1s and 0s on the film, base2 and not base10 would be right. May change it, or go alpha numeric to make it more complicated.

NoXcuz.... if only..

Reply With Quote
  #9  
Old May 9th, 2002, 04:51 AM
deepspring's Avatar
deepspring deepspring is offline
Is a Psycho
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: In your computer
Posts: 231 deepspring User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to deepspring Send a message via Yahoo to deepspring
Very nice binky...
__________________
deepspring

- "Netscape 4 users are like lemmings... You can't help but laugh when one falls off a cliff"

Reply With Quote
  #10  
Old May 9th, 2002, 05:24 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Cheers!


Reply With Quote
  #11  
Old May 9th, 2002, 09:35 PM
Number Three's Avatar
Number Three Number Three is offline
Obsolete Vernacular
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: 76012
Posts: 272 Number Three User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 49 m 53 sec
Reputation Power: 8
Send a message via AIM to Number Three Send a message via MSN to Number Three Send a message via Yahoo to Number Three
Thumbs up Looks Cool!

I like it a lot. Now if only you could add the Japanese characters in and have pieces of the code zoom/fade towards the user.

Reply With Quote
  #12  
Old June 24th, 2003, 04:53 PM
flirweb flirweb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 1 flirweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Matrix - Reloaded

Guys,

here is a bit Javascript that does the Matrix effect even better...

html>
<head>
<title>Matrix-like</title>
<script language="JavaScript">
/*
filter:fliph;

*/
</script>
<style>
body{
font-size:10pt;
font-weight:normal;
background-color:#000000;
color:#000000;
}
</style>
</head>
<body scroll=no>
<script language="JavaScript">
// definition de quelques valeurs
var cw=document.body.clientWidth
var ch=document.body.clientHeight
var nb_cols=Math.floor(cw/16)
// nb_cols--
var nb_rows=Math.floor(ch/30)
nb_rows--
var dk_colors=new Array("#173317","#215221")
var normal_color="#40A241"
var light_color="#A9F0AC"
var rnd_gly=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",",","/","+","-","*","_","{","%","!",".",";","$","1","2","3","4","5","6","7","8","9","0")

// boucle collones et char+couleurs
for(n_col=0;n_col<=nb_cols-1;n_col++){
document.write("<div id=d"+n_col+" style='position:absolute;top:0px;'><tt></div>")
document.getElementById("d"+n_col).style.width=16
document.getElementById("d"+n_col).style.left=(n_col*16)
var nb_chars=Math.floor(Math.random()*(nb_rows))
document.getElementById("d"+n_col).style.height=(nb_chars+1)*30
var h_div=parseInt(document.getElementById("d"+n_col).style.height)
// pour vérifier ajouter à la ligne en dessous //
document.getElementById("d"+n_col).style.top=-h_div
document.getElementById("d"+n_col).style.filter="fliph"


// mettre des caracteres avec des couleurs
for(n_char=0;n_char<=nb_chars;n_char++){
if(n_char<=1){
document.getElementById("d"+n_col).innerHTML+="<tt><font color='"+dk_colors[n_char]+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt><br>"
}else if((n_char>1)&&(n_char<nb_chars)){
document.getElementById("d"+n_col).innerHTML+="<tt><font color='"+normal_color+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt><br>"
}else{
document.getElementById("d"+n_col).innerHTML+="<tt><font color='"+light_color+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt>"
}
}
// fin de déf des char_colorés ^
}
// fin boucle collones ^


var deja_fait_st=new Array()
var deja_fait_st_index=0

function del_et_restart(numero){
// del HTML
document.getElementById("d"+numero).innerHTML="<tt>"
// resiZe
var nb_chars=Math.floor(Math.random()*(nb_rows))
document.getElementById("d"+n_col).style.height=(nb_chars+1)*30
var h_div=parseInt(document.getElementById("d"+n_col).style.height)
document.getElementById("d"+n_col).style.top=-h_div
// re-cholor et text
for(n_char=0;n_char<=nb_chars;n_char++){
if(n_char<=1){
document.getElementById("d"+numero).innerHTML+="<tt><font color='"+dk_colors[n_char]+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt><br>"
}else if((n_char>1)&&(n_char<nb_chars)){
document.getElementById("d"+numero).innerHTML+="<tt><font color='"+normal_color+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt><br>"
}else{
document.getElementById("d"+numero).innerHTML+="<tt><font color='"+light_color+"'>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</font></tt>"
}
}
}





bas()
function bas(){
for(n_col=0;n_col<=nb_cols-1;n_col++){
if(parseInt(document.getElementById("d"+n_col).style.top)<=ch){
document.getElementById("d"+n_col).style.top=parseInt(document.getElementById("d"+n_col).style.top)+30
}else{
del_et_restart(n_col)
}
}
window.setTimeout("bas()",50)
}


/* bas_st()
function bas_st(){
var current_down=Math.random()*nb_cols
// recherche
for(i=0;i<=deja_fait_st.length;i++){
if (deja_fait_st.slice(i,i+1).substring(current_down)==-1){
deja_fait_st[deja_fait_st_index]=current_down
deja_fait_st_index++
}
else break
}
if(deja_fait_st==nb_cols){
void(0)
}else{
document.getElementById("d"+n_col).style.top+=30
bas_st()
}
}


window.alert(nb_cols)
window.alert(nb_rows)
window.alert(nb_cols*nb_rows)
document.write("<nobr>")

for(n_col=0;n_col<=nb_cols-1;n_col++){
document.write("<div id=d"+n_col+" style='position:absolute;top:0px;'><tt>"+rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"</div>")
document.getElementById("d"+n_col).style.width=16
document.getElementById("d"+n_col).style.left=(n_col*16)
document.getElementById("d"+n_col).style.top=0
document.getElementById("d"+n_col).style.height=ch-10
// document.getElementById("d"+n_col).style.filter="fliph"
// boucle contenu
for(i=0;i<nb_rows;i++){
document.getElementById("d"+n_col).innerHTML+=rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"<br>"
}
document.getElementById("d"+n_col).innerHTML+=rnd_gly[Math.floor(Math.random()*rnd_gly.length)]
}
document.write("</nobr>")
window.setTimeout("down()", 5)

function down(){
for(n_col=0;n_col<=nb_cols-1;n_col++){
document.getElementById("d"+n_col).innerHTML=rnd_gly[Math.floor(Math.random()*rnd_gly.length)]+"<br>"+document.getElementById("d"+n_col).innerHTML
// document.getElementById("d"+n_col).innerHTML=document.getElementById("d"+n_col).innerHTML.substring(0, document.getElementById("d"+n_col).innerHTML.lastIndexOf("<br>"))
}
window.setTimeout("down()", 500)
}



*/
</script>
</body>
</html>

Reply With Quote
  #13  
Old June 24th, 2003, 08:00 PM
Stink Sleeve's Avatar
Stink Sleeve Stink Sleeve is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2003
Location: New Hampshire, USA
Posts: 550 Stink Sleeve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 17 m 26 sec
Reputation Power: 6
Two different things....Although both really nice.

Who has the credits on the above post?
__________________
Download Mozilla Firefox Now!

Reply With Quote
  #14  
Old June 26th, 2003, 09:52 AM
mohecan mohecan is offline
Contributing User