Home › Forums › General Chat › Super awesome mario game
- This topic has 5 replies, 3 voices, and was last updated 15 years, 2 months ago by
Joaco.
Viewing 6 posts - 1 through 6 (of 6 total)
-
AuthorPosts
-
21 December 2009 at 23:32 #3267
Joaco
ParticipantThings to try
-Konami code
-movement
-background change
-winning
=DUpdates:
-First mini-version
-Konami code addon
-Typo correction
-No more multiple wins
-There’s a real challenge: the box moves every two seconds
-Box won’t move once you win
-Background change
-instant IP trace and FBI goes to your house if you hack this game..…okay, that last one isn’t implemented yet.
Feel free to view the source code (HTML isn’t posted, it’s obvious):
window.addEventListener("keydown",presiono,false);
window.addEventListener("load",start,false);
var left,right,up,down,tops,leftval,val,konami,won,boxBottom,boxLeft,background;
left = 37;
right = 39;
up = 38;
down = 40;
won = false;
function start(e) {
document.getElementById('multicolor').addEventListener('click',multicolorBG,false);
document.getElementById('defaultbg').addEventListener('click',defaultBG,false);
setInterval("locateWinBox()",2000);
}
function multicolorBG(e) {
setBackground('http://i49.tinypic.com/jfxfn4.png');
}
function defaultBG(e) {
setBackground('http://testing-spot.com/ides/illustrator/pincel/abstract_background1.jpg');
}
function setBackground(url) {
document.body.style.background = 'url('+url+')';
}
function locateWinBox() {
if(won == false)
{
boxBottom = Math.floor(Math.random() * 500 + 10);
boxLeft = Math.floor(Math.random() * 700 + 100);
document.getElementById("won").style.bottom = boxBottom;
document.getElementById("won").style.left = boxLeft;
}
}
function add2Log(text) {
var logs = document.getElementById("logs");
logs.innerHTML=text + 'n' + logs.innerHTML;
}
function setPosition(x,y) {
document.getElementById('character').style.bottom = y;
document.getElementById('character').style.left = x;
}
function moveRandom() {
var y = Math.floor(Math.random() * 500);
var x = Math.floor(Math.random() * 980);
setPosition(x,y);
}
function getY() {
tops = document.getElementById('character').style.bottom;
tops = tops.replace("px","");
tops = parseInt(tops);
return tops;
}
function getX() {
leftval = document.getElementById('character').style.left;
leftval = leftval.replace("px","");
leftval = parseInt(leftval);
return leftval;
}
function checkWon() {
if (getY()>boxBottom && getX() > boxLeft && getY() < boxBottom + 100 && getX() < boxLeft + 100 && won == false) {
add2Log("-YOU WON!n Refresh the browser to try again.");
won = true;
}
}
function moveY(val) {
val = getY() + val;
document.getElementById('character').style.bottom= val + '';
checkWon();
}
function moveX(val) {
val = getX() + val;
eval("document.getElementById('character').style.left='"+val+"'");
checkWon();
}
function presiono(e) {
switch(e.keyCode) {
case left:
moveX(-10);
break;
case right:
moveX(10);
break;
case up:
moveY(10);
break;
case down:
moveY(-10);
break;
}
}
konami = {
input:"",
clear:setTimeout('konami.clear_input()',1000),
load: function(link) {
window.document.onkeyup = function(e) {
konami.input+= e ? e.keyCode : event.keyCode ;
if (konami.input.indexOf("3838404037393739666513")!=-1) {
add2Log("-Konami code:n trap activated.");
setInterval("moveRandom()",100);
clearTimeout(konami.clear);
}
clearTimeout(konami.clear);
konami.clear = setTimeout("konami.clear_input()",2000);
}
},
code: function(link) { window.location=link},
clear_input: function() {
konami.input="";
clearTimeout(konami.clear);
}
}
konami.load();Object-oriented source code is coming soon.
22 December 2009 at 00:42 #18649Dest1
ParticipantTHIS GAME FAELS
22 December 2009 at 00:52 #18650Joaco
ParticipantThank you dest
22 December 2009 at 04:14 #18652DarkDragoon
ParticipantLol, too easy xp
22 December 2009 at 04:49 #18653Joaco
ParticipantMaybe you want me to change the respawn time to 1ms?
22 December 2009 at 04:54 #18654Joaco
ParticipantTry now.
-
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.