Created
August 22, 2014 06:02
-
-
Save tommyjtl/12fbda89b5f669ae8afe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<!-- Mirrored from justplaymobile.com/freegames/goosyfarmer/480px.htm by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 15 Oct 2013 06:30:04 GMT --> | |
<head> | |
<title>Goosy Farmer</title> | |
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/> | |
<meta name="oupengmobile" content="landscape" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<style type="text/css"> | |
* | |
{ | |
margin: 0; | |
padding: 0; | |
border: 0; | |
outline: 0; | |
} | |
body | |
{ | |
width: 100%; | |
height: 100%; | |
background-color: #000; | |
color: #FFF; | |
font-family: Impact, Charcoal, sans-serif; | |
} | |
div | |
{ | |
position: absolute; | |
margin: auto; | |
left: 0; | |
right: 0; | |
display: block; | |
} | |
#pb /* preload bar */ | |
{ | |
outline: #FFF 1px solid; | |
left: 40px; | |
top: 145px; | |
width: 400px; | |
height: 30px; | |
} | |
.c480px | |
{ | |
position: absolute; | |
left: 0; | |
top: -20px; | |
width: 480px; | |
height: 320px; | |
} | |
#pbf /* preload bar fill */ | |
{ | |
margin: 0; | |
background-color: #FFF; | |
width: 0; | |
height: 30px; | |
-webkit-transition: width 0.1s linear; | |
-moz-transition: width 0.1s linear; | |
-o-transition: width 0.1s linear; | |
-ms-transition: width 0.1s linear; | |
} | |
#ss /* splash screen */ | |
{ | |
width: 480px; | |
height: 320px; | |
background: url('480px/splash.jpg'); | |
} | |
#gcs /* game cover screen */ | |
{ width: 480px; | |
height: 320px; | |
background: url('480px/cover.jpg'); | |
} | |
#ms /* menu screen */ | |
{ | |
width: 480px; | |
height: 320px; | |
background: url('480px/menu.jpg'); | |
} | |
#sbm /* start button - menu */ | |
{ | |
left: 85px; | |
top: 223px; | |
width: 160px; | |
height: 38px; | |
cursor: pointer; | |
margin: 0; | |
} | |
#hsbm /* high scores button - menu */ | |
{ | |
left: 85px; | |
top: 210px; | |
width: 160px; | |
height: 40px; | |
cursor: pointer; | |
margin: 0; | |
} | |
#mgbm /* more games button - menu */ | |
{ | |
left: 85px; | |
top: 250px; | |
width: 160px; | |
height: 40px; | |
cursor: pointer; | |
margin: 0; | |
} | |
#hs /* help screen */ | |
{ | |
width: 480px; | |
height: 320px; | |
background: url('480px/help.jpg'); | |
} | |
#sbh /* start button - help */ | |
{ | |
left: 170px; | |
top: 245px; | |
width: 140px; | |
height: 50px; | |
cursor: pointer; | |
margin: 0; | |
} | |
#bs /* board screen */ | |
{ | |
width: 480px; | |
height: 320px; | |
background: url('480px/board.jpg'); | |
} | |
#hsr /* high scores */ | |
{ | |
margin: 0; | |
left: 60px; | |
top: 20px; | |
width: 360px; | |
height: 260px; | |
border-radius: 40px; | |
-webkit-border-radius: 40px; | |
-moz-border-radius: 40px; | |
-o-border-radius: 40px; | |
-ms-border-radius: 40px; | |
border: #777 10px solid; | |
box-shadow: 3px 3px 10px 0 #000; | |
-webkit-box-shadow: 3px 3px 10px 0 #000; | |
-moz-box-shadow: 3px 3px 10px 0 #000; | |
-o-box-shadow: 3px 3px 10px 0 #000; | |
-ms-box-shadow: 3px 3px 10px 0 #000; | |
background-color: #CCC; | |
} | |
#hsrc /* high scores - close */ | |
{ | |
margin: 0; | |
left: 340px; | |
top: -20px; | |
width: 42px; | |
height: 42px; | |
background: url("480px/close.png"); | |
} | |
#hsri /* high scores - iframe */ | |
{ | |
margin: 0; | |
margin: 10px; | |
width: 340px; | |
height: 240px; | |
} | |
#ssr /* save score */ | |
{ | |
margin: 0; | |
left: 60px; | |
top: 20px; | |
width: 360px; | |
height: 260px; | |
border-radius: 40px; | |
-webkit-border-radius: 40px; | |
-moz-border-radius: 40px; | |
-o-border-radius: 40px; | |
-ms-border-radius: 40px; | |
border: #777 10px solid; | |
box-shadow: 3px 3px 10px 0 #000; | |
-webkit-box-shadow: 3px 3px 10px 0 #000; | |
-moz-box-shadow: 3px 3px 10px 0 #000; | |
-o-box-shadow: 3px 3px 10px 0 #000; | |
-ms-box-shadow: 3px 3px 10px 0 #000; | |
background-color: #CCC; | |
z-index: 10; | |
} | |
#ssrc /* save score - close */ | |
{ | |
margin: 0; | |
left: 340px; | |
top: -20px; | |
width: 42px; | |
height: 42px; | |
background: url("480px/close.png"); | |
} | |
#ssri /* save score - iframe */ | |
{ | |
margin: 10px; | |
width: 340px; | |
height: 240px; | |
} | |
#bd /* board */ | |
{ | |
margin: 0; | |
left: 130px; | |
top: 20px; | |
width: 285px; | |
height: 263px; | |
} | |
#tp /* top */ | |
{ | |
margin: 0; | |
left: 129px; | |
width: 287px; | |
height: 20px; | |
z-index: 1; | |
background: url("480px/top.jpg"); | |
} | |
#bt /* bottom */ | |
{ | |
margin: 0; | |
left: 420px; | |
top: 284px; | |
width: 21px; | |
height: 36px; | |
z-index: 1; | |
background: url("480px/bottom.jpg"); | |
} | |
#br /* bar */ | |
{ | |
margin: 0; | |
left: 421px; | |
top: 19px; | |
width: 18px; | |
height: 264px; | |
background: url("480px/bar.jpg"); | |
-webkit-transition: height 0.2s linear, top 0.2s linear; | |
-moz-transition: height 0.2s linear, top 0.2s linear; | |
-o-transition: height 0.2s linear, top 0.2s linear; | |
-ms-transition: height 0.2s linear, top 0.2s linear; | |
} | |
.gm /* gem */ | |
{ | |
margin: 0; | |
width: 32px; | |
height: 32px; | |
-webkit-transition: left 0.3s ease, top 0.3s ease; | |
-moz-transition: left 0.3s ease, top 0.3s ease; | |
-o-transition: left 0.3s ease, top 0.3s ease; | |
-ms-transition: left 0.3s ease, top 0.3s ease; | |
} | |
.gm1 /* gem 1 */ | |
{ | |
background: url("480px/gem1.png"); | |
} | |
.gm2 /* gem 2 */ | |
{ | |
background: url("480px/gem2.png"); | |
} | |
.gm3 /* gem 3 */ | |
{ | |
background: url("480px/gem3.png"); | |
} | |
.gm4 /* gem 4 */ | |
{ | |
background: url("480px/gem4.png"); | |
} | |
.gm5 /* gem 5 */ | |
{ | |
background: url("480px/gem5.png"); | |
} | |
.gm6 /* gem 6 */ | |
{ | |
background: url("480px/gem6.png"); | |
} | |
.gm7 /* gem 7 */ | |
{ | |
background: url("480px/gem7.png"); | |
} | |
#sl /* selection */ | |
{ | |
margin: 0; | |
width: 42px; | |
height: 42px; | |
background: url("480px/selection.png"); | |
} | |
.pt /* points */ | |
{ | |
font-size: 16px; | |
font-weight: bold; | |
color: #FF5; | |
text-shadow: #F70 0 0 6px, #F70 0 0 6px, #F70 0 0 6px, #F70 0 0 6px, #F70 0 0 6px, #F70 0 0 6px; | |
z-index: 2; | |
} | |
.lvt /* level text */ | |
{ | |
margin: 0; | |
top: 47px; | |
width: 140px; | |
font-size: 16px; | |
text-align: center; | |
color: #FFFDF2; | |
text-shadow: #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px; | |
} | |
.srt /* score text */ | |
{ | |
margin: 0; | |
top: 130px; | |
width: 140px; | |
font-size: 16px; | |
text-align: center; | |
color: #FFFDF2; | |
text-shadow: #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px, #AC7609 0 0 6px; | |
} | |
#lvu /* level up */ | |
{ | |
margin: 0; | |
left: 130px; | |
top: 100px; | |
width: 285px; | |
font-size: 24px; | |
line-height: 100px; | |
color: #FFF; | |
text-shadow: #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px, #007 0 0 6px; | |
text-align: center; | |
z-index: 3; | |
} | |
#go /* game over */ | |
{ | |
margin: 0; | |
left: 130px; | |
top: 20px; | |
width: 285px; | |
height: 263px; | |
line-height: 200px; | |
background: rgba(0, 0, 0, 0.5); | |
font-size: 24px; | |
color: #FF0; | |
text-shadow: #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px; | |
text-align: center; | |
z-index: 4; | |
} | |
#pa /* play again */ | |
{ | |
margin: 0; | |
top: 150px; | |
width: 285px; | |
font-size: 12px; | |
color: #FFFEA7; | |
text-shadow: #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px; | |
text-align: center; | |
z-index: 5; | |
} | |
#hm /* home */ | |
{ | |
margin: 0; | |
top: 170px; | |
width: 285px; | |
font-size: 12px; | |
color: #FFFEA7; | |
text-shadow: #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px, #C9AD4B 0 0 6px; | |
text-align: center; | |
z-index: 5; | |
} | |
#nm /* no moves */ | |
{ | |
margin: 0; | |
left: 130px; | |
top: 20px; | |
width: 285px; | |
height: 263px; | |
line-height: 263px; | |
font-size: 24px; | |
color: #FF0; | |
text-shadow: #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px, #F00 0 0 6px; | |
text-align: center; | |
z-index: 4; | |
} | |
.advert | |
{ | |
margin: 0; | |
position: absolute; | |
top: 30px; | |
left: 0%; | |
width: 100%; | |
height: 48px; | |
margin: auto; | |
z-index: 9000; | |
display: none; | |
color: Red; | |
text-align: center; | |
} | |
</style> | |
<script type="text/javascript"> | |
var | |
bdw = 8, bdh = 8, // board size, in gems | |
bdx = 130, bdy = 20, // board position | |
gmw = 36, gmh = 33, // gem size | |
gmt = 7, // gem types | |
slx0 = Math.round((gmw - 45) / 2), // selection initial x | |
sly0 = Math.round((gmh - 45) / 2), // selection initial y | |
ms = 200, // moving speed | |
bry = 19, // bar position | |
brh = 264, // bar height | |
lil = 0.05, // life increment per line | |
ld0 = 0.001, // initial life decrease | |
ldi = 0.00025, // life decrease increment | |
sln = 100, // score for line | |
seg = 70, // score for extra gem | |
sel = 80, // score for extra line | |
scb = 90, // score for combo | |
slu = 5000, // score for level up | |
lpi = [], // list of preloaded images | |
pb, // preload bar | |
pbf, // preload bar fill | |
sn, // screen | |
go, // game over | |
ln, // lines | |
sl, // selection | |
sla, // selection active | |
slx, sly, // selection position, in gems | |
gmm, // gems moving | |
bd, // board | |
br, // bar | |
lf, // life | |
ld, // life decrease | |
ld1, // life decrease | |
sr, // score | |
lv, // level | |
cl, // changing level | |
nm, // no moves | |
cbc, // combo counter | |
ptc, // points counter | |
lnc, // lines counter | |
nlv, // next level | |
lvt, // level text | |
srt, // score text | |
dl, // destruction list | |
saveScore; //save score | |
//------------------------------------------------------------------------------ | |
function i() // initialize | |
{ | |
//alert("entrooo"); | |
window.HideAllAdverts(); | |
//window.ShowAdvert(1, 100 , 17 , 43); | |
//window.ShowAdvertFullScreen(0 , 0 , 4); | |
pb = c('pb', '', '', null); | |
pbf = c('pbf', '', '', pb); | |
pi([ | |
'480px/bar.jpg', | |
'480px/board.jpg', | |
'480px/bottom.jpg', | |
'480px/close.png', | |
'480px/cover.jpg', | |
'480px/gem1.png', | |
'480px/gem2.png', | |
'480px/gem3.png', | |
'480px/gem4.png', | |
'480px/gem5.png', | |
'480px/gem6.png', | |
'480px/gem7.png', | |
'480px/help.jpg', | |
'480px/menu.jpg', | |
'480px/selection.png', | |
'480px/splash.jpg', | |
'480px/top.jpg' | |
]); | |
upb(); | |
scrollT(); | |
} | |
function scrollT() | |
{ | |
if (parent.sw != null) | |
parent.sw(); | |
setTimeout('scrollT()', 100); | |
} | |
//------------------------------------------------------------------------------ | |
function pi( // preload images | |
p // paths: array(string) | |
) | |
{ | |
for (var i in p) // index | |
{ | |
var i1 = new Image(); // image | |
i1.src = p[i]; | |
lpi.push(i1); | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function upb() // update preload bar | |
{ | |
var c = 0; // count | |
for (var i in lpi) // index | |
{ | |
if (lpi[i].complete) | |
c++; | |
} | |
pbf.style.width = (400*(c/lpi.length))+'px'; | |
if (c < lpi.length) | |
setTimeout('upb()', 10); | |
else | |
setTimeout('ss()', 4000); | |
} | |
//------------------------------------------------------------------------------ | |
function ss() // show splash | |
{ | |
d(pb); | |
sn = c('ss', '', '', null); | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(2, 100 , 18 , 43 , 3000); | |
setTimeout('sgc()', 3000); | |
} | |
//------------------------------------------------------------------------------ | |
function sgc() // show game cover | |
{ | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(3, 100 , 17 , 43 , 7000); | |
d(sn); | |
sn = c('gcs', '', '', null); | |
sn.setAttribute('onclick', 'sm()'); | |
} | |
//------------------------------------------------------------------------------ | |
function sm() // show menu | |
{ | |
if (parent.sw != null) | |
parent.sw(); | |
var b; // button | |
d(sn); | |
sn = c('ms', '', '', null); | |
b = c('sbm', '', '', sn); | |
b.setAttribute('onclick', 'sh()'); | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(4, 100 , 18 , 43 , 3000); | |
var bButton = parent.document.getElementById('dbackbutton'); | |
//alert("bButton: "+bButton); | |
bButton.style.display = 'none'; | |
} | |
//------------------------------------------------------------------------------ | |
function sh() // show help | |
{ | |
if (parent.sw != null) | |
parent.sw(); | |
d(sn); | |
sn = c('hs', '', '', null); | |
var b = c('sbh', '', '', sn); // button | |
ae(sg, 'click', b, 1, 0); | |
//window.ShowAdvertTime(9, 100 , 18 , 43 , 3000); | |
$("#dbackbutton").show(); | |
var bButton = parent.document.getElementById('dbackbutton'); | |
bButton.style.display = 'block'; | |
} | |
//------------------------------------------------------------------------------ | |
/*function shsr() // show high scores | |
{ | |
var | |
w = c('hsr', '', '', sn), // window | |
i = c('hsri', 'iframe', '', w), // iframe | |
b = c('hsrc', '', '', w); // button | |
i.setAttribute('src', 'http://justplaymobile.com/freegames/goosyfarmer/highscores.html'); | |
i.setAttribute('scrolling', 'no'); | |
b.setAttribute('onclick', 'sm()'); | |
//window.ShowAdvertTime(8, 100 , 235 , 43 , 3000); | |
var bButton = parent.document.getElementById('dbackbutton'); | |
bButton.style.display = 'block'; | |
} | |
//------------------------------------------------------------------------------ | |
function smg() // show more games | |
{ | |
o('mg').submit(); | |
} | |
*/ | |
//------------------------------------------------------------------------------ | |
function sg() // start game | |
{ | |
if (parent.sw != null) | |
parent.sw(); | |
go = null; | |
sn = c('bs', '', '', null); | |
ae(pc, 'mousedown', null, 1, 0); | |
ae(pc, 'touchstart', null, 1, 0); | |
ae(mc, 'mousemove', null, 1, 0); | |
ae(rc, 'mouseup', null, 1, 0); | |
ae(mc, 'touchmove', null, 1, 1); | |
ae(rc, 'touchend', null, 1, 0); | |
ae(rc, 'touchcancel', null, 1, 0); | |
bdx += Math.floor((window.innerWidth - 480) / 2); | |
c('tp', '', '', sn); | |
c('bt', '', '', sn); | |
br = c('br', '', '', sn); | |
lvt = c('', '', 'lvt', sn); | |
lvt.innerHTML = '1'; | |
srt = c('', '', 'srt', sn); | |
srt.innerHTML = '0' | |
lf = 0.5; | |
ld = ld0; | |
sr = 0; | |
lv = 1; | |
ptc = 0; | |
lnc = 0; | |
nlv = 15; | |
slf(); | |
bbd(); | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(10, 100 , 18 , 43 , 3000); | |
var bButton = parent.document.getElementById('dbackbutton'); | |
bButton.style.display = 'block'; | |
} | |
//------------------------------------------------------------------------------ | |
function ulf() // update life | |
{ | |
if (go) | |
return; | |
lf -= ld; | |
if (lf <= 0) | |
{ | |
go = c('go', '', '', sn); | |
go.innerHTML = 'GAME OVER'; | |
lf = 0; | |
//window.ShowAdvertFullScreen(0 , 0 , 4); | |
setTimeout('sph()', 1000); | |
return; | |
} | |
slf(); | |
if (cl && lf <= 0.5) | |
{ | |
cl = 0; | |
lf = 0.5; | |
bnl(); | |
return; | |
} | |
if (nm) | |
return; | |
setTimeout('ulf()', 100); | |
} | |
//------------------------------------------------------------------------------ | |
function sph() // show play again and home | |
{ | |
var t; // text | |
t = c('pa', '', '', bd); | |
t.innerHTML = 'Play Again'; | |
t.setAttribute('onclick', 'pya()'); | |
t = c('hm', '', '', bd); | |
t.innerHTML = 'Home'; | |
t.setAttribute('onclick', 'ghm()'); | |
//window.HideAllAdverts(); | |
//window.ShowAdvert(8, 100 , 18 , 43); | |
//window.ShowAdvert(8, 100 , 235 , 43); | |
} | |
//------------------------------------------------------------------------------ | |
function pya() // play again | |
{ | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(8, 100 , 18 , 43 , 3000); | |
d(bd); | |
d(go); | |
go = null; | |
lvt.innerHTML = '1'; | |
srt.innerHTML = '0' | |
lf = 0.5; | |
ld = ld0; | |
sr = 0; | |
lv = 1; | |
ptc = 0; | |
lnc = 0; | |
nlv = 15; | |
slf(); | |
bbd(); | |
} | |
//------------------------------------------------------------------------------ | |
function ghm() // go home | |
{ | |
window.HideAllAdverts(); | |
//window.ShowAdvertTime(8, 100 , 18 , 43 , 3000); | |
d(bd); | |
d(go); | |
sm(); | |
} | |
//------------------------------------------------------------------------------ | |
function slf() // show life | |
{ | |
var h = Math.floor(brh * lf); // height | |
br.style.top = (bry + brh - h) + 'px'; | |
br.style.height = (h + 10) + 'px'; | |
} | |
//------------------------------------------------------------------------------ | |
function bbd() // build board | |
{ | |
bd = c('bd', '', '', sn); | |
ln = []; | |
for (var y = 0; y < bdh; y++) | |
{ | |
var r = []; // row | |
for (var x = 0; x < bdw; x++) | |
{ | |
var t = rt(); // type | |
while (x >= 2 && r[x - 1].t == t && r[x - 2].t == t) | |
t = rt(); | |
while (y >= 2 && ln[y - 1][x].t == t && ln[y - 2][x].t == t) | |
t = rt(); | |
var g = c('', '', 'gm gm' + t, bd); // gem | |
g.style.left = (x * gmw) + 'px'; | |
g.style.top = (-1 * gmh) + 'px'; | |
r.push({ | |
t: t, // type | |
g: g, // gem | |
x: x, y: y // position | |
}); | |
} | |
ln.push(r); | |
setTimeout('aln(' + y + ')', ms + (bdh - 1 - y) * 100); | |
} | |
sl = c('sl', '', '', bd); | |
sl.style.display = 'none'; | |
sla = 0; | |
gmm = 1; | |
setTimeout('slv()', ms + (bdh) * 100); | |
} | |
//------------------------------------------------------------------------------ | |
function rt() // random type | |
{ | |
return 1 + Math.floor(Math.random() * gmt); | |
} | |
//------------------------------------------------------------------------------ | |
function aln( // align line | |
y // line: int | |
) | |
{ | |
for (var x = 0; x < bdw; x++) | |
{ | |
var g = ln[y][x]; | |
if (!g) | |
continue; | |
g.g.style.left = (x * gmw) + 'px'; | |
g.g.style.top = (y * gmh) + 'px'; | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function abd() // align board | |
{ | |
for (var y = 0; y < bdh; y++) | |
aln(y); | |
} | |
//------------------------------------------------------------------------------ | |
function slv() // start level | |
{ | |
gmm = 0; | |
cbc = 0; | |
ulf(); | |
} | |
//------------------------------------------------------------------------------ | |
function egm( // exchange gems | |
x1, y1, // position of gem 1: int, int | |
x2, y2 // position of gem 2: int, int | |
) | |
{ | |
var | |
g1 = ln[y1][x1], | |
g2 = ln[y2][x2]; | |
ln[y2][x2] = g1; | |
ln[y1][x1] = g2; | |
if (g1) | |
{ | |
g1.x = x2; | |
g1.y = y2; | |
g1.g.style.left = (x2 * gmw) + 'px'; | |
g1.g.style.top = (y2 * gmh) + 'px'; | |
} | |
if (g2) | |
{ | |
g2.x = x1; | |
g2.y = y1; | |
g2.g.style.left = (x1 * gmw) + 'px'; | |
g2.g.style.top = (y1 * gmh) + 'px'; | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function sgm( // switch gems | |
x1, y1, // position of gem 1: int, int | |
x2, y2 // position of gem 2: int, int | |
) | |
{ | |
egm(x1, y1, x2, y2); | |
gmm = 1; | |
setTimeout('mgm(' + x1 + ',' + y1 + ',' + x2 + ',' + y2 + ')', ms); | |
} | |
//------------------------------------------------------------------------------ | |
function mgm( // match gems | |
x1, y1, // position of gem 1: int, int | |
x2, y2 // position of gem 2: int, int | |
) | |
{ | |
if (fln()) | |
{ | |
sl.style.display = 'none'; | |
sla = 0; | |
} | |
else | |
setTimeout('rgm(' + x1 + ',' + y1 + ',' + x2 + ',' + y2 + ')', ms); | |
} | |
//------------------------------------------------------------------------------ | |
function fln( // find lines | |
) // : boolean | |
{ | |
dl = []; // destruction list | |
var | |
pt = 0, // points | |
lc = 0; // lines counter | |
for (var t = 1; t <= gmt; t++) // type | |
{ | |
// Search vertical lines. | |
for (var x = 0; x < bdw; x++) | |
{ | |
for (var y = 0; y < bdh; y++) | |
{ | |
if (!ln[y][x]) | |
continue; | |
if (ln[y][x].t == t) | |
{ | |
var l = []; // line | |
for (; y < bdh; y++) | |
{ | |
if (!ln[y][x]) | |
break; | |
if (ln[y][x].t == t) | |
l.push(ln[y][x]); | |
else | |
break; | |
} | |
if (l.length >= 3) | |
{ | |
pt += sln + (l.length - 3) * seg + lc * sel; | |
lc++; | |
for (var i in l) | |
dl.push(l[i]); | |
} | |
} | |
} | |
} | |
// Search horizontal lines. | |
for (var y = 0; y < bdh; y++) | |
{ | |
for (var x = 0; x < bdw; x++) | |
{ | |
if (!ln[y][x]) | |
continue; | |
if (ln[y][x].t == t) | |
{ | |
var l = []; // line | |
for (; x < bdw; x++) | |
{ | |
if (!ln[y][x]) | |
break; | |
if (ln[y][x].t == t) | |
l.push(ln[y][x]); | |
else | |
break; | |
} | |
if (l.length >= 3) | |
{ | |
pt += sln + (l.length - 3) * seg + lc * sel; | |
lc++; | |
for (var i in l) | |
dl.push(l[i]); | |
} | |
} | |
} | |
} | |
} | |
if (dl.length) | |
{ | |
pt += cbc * scb; | |
cbc++; | |
var | |
xc = 0, yc = 0; // center | |
for (var i in dl) | |
{ | |
var g = dl[i]; // gem | |
if (!g) | |
continue; | |
s(g.g, 0.5, 0.5); | |
ln[g.y][g.x] = null; | |
xc += g.x * gmw; | |
yc += g.y * gmh; | |
} | |
xc /= dl.length; | |
yc /= dl.length; | |
var p = c('pt' + ptc, '', 'pt', bd); | |
p.style.left = xc; | |
p.style.top = yc; | |
p.innerHTML = '+' + pt; | |
setTimeout('d(o(\'pt' + ptc + '\'))', ms * 2); | |
sr += pt; | |
srt.innerHTML = sr; | |
ptc++; | |
lf += lil * lc; | |
if (lf > 1) | |
lf = 1; | |
lnc += lc; | |
setTimeout('dln()', ms); | |
} | |
return dl.length; | |
} | |
//------------------------------------------------------------------------------ | |
function dln() // destroy lines | |
{ | |
for (var i in dl) | |
{ | |
var g = dl[i]; // gem | |
if (!g) | |
continue; | |
d(g.g); | |
} | |
for (var y = bdh - 1; y > 0; y--) | |
{ | |
for (var x = 0; x < bdw; x++) | |
{ | |
if (!ln[y][x]) | |
{ | |
for (var y1 = y - 1; y1 >= 0; y1--) | |
{ | |
var g = ln[y1][x]; // gem | |
if (g) | |
{ | |
ln[y1][x] = null; | |
ln[y][x] = g; | |
g.y = y; | |
break; | |
} | |
} | |
} | |
} | |
} | |
for (var x = 0; x < bdw; x++) | |
{ | |
var y1 = -1; | |
for (var y = bdh - 1; y >= 0; y--) | |
{ | |
if (!ln[y][x]) | |
{ | |
var | |
t = rt(), // type | |
g = c('', '', 'gm gm' + t, bd); // gem | |
g.style.left = (x * gmw) + 'px'; | |
g.style.top = (y1 * gmh) + 'px'; | |
y1 -= 1; | |
ln[y][x] = { | |
t: t, // type | |
g: g, // gem | |
x: x, y: y // position | |
}; | |
} | |
} | |
} | |
sl.style.display = 'none'; | |
sla = 0; | |
setTimeout('abd()', 50); | |
setTimeout('mngm()', ms); | |
} | |
//------------------------------------------------------------------------------ | |
function mngm() // match new gems | |
{ | |
if (!fln()) | |
{ | |
cbc = 0; | |
if (lnc >= nlv) | |
{ | |
for (var y = 0; y < bdh; y++) | |
{ | |
for (var x = 0; x < bdw; x++) | |
{ | |
var g = ln[y][x]; // gem | |
if (!g) | |
continue; | |
s(g.g, 0.5, 0.5); | |
} | |
} | |
lf = 1; | |
slf(); | |
lnc = 0; | |
nlv *= 2; | |
setTimeout('snl()', ms); | |
} | |
else if (!fmv()) | |
{ | |
nm = 1; | |
var t = c('nm', '', '', sn); | |
t.innerHTML = 'No More Moves'; | |
for (var y = 0; y < bdh; y++) | |
setTimeout('rrw(' + (bdh - 1 - y) + ')', Math.floor(y * ms / 2)); | |
setTimeout('fbd()', Math.floor(bdh * ms / 2)); | |
} | |
else | |
gmm = 0; | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function rrw( // reduce row | |
y // row: int | |
) | |
{ | |
for (var x = 0; x < bdw; x++) | |
{ | |
var g = ln[y][x]; // gem | |
if (!g) | |
continue; | |
s(g.g, 0.5, 0.5); | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function fmv( // find moves | |
) // : boolean | |
{ | |
for (var y = 0; y < bdh; y++) | |
{ | |
for (var x = 0; x < bdw - 3; x++) | |
{ | |
var t = tgm(x, y); // type | |
if (tgm(x + 1, y) == t && (tgm(x + 3, y) == t || tgm(x + 2, y - 1) == t || tgm(x + 2, y + 1) == t)) | |
return 1; | |
} | |
for (var x = bdw - 1; x >= 3; x--) | |
{ | |
var t = tgm(x, y); // type | |
if (tgm(x - 1, y) == t && (tgm(x - 3, y) == t || tgm(x - 2, y - 1) == t || tgm(x - 2, y + 1) == t)) | |
return 1; | |
} | |
} | |
for (var x = 0; x < bdw; x++) | |
{ | |
for (var y = 0; y < bdh - 3; y++) | |
{ | |
var t = tgm(x, y); // type | |
if (tgm(x, y + 1) == t && (tgm(x, y + 3) == t || tgm(x - 1, y + 2) == t || tgm(x + 1, y + 2) == t)) | |
return 1; | |
} | |
for (var y = bdh - 1; y >= 3; y--) | |
{ | |
var t = tgm(x, y); // type | |
if (tgm(x, y - 1) == t && (tgm(x, y - 3) == t || tgm(x - 1, y - 2) == t || tgm(x + 1, y - 2) == t)) | |
return 1; | |
} | |
} | |
return 0; | |
} | |
//------------------------------------------------------------------------------ | |
function fbd() // fill board | |
{ | |
nm = 0; | |
d(o('nm')); | |
d(bd); | |
bbd(); | |
} | |
//------------------------------------------------------------------------------ | |
function tgm( // type of gem | |
x, y // position: int int | |
) // : int | |
{ | |
if (x < 0 || y < 0 || x >= bdw || y >= bdh) | |
return; | |
return ln[y][x].t; | |
} | |
//------------------------------------------------------------------------------ | |
function snl() // show next level | |
{ | |
lf = 1; | |
slf(); | |
ld1 = ld; | |
ld = 0.02; | |
cl = 1; | |
d(bd); | |
sr += slu; | |
srt.innerHTML = sr; | |
var t = c('lvu', '', '', sn); // text | |
t.innerHTML = 'LEVEL UP!<br/>' + slu; | |
//aki | |
//window.ShowAdvertTime(8, 100 , 18 , 43 , 3000); | |
} | |
//------------------------------------------------------------------------------ | |
function bnl() // build next level | |
{ | |
ld = ld1 + ldi; | |
lv++; | |
lvt.innerHTML = lv; | |
d(o('lvu')); | |
bbd(); | |
} | |
//------------------------------------------------------------------------------ | |
function rgm( // return gems | |
x1, y1, // position of gem 1: int, int | |
x2, y2 // position of gem 2: int, int | |
) | |
{ | |
egm(x1, y1, x2, y2); | |
sl.style.display = 'none'; | |
sla = 0; | |
gmm = 0; | |
} | |
//------------------------------------------------------------------------------ | |
/*function ssr() // save score | |
{ | |
var | |
w = c('ssr', '', '', sn), // window | |
i = c('ssri', 'iframe', '', w), // iframe | |
b = c('ssrc', '', '', w); // button | |
i.setAttribute('src', 'congrats.html'); | |
i.setAttribute('scrolling', 'no'); | |
b.setAttribute('onclick', 'd(o(\'ssr\'))'); | |
//window.ShowAdvert(8, 100 , 235 , 43); | |
saveScore = true; | |
}*/ | |
//------------------------------------------------------------------------------ | |
function pc( // press cursor | |
e // event: MouseEvent | |
) | |
{ | |
if (gmm) | |
return; | |
if (go) | |
return; | |
if (!e) | |
e = window.event; | |
var ci = cie(e); // cursor information | |
if (ci.x >= bdx && ci.y >= bdy && ci.x < bdx + gmw * bdw && ci.y < bdy + gmh * bdh) | |
{ | |
var x = Math.floor((ci.x - bdx) / gmw); | |
var y = Math.floor((ci.y - bdy) / gmh); | |
if (sla && x == slx && y == sly) | |
{ | |
sl.style.display = 'none'; | |
sla = 0; | |
} | |
else | |
if (sla && ((Math.abs(x - slx) == 1 && y == sly) || (Math.abs(y - sly) == 1 && x == slx))) | |
{ | |
sgm(x, y, slx, sly); | |
} | |
else | |
{ | |
slx = x; | |
sly = y; | |
sl.style.left = (slx * gmw + slx0) + 'px'; | |
sl.style.top = (sly * gmh + sly0) + 'px'; | |
sl.style.display = ''; | |
sla = 1; | |
} | |
} | |
e.cancelBubble = true; | |
if (e.preventDefault) | |
e.preventDefault(); | |
if (e.stopPropagation) | |
e.stopPropagation(); | |
} | |
//------------------------------------------------------------------------------ | |
function mc( // move cursor | |
e // event: MouseEvent | |
) | |
{ | |
if (gmm) | |
return; | |
if (go) | |
return; | |
if (!e) | |
e = window.event; | |
var ci = cie(e); // cursor information | |
} | |
//------------------------------------------------------------------------------ | |
function rc( // release cursor | |
e // event: MouseEvent | |
) | |
{ | |
if (gmm) | |
return; | |
if (go) | |
return; | |
if (!e) | |
e = window.event; | |
var ci = cie(e); // cursor information | |
if (ci.x >= bdx && ci.y >= bdy && ci.x < bdx + gmw * bdw && ci.y < bdy + gmh * bdh) | |
{ | |
var x = Math.floor((ci.x - bdx) / gmw); | |
var y = Math.floor((ci.y - bdy) / gmh); | |
if (sla && ((Math.abs(x - slx) == 1 && y == sly) || (Math.abs(y - sly) == 1 && x == slx))) | |
{ | |
sgm(x, y, slx, sly); | |
} | |
} | |
} | |
//------------------------------------------------------------------------------ | |
function o( // object | |
i // identity: string | |
) // : object | |
{ | |
return document.getElementById(i); | |
} | |
//------------------------------------------------------------------------------ | |
function c( // create | |
i, // identity: string | |
t, // type: string | |
c, // class: string | |
p // parent: object | |
) // : object | |
{ | |
if (!t) | |
t = 'div'; | |
if (!p) | |
p = document.body; | |
var o = document.createElement(t); // object | |
if (i) | |
o.setAttribute('id', i); | |
sc(c, o); | |
p.appendChild(o); | |
return o; | |
} | |
//------------------------------------------------------------------------------ | |
function sc( // set class | |
c, // class: string | |
o // object: object | |
) | |
{ | |
if (!c || !o) | |
return; | |
if (navigator.appName.indexOf('Microsoft') != -1) | |
o.setAttribute('className', c); | |
o.setAttribute('class', c); | |
} | |
//------------------------------------------------------------------------------ | |
function d( // destroy | |
o // object: object | |
) | |
{ | |
if(saveScore){ | |
//alert("entro"); | |
window.HideAllAdverts(); | |
//window.ShowAdvert(8, 100 , 18 , 43); | |
saveScore = false; | |
} | |
if (o && o.parentNode) | |
o.parentNode.removeChild(o); | |
} | |
//------------------------------------------------------------------------------ | |
function ae( // add event | |
f, // function: function | |
e, // event: string | |
o, // object: object | |
ae, // adjust event: boolean | |
c // capture: boolean | |
) | |
{ | |
if (!o) | |
o = document.body; | |
if (o.attachEvent) | |
o.attachEvent((ae ? 'on' : '')+e, f); | |
else | |
o.addEventListener(e, f, c); | |
} | |
//------------------------------------------------------------------------------ | |
function cie( // cursor information on event | |
e // event: MouseEvent | |
) // : {o: object, x: int, y: int} | |
{ | |
if (!e) | |
e = window.event; | |
if (e.changedTouches) | |
e = e.changedTouches[0]; | |
var i = {}; // information | |
// Get object. | |
i.o = e.target || e.srcElement || e.currentTarget || e.relatedTarget || e.originalTarget || e.toElement || e.fromElement; // object | |
// Get position. | |
if (e.pageX != null) | |
{ | |
i.x = e.pageX; | |
i.y = e.pageY; | |
} | |
else | |
{ | |
i.x = e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft; | |
i.y = e.clientY+document.body.scrollTop+document.documentElement.scrollTop; | |
} | |
return i; | |
} | |
//------------------------------------------------------------------------------ | |
function ssp( // set style with prefixes | |
o, // object: object | |
p, // prefixes: array (string) | |
s, // style: string | |
v // value: string | |
) | |
{ | |
if (!o) | |
return; | |
for (var i in p) // index | |
o.style[p[i]+s] = v; | |
} | |
//------------------------------------------------------------------------------ | |
function s( // scale | |
o, // object: object | |
xs, ys // scale: float, float | |
) | |
{ | |
if (!o) | |
return; | |
o.style.transform = 'scale('+xs+','+ys+')'; | |
ssp(o, ['webkit', 'Moz', 'O', 'ms'], 'Transform', 'scale('+xs+','+ys+')'); | |
} | |
function removeAdvFS() | |
{ | |
//alert("removeAdvFS"); | |
$("#advertFS").hide(); | |
document.getElementById('ssri').contentWindow.disableInput(false); | |
} | |
</script> | |
<script type="text/javascript"> | |
var advertsAmount = 11; | |
// Shows an advert | |
var ShowAdvert = function (adtype, posx, posy, quadrantY) { | |
//var realY = GetPositionYForQuadrant(quadrantY); | |
//$("#advert" + adtype).css("top", realY + "px"); | |
$("#advert" + adtype).css("top", posy); | |
//$("#advert" + adtype).css("left", posx); | |
$("#advert" + adtype).show(); | |
} | |
// Shows an advert for a limited period of time | |
var ShowAdvertTime = function (adtype, posx, posy, quadrantY, showtime) { | |
//var realY = GetPositionYForQuadrant(quadrantY); | |
//$("#advert" + adtype).css("top", realY); | |
$("#advert" + adtype).css("top", posy); | |
//$("#advert" + adtype).css("left", posx); | |
$("#advert" + adtype).show(); | |
//alert("ShowAdvertTime"); | |
setTimeout("HideAdvert(" + adtype + ")", showtime); | |
} | |
var ShowAdvertFullScreen = function(posx, posy, showtimeSeconds){ | |
showtimeSeconds = showtimeSeconds*1000; | |
$("#advertFS").css("top", posy); | |
$("#advertFS").css("left", posx); | |
$("#advertFS").show(); | |
//showButtonAFH(); | |
setTimeout(function () { | |
parent.showButtonAFHP(); | |
},showtimeSeconds); | |
} | |
// Hides all advert banners | |
var HideAllAdverts = function () { | |
/*for (i = 1; i <= advertsAmount; i++) { | |
HideAdvert(i); | |
}*/ | |
/*$("#advert1").hide(); | |
$("#advert7").hide(); | |
$("#advert8").hide(); | |
$("#advert9").hide(); | |
$("#advert2").hide();*/ | |
} | |
// Hides all advert banners, except the specified as a parameter | |
var HideAllAdvertsExcept = function (adtype) { | |
for (i = 1; i <= advertsAmount; i++) { | |
if (i != adtype){ | |
HideAdvert(i); | |
} | |
} | |
/*$("#advert1").hide(); | |
$("#advert7").hide(); | |
$("#advert8").hide(); | |
$("#advert9").hide(); | |
$("#advert2").hide();*/ | |
} | |
// Hides an advert | |
var HideAdvert = function (adtype) { | |
$("#advert" + adtype).hide(); | |
} | |
// For internal use, do not call it directyly | |
var GetPositionYForQuadrant = function (quadrant) { | |
if (quadrant != 0) { | |
var totalQuadrants = 50; | |
var height = window.innerHeight; | |
if (navigator.userAgent.match(/iPhone/i) || (navigator.userAgent.match(/iPod/i))) { | |
height = height - 7; | |
} | |
var quadrantHeight = height / totalQuadrants; | |
return quadrant * quadrantHeight; | |
} | |
else { | |
return 0; | |
} | |
} | |
</script> | |
</head> | |
<body onLoad="i()"> | |
<form id="mg" action="http://justplaymobile.com/" target="_blank"></form> | |
<div class="advert" id="advertFS"> | |
<script type="text/javascript"> | |
var useragent = navigator.userAgent; | |
useragent = useragent.toLowerCase(); | |
if (useragent.indexOf('iphone') != -1) { | |
//alert("iphone"); | |
document.getElementById('advertFS').innerHTML = '<a href="http://justplaymobile.com/" target="new"><img src="http://tweensoft.com/html5games/minijuegos/goosyfarmer/moregames.jpg"></a>'; | |
}else{ | |
if(useragent.indexOf('android')!=-1){ | |
//alert("android"); | |
document.getElementById('advertFS').innerHTML = '<a href="http://justplaymobile.com/" target="new"><img src="http://tweensoft.com/html5games/minijuegos/goosyfarmer/moregames.jpg"></a>'; | |
}else{ | |
//alert("other"); | |
//other device | |
document.getElementById('advertFS').innerHTML = '<a href="http://justplaymobile.com/" target="new"><img src="http://tweensoft.com/html5games/minijuegos/goosyfarmer/moregames.jpg"></a>'; | |
} | |
} | |
</script> | |
<!--a href="http://www.goosypets.com" target="new"><img src="http://goosypets.com/html5games/bouncing/gokart300x250.jpg"--> | |
</div> | |
</body> | |
<!-- Mirrored from justplaymobile.com/freegames/goosyfarmer/480px.htm by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 15 Oct 2013 06:30:21 GMT --> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment