Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- //begin jakechanges
- var clevel=1;
- var template;
- var ldata;
- var request = new XMLHttpRequest();
- request.open('GET', 'lt.txt', true);
- request.onload = function() {
- if (request.status >= 200 && request.status < 400) {
- template = request.responseText;
- } else throw"target server error loading template data";
- };
- request.onerror = function() {
- console.log("error loading template");
- };
- request.send();
- var request = new XMLHttpRequest();
- request.open('GET', clevel+'.txt', true);
- request.onload = function() {
- if (request.status >= 200 && request.status < 400) {
- ldata = request.responseText;
- } else throw"target server error";
- };
- request.onerror = function() {
- console.log("error loading level");
- };
- request.send();
- //end jakechanges
- var jc=template+ldata;
- (function()
- {
- function spawnSpike(game)
- {
- if(this.spike && this.spike.timer)
- {
- // there is already a spike that is moving
- return;
- }
- this.spike = game.addObject({
- image: "spikeUp",
- killing: true,
- x: this.x,
- y: this.y,
- tickFunction: moveHiddenSpike,
- zIndex: -1,
- });
- this.spike.timer = 64;
- }
- function moveHiddenSpike(game)
- {
- if(this.timer)
- {
- this.y += Math.rectangle(64)(this.timer);
- this.timer--;
- }
- else
- {
- game.removeObject(this);
- }
- }
- function startObject(id)
- {
- return function(game)
- {
- var obj = game.objectMap[id];
- obj.active = true;
- obj.timer = 0;
- // remove the trigger
- game.removeObject(this);
- }
- }
- function movePlatform(game)
- {
- if(this.active)
- {
- if(this.timer % 2 === 0)
- {
- game.moveObjectDown(this, -1);
- }
- if(this.y > 400)
- {
- game.moveObjectRight(this, -Math.rectangle(260)(this.timer + 65));
- }
- else
- {
- game.moveObjectRight(this, 1);
- }
- if(this.x < -40)
- {
- game.removeObject(this);
- }
- this.timer++;
- }
- }
- function movePlatform2(game)
- {
- if(this.active)
- {
- if(this.timer < 95)
- {
- game.moveObjectRight(this, -2);
- }
- else if(this.timer < 185)
- {
- //game.moveObjectDown(this,
- // 2 * Math.rectangle(85)(this.timer - 95));
- game.moveObjectRight(this, 3);
- }
- else if(this.timer < 325)
- {
- if(this.timer % 2)
- {
- game.moveObjectDown(this, -1);
- game.moveObjectRight(this, -1);
- }
- }
- else if(this.timer < 480)
- {
- game.moveObjectRight(this, -2);
- }
- else if(this.timer < 500)
- {
- game.moveObjectDown(this, 6);
- }
- else if(this.timer < 600)
- {
- game.moveObjectDown(this, -1);
- game.moveObjectRight(this,
- Math.round(2 * Math.triangle(80)(this.timer)));
- }
- else if(this.timer < 750)
- {
- game.moveObjectRight(this, -1);
- }
- else if(this.timer < 790)
- {
- game.moveObjectDown(this, -1);
- }
- else if(this.timer < 850)
- {
- }
- else if(this.timer < 950)
- {
- game.moveObjectRight(this, 3);
- }
- else if(this.timer < 1000)
- {
- game.moveObjectDown(this, -1);
- }
- else if(this.timer < 1022)
- {
- game.moveObjectRight(this, 4);
- }
- else if(this.timer < 1050)
- {
- }
- else if(this.timer < 1150)
- {
- game.moveObjectDown(this, -1);
- }
- else if(this.timer < 1230)
- {
- game.moveObjectRight(this, 1);
- }
- else if(this.timer < 1300)
- {
- }
- else
- {
- game.moveObjectRight(this, -Math.ceil((this.timer - 1300) / 18));
- }
- this.timer++;
- }
- }
- function badPlatform(game)
- {
- game.removeObject(this);
- }
- function transitionUp(game)
- {
- if(game.viewportY === 600)
- {
- game.viewportY = 0;
- }
- }
- function transitionDown(game)
- {
- if(game.viewportY === 0)
- {
- game.viewportY = 600;
- }
- }
- function additionalJump(game)
- {
- game.canJump = true;
- game.removeObject(this);
- game.audio.play("Mega_Man_Blast_Sound.ogg");
- }
- function moveApple(game)
- {
- this.y += Math.rectangle(100)(game.tickCount);
- }
- function redOrb(game)
- {
- var f = game.addObject({
- tickFunction: shake,
- });
- f.timer = 0;
- game.removeObject(this);
- }
- function shake(game)
- {
- if(this.timer % 4 === 2)
- {
- game.viewportY -= 2;
- }
- else if(this.timer % 4 === 0)
- {
- game.viewportY += 2;
- }
- if(this.timer % 10 === 0)
- {
- game.objectMap["exitBlock"].y--;
- game.objectMap["exitSpike"].y--;
- }
- this.timer++;
- if(this.timer > 1500)
- {
- game.removeObject(this);
- }
- }
- function tickFunction(game)
- {
- }
- function nextLevel(game)
- {
- game.nextLevel("2up.js");
- //DOIT: CHANGE THIS METHOD TO RELOAD CSV RATHER THAN NEW LEVEL
- game.removeObject(this);
- }
- function loadState(game, state)
- {
- if(state === 0xbeeeef)
- {
- game.posY = 224;
- game.posX = 37;
- game.viewportY = 0;
- game.removeObjectById("saveState1");
- }
- else
- {
- console.log("invalid state: " + state);
- }
- }
- function saveState1(game)
- {
- game.saveState(0xbeeeef);
- game.removeObject(this);
- game.audio.play("Mega_Man_Beam_Sound.ogg", false, false);
- }
- return jc;
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement