Version 0.5
Changed menu layout. Added options for controls. Removed multiplayer button. Added multiple game modes, only time trial is different for now. Added fallback for particle errors. Lots of bug fixes in menu. Added camera stopping at edge of level. Added support for mobiles devices. Fixed jump sound. Fixed graphics for browsers other than Chrome. Other changes too.
This commit is contained in:
parent
e20e535802
commit
e560f514ae
7 changed files with 363 additions and 116 deletions
13
Server/server.php
Normal file
13
Server/server.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
$values = $_REQUEST;
|
||||||
|
if(isset($values['id']) and isset($values['x']) and isset($values['y']) and isset($values['time'])){
|
||||||
|
$x = $values['x'];
|
||||||
|
$y = $values['y'];
|
||||||
|
$id = $values['id'];
|
||||||
|
$time = $values['time'];
|
||||||
|
// Set database x + y to values
|
||||||
|
$return = json_encode(); // Return other player's data
|
||||||
|
echo json_encode($return);
|
||||||
|
}elseif(isset($values['getID']){
|
||||||
|
|
||||||
|
}
|
6
Server/sql.php
Normal file
6
Server/sql.php
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
$online = false;
|
||||||
|
if($online){
|
||||||
|
$server = 'sint.comli.com'
|
||||||
|
}
|
||||||
|
$con = msqli_connect()
|
BIN
Sint.zip
Normal file
BIN
Sint.zip
Normal file
Binary file not shown.
11
index.html
11
index.html
|
@ -2,6 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=500, initial-scale=1, maximum-scale=1">
|
||||||
<title>
|
<title>
|
||||||
Sint
|
Sint
|
||||||
</title>
|
</title>
|
||||||
|
@ -21,9 +22,11 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<canvas id="game" width="500" height="320" />
|
<div id="holder">
|
||||||
<div id='innergame'>
|
<canvas id="game" width="500" height="320" />
|
||||||
</div>
|
<div id='innergame'>
|
||||||
</canvas>
|
</div>
|
||||||
|
</canvas>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
50
level.js
50
level.js
|
@ -1,5 +1,53 @@
|
||||||
function defineLevels(){
|
function defineLevels(){
|
||||||
levelparts = [
|
timelevels = [
|
||||||
|
[
|
||||||
|
'...................................................................................................................................................................................'
|
||||||
|
,'...............................................................................................................................................................................###.'
|
||||||
|
,'...............................................................................................................................................................................###.'
|
||||||
|
,'.###...........................................................................................................................................................................###.'
|
||||||
|
,'.###...........................................................................................................................................................................###.'
|
||||||
|
,'.###...................................................######........................................................................................................FFFFFFFFFF###.'
|
||||||
|
,'.###....................................................................................................................................##..........................##############.'
|
||||||
|
,'.###............................................######........######.................................................................##..........................##.##############.'
|
||||||
|
,'.###..............................................................................................................................##..........................##....##############.'
|
||||||
|
,'.###.....................................######......................######.........######...#x#x#x#...........................##..........................##..................###.'
|
||||||
|
,'.###.........................................................................................#######........................##..........................##.....................###.'
|
||||||
|
,'.###..............................######...................................................................######........##..........................##........................###.'
|
||||||
|
,'.###..................................................................................................................##..........................##...........................###.'
|
||||||
|
,'.##########................######..............................................................................................................##..............................###.'
|
||||||
|
,'.##########...............................................................................................................................####.................................###.'
|
||||||
|
,'.##################################xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###.'
|
||||||
|
,'.##################################xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###.'
|
||||||
|
,'.#################################################################################################################################################################################.'
|
||||||
|
,'.#################################################################################################################################################################################.'
|
||||||
|
,'.#################################################################################################################################################################################.'
|
||||||
|
,'Super Awesome Carrot', 'Josh'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'....................................................................................................................................'
|
||||||
|
,'..................................................................................................................###...............'
|
||||||
|
,'..................................................................................................................###...............'
|
||||||
|
,'.###........................................................................................................FFFFFF###...............'
|
||||||
|
,'.###.....................................................................###...............#####............FFFFFF###...............'
|
||||||
|
,'.###.....................................................................###...............#####............#########...............'
|
||||||
|
,'.###.....................................................................###................................#########...............'
|
||||||
|
,'.###.....................................................................#########.............................###..................'
|
||||||
|
,'.###.....................................................................#########.............................###..................'
|
||||||
|
,'.###....................#.............................###................#########.............................###..................'
|
||||||
|
,'.###....................#.............................###................###############.......................###..................'
|
||||||
|
,'.###..................#.#.#......###.........###......###................###############.......................###..................'
|
||||||
|
,'.###..................#.#.#......###.........###......###................###############.......................###..................'
|
||||||
|
,'.##########.........#.#x#x###############################...################################.......###############..................'
|
||||||
|
,'.##########.........#.#x#x###############################...##################################...#################..................'
|
||||||
|
,'.########################################################........................................#################..................'
|
||||||
|
,'.########################################################........................................#################..................'
|
||||||
|
,'.#################################################################################################################..................'
|
||||||
|
,'.#################################################################################################################..................'
|
||||||
|
,'.#################################################################################################################..................'
|
||||||
|
,'Duck', 'Asraelite'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
levelparts = [ // Free roam level sections
|
||||||
[
|
[
|
||||||
'.....................'
|
'.....................'
|
||||||
,'.....................'
|
,'.....................'
|
||||||
|
|
BIN
lol.mp3
BIN
lol.mp3
Binary file not shown.
399
sint.js
399
sint.js
|
@ -24,14 +24,25 @@ function start(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get mouse position
|
// Get mouse position
|
||||||
function getMouse(evt) {
|
function getMouse(evt){
|
||||||
var rect = canvas.getBoundingClientRect();
|
var rect = canvas.getBoundingClientRect();
|
||||||
return {
|
return {
|
||||||
x: evt.clientX - rect.left,
|
x: evt.clientX - rect.left,
|
||||||
y: evt.clientY - rect.top,
|
y: evt.clientY - rect.top
|
||||||
click: false
|
};
|
||||||
};
|
}
|
||||||
}
|
|
||||||
|
// Get touch position on mobiles
|
||||||
|
function getTouch(evt){
|
||||||
|
var rect = canvas.getBoundingClientRect();
|
||||||
|
var touch = evt.touches[0];
|
||||||
|
console.log(touch);
|
||||||
|
evt.preventDefault();
|
||||||
|
return {
|
||||||
|
x: touch.clientX - rect.left,
|
||||||
|
y: touch.clientY - rect.top
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Set up variables
|
// Set up variables
|
||||||
function reset(){
|
function reset(){
|
||||||
|
@ -42,69 +53,120 @@ function reset(){
|
||||||
camera = [];
|
camera = [];
|
||||||
ais = [];
|
ais = [];
|
||||||
keys = [];
|
keys = [];
|
||||||
|
keysDown = [];
|
||||||
test = [];
|
test = [];
|
||||||
level = ['','','','','','','','','','','','','','','','','','','',''];
|
level = ['','','','','','','','','','','','','','','','','','','',''];
|
||||||
partsInserted = [];
|
partsInserted = [];
|
||||||
optionvars = [50, 50];
|
optionvars = [50, 50, 87, 65, 68, 69, 81];
|
||||||
|
game = 'menu';
|
||||||
|
moveLocked = false;
|
||||||
|
lookx = 0;
|
||||||
|
ui = {
|
||||||
|
select: 0,
|
||||||
|
area: 0
|
||||||
|
}
|
||||||
mouse = {
|
mouse = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
down: false,
|
down: false,
|
||||||
click: false
|
click: false
|
||||||
};
|
};
|
||||||
|
tomenu = false;
|
||||||
slow = false;
|
slow = false;
|
||||||
|
trialComplete = false;
|
||||||
|
finTime = false;
|
||||||
sound = {
|
sound = {
|
||||||
shoot1: new Audio('sfx.wav'),
|
shoot1: new Audio('sfx.wav'),
|
||||||
jump: new Audio('Funk.mp3'),
|
jump: new Audio('Funk.mp3'),
|
||||||
lol: new Audio('lol.mp3')
|
|
||||||
}
|
|
||||||
game = 'menu';
|
|
||||||
ui = {
|
|
||||||
select : 0,
|
|
||||||
area : 0
|
|
||||||
}
|
}
|
||||||
menu = [
|
menu = [
|
||||||
[
|
[
|
||||||
['Singleplayer', 2, true],
|
['Play', 4, true],
|
||||||
['Multiplayer', 3, true],
|
//['Multiplayer', 5, true],
|
||||||
['Options', 1, true],
|
['Options', 1, true],
|
||||||
['Credits', 4, true]
|
['Credits', 6, true]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['Sound levels', 2, true],
|
||||||
|
['Controls', 3, true],
|
||||||
|
['Back', 0, true]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
['Music', 's', 0, 0, 100, false],
|
['Music', 's', 0, 0, 100, false],
|
||||||
['Sound', 's', 1, 0, 100, false],
|
['Sound', 's', 1, 0, 100, false],
|
||||||
|
['Back', 1, true]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['Jump', 'c', 2], ['Left', 'c', 3],
|
||||||
|
['Right', 'c', 4],['Next', 'c', 5],
|
||||||
|
['Prev', 'c', 6],['Back', 1, true, 120]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['Adventure', 5, true],
|
||||||
|
['Time trial', 7, true],
|
||||||
|
['Free play', 5, true],
|
||||||
['Back', 0, true]
|
['Back', 0, true]
|
||||||
],
|
],
|
||||||
['r', 'play'],
|
['r', 'play'],
|
||||||
['r', 'play'],
|
['t', 'Sint', '', 'Programming and graphics by Markus Scully (Asraelite)', 'Sound and music by Christian Stryczynski'],
|
||||||
['t', 'Sint', '', 'Programming and graphics by Asraelite', 'Sound from a source that does not deserve credit']
|
[
|
||||||
]
|
['"Super Awesome Carrot" by Josh', 8, 0, 'tl'],
|
||||||
|
['"Duck" by Asraelite', 8, 1, 'tl'],
|
||||||
|
['Back', 7, true]
|
||||||
|
],
|
||||||
|
['r', 'time']
|
||||||
|
];
|
||||||
lastspeed = 0;
|
lastspeed = 0;
|
||||||
|
|
||||||
|
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)){ // Check if mobile
|
||||||
//controllers[1] = new Controller(actors[2], [[39, 'moveRight'], [37, 'moveLeft'], [38, 'jump'], [88, 'camera'], [78, 'bounce', 100]]);
|
mobile = true;
|
||||||
|
}else{
|
||||||
|
mobile = false;
|
||||||
|
}
|
||||||
|
|
||||||
// type, affiliation, lifespan, xpos, ypos, xvel, yvel
|
// type, affiliation, lifespan, xpos, ypos, xvel, yvel
|
||||||
particles[0] = new Particle('mouse', 0, 10000000000, 0, 0, 0, 0);
|
|
||||||
defineLevels(); // Call function to create level variables
|
defineLevels(); // Call function to create level variables
|
||||||
//level = 2 // Set level
|
//level = 2 // Set level
|
||||||
spritesheet = new Image(); // Define spritesheet
|
spritesheet = new Image(); // Define spritesheet
|
||||||
spritesheet.src = 'actors.png';
|
spritesheet.src = 'actors.png';
|
||||||
document.addEventListener('keydown', keyDown, true); // Add key events
|
document.addEventListener('keydown', keyDown, true); // Add key events
|
||||||
document.addEventListener('keyup', keyUp, true);
|
document.addEventListener('keyup', keyUp, true);
|
||||||
document.addEventListener('mousemove', function(evt){mouse.x = getMouse(evt).x; mouse.y = getMouse(evt).y}, false);
|
if(mobile){
|
||||||
document.addEventListener('mousedown', function(evt){mouse.down = true}, false);
|
document.body.addEventListener('touchstart', function(evt){mouse.down = true}, false);
|
||||||
document.addEventListener('mouseup', function(evt){mouse.down = false}, false);
|
document.body.addEventListener('touchend', function(evt){mouse.down = false}, false);
|
||||||
|
document.body.addEventListener('touchmove', function(evt){mouse.x = getTouch(evt).x; mouse.y = getTouch(evt).y}, false);
|
||||||
|
}else{
|
||||||
|
document.addEventListener('mousedown', function(evt){mouse.down = true}, false);
|
||||||
|
document.addEventListener('mouseup', function(evt){mouse.down = false}, false);
|
||||||
|
document.addEventListener('mousemove', function(evt){mouse.x = getMouse(evt).x; mouse.y = getMouse(evt).y}, false);
|
||||||
|
}
|
||||||
|
|
||||||
animate();
|
animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toMenu(){
|
||||||
|
actors = [];
|
||||||
|
controllers = [];
|
||||||
|
particles = [];
|
||||||
|
camera = [];
|
||||||
|
ais = [];
|
||||||
|
keys = [];
|
||||||
|
level = ['','','','','','','','','','','','','','','','','','','',''];
|
||||||
|
partsInserted = [];
|
||||||
|
game = 'menu';
|
||||||
|
ui.area = 0;
|
||||||
|
ui.select = 0;
|
||||||
|
tomenu = false;
|
||||||
|
}
|
||||||
|
|
||||||
function play(){
|
function play(){
|
||||||
// Create player and its key controller
|
// Create player and its key controller
|
||||||
actors[0] = new Actor(0, 'player', 200, 3, 128, 64, 16, 16);
|
actors[0] = new Actor(0, 'player', 200, 3, 128, 64, 16, 16);
|
||||||
controllers[0] = new Controller(actors[0], [[68, 'moveRight'], [65, 'moveLeft'], [87, 'jump'], [67, 'camera'], /*[69, 'stream', 100]*/, [81, 'suicide']]);
|
controllers[0] = new Controller(actors[0], [[optionvars[4], 'moveRight'], [optionvars[3], 'moveLeft'], [optionvars[2], 'jump'], [27, 'quit'], [81, 'suicide', 0]]);
|
||||||
|
|
||||||
actors[1] = new Actor(6, 'all', 200, 3, 256, 64, 16, 16);
|
particles[0] = new Particle('mouse', 0, 10000000000, 0, 0, 0, 0); // Create reticule
|
||||||
ais[0] = new Ai(1, 'pace');
|
|
||||||
|
finTime = false;
|
||||||
|
|
||||||
camera = [actors[0]]; // Set camera.
|
camera = [actors[0]]; // Set camera.
|
||||||
}
|
}
|
||||||
|
@ -162,6 +224,7 @@ function keyDown(e){
|
||||||
}
|
}
|
||||||
if(keys.indexOf(keyPress) == -1){
|
if(keys.indexOf(keyPress) == -1){
|
||||||
keys.push(keyPress);
|
keys.push(keyPress);
|
||||||
|
keysDown.push(keyPress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +245,14 @@ function Controller(object, actions){
|
||||||
this.actor = object;
|
this.actor = object;
|
||||||
this.checkKeys = function(){
|
this.checkKeys = function(){
|
||||||
for(i in actions){
|
for(i in actions){
|
||||||
if(keys.indexOf(actions[i][0]) > -1){
|
if(actions[i].length > 2 && actions[i][2] == 0){
|
||||||
this.actor.action(actions[i][1]);
|
if(keysDown.indexOf(actions[i][0]) > -1){
|
||||||
|
this.actor.action(actions[i][1]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(keys.indexOf(actions[i][0]) > -1){
|
||||||
|
this.actor.action(actions[i][1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(mouse.click && actions[i][0] == 'c'){
|
if(mouse.click && actions[i][0] == 'c'){
|
||||||
this.actor.action(actions[i][1]);
|
this.actor.action(actions[i][1]);
|
||||||
|
@ -278,6 +347,7 @@ function Actor(image, type, health, power, xpos, ypos, width, height){
|
||||||
this.actionsturn = [];
|
this.actionsturn = [];
|
||||||
this.index = actors.length;
|
this.index = actors.length;
|
||||||
this.vars = [false, false, false]; // for use by AIs to control particles
|
this.vars = [false, false, false]; // for use by AIs to control particles
|
||||||
|
this.test = '';
|
||||||
|
|
||||||
this.refreshActions = function(){
|
this.refreshActions = function(){
|
||||||
this.oneactions = [];
|
this.oneactions = [];
|
||||||
|
@ -300,8 +370,8 @@ function Actor(image, type, health, power, xpos, ypos, width, height){
|
||||||
if(this.box.collide() || this.box.inlava){
|
if(this.box.collide() || this.box.inlava){
|
||||||
this.yvel = (-4 - this.power) * (this.box.inlava ? 0.2 : 1);
|
this.yvel = (-4 - this.power) * (this.box.inlava ? 0.2 : 1);
|
||||||
distanceToSound = Math.abs(this.x - lookx - 250);
|
distanceToSound = Math.abs(this.x - lookx - 250);
|
||||||
if(Math.abs(this.x - lookx) < 300){
|
if(distanceToSound < 300){
|
||||||
sound.jump.volume = r(((optionvars[1]) / 100) / (distanceToSound < 100 ? 1 : distanceToSound / 50));
|
sound.jump.volume = (r(distanceToSound < 100 ? 1 : (300 - distanceToSound) / 200) * optionvars[1]) / 100;
|
||||||
sound.jump.play();
|
sound.jump.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +403,11 @@ function Actor(image, type, health, power, xpos, ypos, width, height){
|
||||||
this.vars = [true, this.vars[1], this.vars[2]];
|
this.vars = [true, this.vars[1], this.vars[2]];
|
||||||
break;
|
break;
|
||||||
case 'suicide':
|
case 'suicide':
|
||||||
this.health = (this.y > -50 ? 0 : this.health);
|
this.health = (this.y > 50 ? 0 : this.health);
|
||||||
|
clockStart = new Date().getTime();
|
||||||
|
break;
|
||||||
|
case 'quit':
|
||||||
|
tomenu = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.actionsturn.push(type);
|
this.actionsturn.push(type);
|
||||||
|
@ -354,9 +428,10 @@ function Actor(image, type, health, power, xpos, ypos, width, height){
|
||||||
if(this.health <= 0){
|
if(this.health <= 0){
|
||||||
this.health = 200;
|
this.health = 200;
|
||||||
for(i = 0; i < 64; i++){
|
for(i = 0; i < 64; i++){
|
||||||
particles.push(new Particle(0, 0, Math.random() * 500 + 2500, this.x + ((i % 8) * 2), this.y - ((i % 8) * 2), (Math.random() - 0.5) * 10, (Math.random() - 0.8) * 10));
|
particles.push(new Particle(0, 0, Math.random() * 500 + 2500, this.x + ((i % 8) * 2), this.y - ((i % 8) * 2), (Math.random() - 0.5) * 10, (Math.random() - 0.8) * 10), true);
|
||||||
}
|
}
|
||||||
this.y = -500;
|
this.y = 0;
|
||||||
|
this.x = 128;
|
||||||
}
|
}
|
||||||
//this.xvel *= Math.pow(0.992, speed);
|
//this.xvel *= Math.pow(0.992, speed);
|
||||||
}
|
}
|
||||||
|
@ -436,11 +511,6 @@ function Particle(type, affiliation, lifespan, xpos, ypos, xvel, yvel, gravity){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onGround = function(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.simulate = function(){
|
this.simulate = function(){
|
||||||
switch(this.type){
|
switch(this.type){
|
||||||
case 'mouse':
|
case 'mouse':
|
||||||
|
@ -460,10 +530,22 @@ function Particle(type, affiliation, lifespan, xpos, ypos, xvel, yvel, gravity){
|
||||||
}
|
}
|
||||||
this.x = lookx;
|
this.x = lookx;
|
||||||
if(mouse.down){
|
if(mouse.down){
|
||||||
particles.push(new Particle(0, 0, 9000, lookx + mouse.x, mouse.y, (Math.random() - 0.5) * 5, (Math.random() - 0.5) * 5));
|
if(!mobile){
|
||||||
|
particles.push(new Particle(0, 0, 9000, lookx + mouse.x, mouse.y, (Math.random() - 0.5) * 5, (Math.random() - 0.5) * 5));
|
||||||
|
}else{
|
||||||
|
if(mouse.y < 100){
|
||||||
|
actors[0].action('jump');
|
||||||
|
}
|
||||||
|
if(mouse.x > 300){
|
||||||
|
actors[0].action('moveRight');
|
||||||
|
}else if(mouse.x < 200){
|
||||||
|
actors[0].action('moveLeft');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.vars[0] = 6;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case 0:
|
||||||
for(j in actors){
|
for(j in actors){
|
||||||
if(Math.abs(this.x - (actors[j].x + 8)) < 20 && Math.abs(this.y - (actors[j].y + 8)) < 20){
|
if(Math.abs(this.x - (actors[j].x + 8)) < 20 && Math.abs(this.y - (actors[j].y + 8)) < 20){
|
||||||
this.xvel += (20 - Math.abs(this.x - (actors[j].x + 8))) / (this.x > (actors[j].x + 8) ? 5 : -5);
|
this.xvel += (20 - Math.abs(this.x - (actors[j].x + 8))) / (this.x > (actors[j].x + 8) ? 5 : -5);
|
||||||
|
@ -471,6 +553,10 @@ function Particle(type, affiliation, lifespan, xpos, ypos, xvel, yvel, gravity){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(thisLoop > this.timeup){
|
if(thisLoop > this.timeup){
|
||||||
this.deleteme = true;
|
this.deleteme = true;
|
||||||
|
@ -537,6 +623,8 @@ function Box(x, y, w, h, xvel, yvel, colgroup, gravity){
|
||||||
this.inlava = true;
|
this.inlava = true;
|
||||||
this.xvel *= Math.pow(0.999, speed);
|
this.xvel *= Math.pow(0.999, speed);
|
||||||
this.yvel *= Math.pow(0.999, speed);
|
this.yvel *= Math.pow(0.999, speed);
|
||||||
|
}else if(lv[ycol - 1][xcol] == 'F'){
|
||||||
|
trialComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -646,34 +734,41 @@ function loopGame(){
|
||||||
speed = (thisLoop - lastLoop);
|
speed = (thisLoop - lastLoop);
|
||||||
speed = (speed > 50 ? 50 : speed);
|
speed = (speed > 50 ? 50 : speed);
|
||||||
context.clearRect(0, 0, 500, 350);
|
context.clearRect(0, 0, 500, 350);
|
||||||
lookx = looky = 0;
|
limitLeft = 16;
|
||||||
looky = -0;
|
limitRight = 16;
|
||||||
var maxx = 0;
|
if(game == 'playing'){
|
||||||
for(i in actors){
|
if(gameMode == 'free'){
|
||||||
if(actors[i].x > maxx){
|
var maxx = 0;
|
||||||
maxx = actors[i].x;
|
for(i in actors){
|
||||||
}
|
if(actors[i].x > maxx){
|
||||||
}
|
maxx = actors[i].x;
|
||||||
maxx += 1;
|
}
|
||||||
while(level[0].length < maxx){
|
|
||||||
partIndex = Math.floor(Math.random() * (levelparts.length - 1)) + 1;
|
|
||||||
partFound = false;
|
|
||||||
if(partsInserted.length == 0){
|
|
||||||
var toInsert = levelparts[0];
|
|
||||||
partsInserted.push([false, '5n', 1, 1, 0]);
|
|
||||||
partFound = true;
|
|
||||||
}else{
|
|
||||||
thisPart = levelparts[partIndex];
|
|
||||||
if(thisPart[20] == partsInserted[partsInserted.length - 1][1] && (Math.random() * thisPart[24]) < 1){
|
|
||||||
partsInserted.push([thisPart[20], thisPart[21], thisPart[22], thisPart[23], thisPart[24]]);
|
|
||||||
toInsert = thisPart;
|
|
||||||
partFound = true;
|
|
||||||
}
|
}
|
||||||
}
|
maxx += 1;
|
||||||
if(partFound){
|
while(level[0].length < maxx){
|
||||||
for(i = 0; i < 20; i++){
|
partIndex = Math.floor(Math.random() * (levelparts.length - 1)) + 1;
|
||||||
level[i] += toInsert[i];
|
partFound = false;
|
||||||
|
if(partsInserted.length == 0){
|
||||||
|
var toInsert = levelparts[0];
|
||||||
|
partsInserted.push([false, '5n', 1, 1, 0]);
|
||||||
|
partFound = true;
|
||||||
|
}else{
|
||||||
|
thisPart = levelparts[partIndex];
|
||||||
|
if(thisPart[20] == partsInserted[partsInserted.length - 1][1] && (Math.random() * thisPart[24]) < 1){
|
||||||
|
partsInserted.push([thisPart[20], thisPart[21], thisPart[22], thisPart[23], thisPart[24]]);
|
||||||
|
toInsert = thisPart;
|
||||||
|
partFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(partFound){
|
||||||
|
for(i = 0; i < 20; i++){
|
||||||
|
level[i] += toInsert[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}else if(gameMode == 'time'){
|
||||||
|
level = timelevels[levelNo];
|
||||||
|
limitRight = (level[0].length << 4) - 516;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i in controllers){
|
for(i in controllers){
|
||||||
|
@ -682,12 +777,20 @@ function loopGame(){
|
||||||
for(i in actors){
|
for(i in actors){
|
||||||
actors[i].simulate();
|
actors[i].simulate();
|
||||||
}
|
}
|
||||||
|
lookx = 0
|
||||||
|
looky = 0;
|
||||||
for(i in camera){
|
for(i in camera){
|
||||||
lookx += (camera[i] instanceof Array ? camera[i][0] : camera[i].x + camera[i].xvel * 1) - 250;
|
lookx += (camera[i] instanceof Array ? camera[i][0] : camera[i].x + camera[i].xvel * 1) - 250;
|
||||||
// looky += (camera[i] == instanceof Array ? camera[i][1] : camera[i].y) - 175;
|
// looky += (camera[i] == instanceof Array ? camera[i][1] : camera[i].y) - 175;
|
||||||
}
|
}
|
||||||
lookx /= camera.length;
|
lookx /= camera.length;
|
||||||
looky /= camera.length;
|
looky /= camera.length;
|
||||||
|
if(lookx < limitLeft){
|
||||||
|
lookx = limitLeft;
|
||||||
|
}
|
||||||
|
if(lookx > limitRight && gameMode != 'free'){
|
||||||
|
lookx = limitRight;
|
||||||
|
}
|
||||||
|
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = 1;
|
||||||
context.lineWidth = 1;
|
context.lineWidth = 1;
|
||||||
|
@ -750,12 +853,29 @@ function loopGame(){
|
||||||
}
|
}
|
||||||
lastspeed = (new Date() % 10 == 0 ? r(1000 / speed) : lastspeed);
|
lastspeed = (new Date() % 10 == 0 ? r(1000 / speed) : lastspeed);
|
||||||
context.fillText('FPS: ' + lastspeed, 10, 20);
|
context.fillText('FPS: ' + lastspeed, 10, 20);
|
||||||
|
if(game == 'playing'){
|
||||||
|
if(gameMode == 'time'){
|
||||||
|
var time = r((new Date().getTime() - clockStart)) / 1000;
|
||||||
|
if(trialComplete && !finTime){
|
||||||
|
finTime = (Math.floor(time / 60) + ':' + (r(time % 60) < 10 ? '0' + r(time % 60) : r(time % 60)));
|
||||||
|
}
|
||||||
|
context.fillText('Time: ' + (finTime ? finTime : (Math.floor(time / 60) + ':' + (r(time % 60) < 10 ? '0' + r(time % 60) : r(time % 60)))), 10, 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
context.textAlign = 'right';
|
context.textAlign = 'right';
|
||||||
context.fillText('Sint version α 0.4.2', 490, 310);
|
if(mobile){
|
||||||
|
context.fillText('RetX: ' + r(mouse.x), 420, 290);
|
||||||
|
context.fillText('RetX: ' + r(mouse.y), 490, 290);
|
||||||
|
context.fillText('Sint mobile version α 0.5', 490, 310);
|
||||||
|
}else{
|
||||||
|
context.fillText('Sint version α 0.5', 490, 310);
|
||||||
|
}
|
||||||
context.fillText(test, 490, 290);
|
context.fillText(test, 490, 290);
|
||||||
if(game == 'playing'){
|
if(game == 'playing'){
|
||||||
context.fillText('Actors: ' + actors.length, 490, 20);
|
context.fillText('Actors: ' + actors.length, 490, 20);
|
||||||
context.fillText('Particles: ' + particles.length, 490, 40);
|
context.fillText('Particles: ' + particles.length, 490, 40);
|
||||||
|
context.fillText(r(lookx), 490, 60);
|
||||||
|
context.fillText(actors[0].test, 490, 80);
|
||||||
}
|
}
|
||||||
for(i in ais){
|
for(i in ais){
|
||||||
if(Math.abs(ais[i].actor.x - lookx) < 2000){
|
if(Math.abs(ais[i].actor.x - lookx) < 2000){
|
||||||
|
@ -763,61 +883,59 @@ function loopGame(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i in particles){
|
for(i in particles){
|
||||||
particles[i].simulate()
|
try{
|
||||||
particles[i]. draw()
|
particles[i].simulate();
|
||||||
|
particles[i]. draw();
|
||||||
|
}catch(err){
|
||||||
|
particles.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
console.error('Particle error');
|
||||||
|
}
|
||||||
if(particles[i].deleteme || particles.length > 3000){
|
if(particles[i].deleteme || particles.length > 3000){
|
||||||
particles.splice(i, 1);
|
particles.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(game == 'menu'){
|
if(game == 'menu'){
|
||||||
if(keys.indexOf(83) > -1){
|
if(keysDown.indexOf(83) > -1 && moveLocked == false){
|
||||||
if(menudown == false){
|
ui.select += 1;
|
||||||
menudown = true;
|
|
||||||
ui.select += 1;
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
menudown = false;
|
menudown = false;
|
||||||
}
|
}
|
||||||
if(keys.indexOf(87) > -1){
|
if(keysDown.indexOf(87) > -1 && moveLocked == false){
|
||||||
if(menuup == false){
|
ui.select -= 1;
|
||||||
menuup = true;
|
|
||||||
ui.select -= 1;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
menuup = false;
|
|
||||||
}
|
|
||||||
if(keys.indexOf(13) > -1){
|
|
||||||
if(menuenter == false){
|
|
||||||
menuenter = true;
|
|
||||||
if(menu[ui.area][ui.select][2]){
|
|
||||||
ui.area = menu[ui.area][ui.select][1];
|
|
||||||
ui.select = 0;
|
|
||||||
}else if(menu[ui.area][0] == 't'){
|
|
||||||
ui.area = 0;
|
|
||||||
ui.select = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
menuenter = false;
|
|
||||||
}
|
}
|
||||||
ui.select = (ui.select + menu[ui.area].length) % menu[ui.area].length;
|
ui.select = (ui.select + menu[ui.area].length) % menu[ui.area].length;
|
||||||
context.fillStyle = '69d';
|
if(menu[ui.area][0] == 't'){
|
||||||
|
ui.select = 0;
|
||||||
|
}
|
||||||
|
var thisType = menu[ui.area][ui.select][1];
|
||||||
|
// Draw menu
|
||||||
|
context.fillStyle = '#69d';
|
||||||
context.font = '40pt Helvetica';
|
context.font = '40pt Helvetica';
|
||||||
context.textAlign = 'center';
|
context.textAlign = 'center';
|
||||||
context.shadowColor = '69d';
|
context.shadowColor = '#69d';
|
||||||
context.shadowBlur = 10;
|
context.shadowBlur = 10;
|
||||||
context.fillText('Sint', 250, 100);
|
context.fillText('Sint', 250, 100);
|
||||||
context.shadowBlur = 0;
|
context.shadowBlur = 0;
|
||||||
// Main menu
|
// Main menu
|
||||||
|
if(mobile){
|
||||||
|
play();
|
||||||
|
game = 'playing';
|
||||||
|
gameMode = 'free';
|
||||||
|
}
|
||||||
if(menu[ui.area][0] == 'r'){
|
if(menu[ui.area][0] == 'r'){
|
||||||
switch(menu[ui.area][1]){
|
switch(menu[ui.area][1]){
|
||||||
case 'play':
|
case 'play':
|
||||||
play();
|
play();
|
||||||
game = 'playing';
|
game = 'playing';
|
||||||
|
gameMode = 'free';
|
||||||
break;
|
break;
|
||||||
case 'fractal':
|
case 'time':
|
||||||
game = 'test';
|
play();
|
||||||
|
clockStart = new Date().getTime();
|
||||||
|
game = 'playing';
|
||||||
|
gameMode = 'time';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ui.area = 0;
|
ui.area = 0;
|
||||||
|
@ -830,10 +948,10 @@ function loopGame(){
|
||||||
context.fillText(menu[ui.area][i], 250, 120 + (20 * i));
|
context.fillText(menu[ui.area][i], 250, 120 + (20 * i));
|
||||||
}
|
}
|
||||||
context.fillStyle = '#9bf';
|
context.fillStyle = '#9bf';
|
||||||
context.fillRect(150, 150 + (20 * i), 200, 25);
|
context.fillRect(150, 130 + (20 * i), 200, 25);
|
||||||
context.font = '12pt Helvetica';
|
context.font = '12pt Helvetica';
|
||||||
context.fillStyle = '#fff';
|
context.fillStyle = '#fff';
|
||||||
context.fillText('Back', 250, 168 + (20 * i));
|
context.fillText('Back', 250, 148 + (20 * i));
|
||||||
}else{
|
}else{
|
||||||
for(i in menu[ui.area]){
|
for(i in menu[ui.area]){
|
||||||
if(menu[ui.area][i][1] == 's'){
|
if(menu[ui.area][i][1] == 's'){
|
||||||
|
@ -853,27 +971,86 @@ function loopGame(){
|
||||||
context.strokeRect(240 + optionaddx, 155 + (30 * i), 10, 10);
|
context.strokeRect(240 + optionaddx, 155 + (30 * i), 10, 10);
|
||||||
context.fillRect(240 + optionaddx, 155 + (30 * i), 10, 10);
|
context.fillRect(240 + optionaddx, 155 + (30 * i), 10, 10);
|
||||||
if(ui.select == i){
|
if(ui.select == i){
|
||||||
if(keys.indexOf(65) > -1 && optionvars[thisoption] > menu[ui.area][i][3]){
|
if(keys.indexOf(65) > -1){
|
||||||
optionvars[thisoption] -= 0.05 * speed;
|
if(optionvars[thisoption] > menu[ui.area][i][3]){
|
||||||
|
optionvars[thisoption] -= 0.1 * speed;
|
||||||
|
}else{
|
||||||
|
optionvars[thisoption] = menu[ui.area][i][3]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(keys.indexOf(68) > -1 && optionvars[thisoption] < menu[ui.area][i][4]){
|
if(keys.indexOf(68) > -1){
|
||||||
optionvars[thisoption] += 0.05 * speed;
|
if(optionvars[thisoption] < menu[ui.area][i][4]){
|
||||||
|
optionvars[thisoption] += 0.1 * speed;
|
||||||
|
}else{
|
||||||
|
optionvars[thisoption] = menu[ui.area][i][4]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(menu[ui.area][i][1] == 'c'){
|
||||||
|
context.fillStyle = (ui.select == i ? '#9bf' : '#cdf');
|
||||||
|
context.fillRect(150, 120 + (30 * i), 80, 25);
|
||||||
|
context.font = '12pt Helvetica';
|
||||||
|
context.fillStyle = (ui.select == i ? '#fff' : '#eef');
|
||||||
|
context.fillText(menu[ui.area][i][0], 190, 138 + (30 * i));
|
||||||
|
context.fillStyle = (ui.select == i ? '#9bf' : '#cdf');
|
||||||
|
context.fillRect(240, 120 + (30 * i), 110, 25);
|
||||||
|
context.fillStyle = (ui.select == i ? '#fff' : '#eef');
|
||||||
|
var tempIn = optionvars[parseInt(i) + 2];
|
||||||
|
if(tempIn > 47){
|
||||||
|
tempIn = String.fromCharCode(tempIn);
|
||||||
|
}
|
||||||
|
if(tempIn == 0){
|
||||||
|
tempIn = 'Enter key';
|
||||||
|
}
|
||||||
|
context.fillText(tempIn, 290, 138 + (30 * i));
|
||||||
|
|
||||||
|
if(ui.select == i){
|
||||||
|
if(keysDown.length > 0 && keysDown.indexOf(13) > -1 && moveLocked == false){
|
||||||
|
moveLocked = true;
|
||||||
|
optionvars[ui.select + 2] = 0;
|
||||||
|
}else if(keysDown.length > 0 && moveLocked == true){
|
||||||
|
optionvars[ui.select + 2] = keysDown[0];
|
||||||
|
moveLocked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
thisOne = menu[ui.area];
|
||||||
|
if(thisOne[i].length > 3){
|
||||||
|
var more = thisOne[i][3];
|
||||||
|
}else{
|
||||||
|
var more = false;
|
||||||
|
}
|
||||||
context.fillStyle = (ui.select == i ? '#9bf' : '#cdf');
|
context.fillStyle = (ui.select == i ? '#9bf' : '#cdf');
|
||||||
context.fillRect(150, 150 + (30 * i), 200, 25);
|
context.fillRect((more == 'tl' ? 100 : 150), (typeof more === 'number' ? more : 150) + (30 * i), (more == 'tl' ? 300 : 200), 25);
|
||||||
context.font = '12pt Helvetica';
|
context.font = '12pt Helvetica';
|
||||||
context.fillStyle = (ui.select == i ? '#fff' : '#eef');
|
context.fillStyle = (ui.select == i ? '#fff' : '#eef');
|
||||||
context.fillText(menu[ui.area][i][0], 250, 168 + (30 * i));
|
context.fillText(menu[ui.area][i][0], 250, (typeof more === 'number' ? more + 18 : 168) + (30 * i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(keysDown.indexOf(13) > -1 && thisType != 'c' && thisType != 's'){
|
||||||
|
if(menu[ui.area][ui.select][0] == 't'){
|
||||||
|
ui.area = 0;
|
||||||
|
ui.select = 0;
|
||||||
|
}else if(menu[ui.area][ui.select][3] == 'tl'){
|
||||||
|
levelNo = ui.select;
|
||||||
|
ui.area = 8;
|
||||||
|
ui.select = 0;
|
||||||
|
}else{
|
||||||
|
ui.area = menu[ui.area][ui.select][1];
|
||||||
|
ui.select = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slow down game to test low framerates
|
// Slow down game to test low framerates
|
||||||
if(slow){
|
if(slow){
|
||||||
for(var j=1; j < 10000000; j++){
|
for(var j=1; j < 10000000; j++){
|
||||||
j = j;
|
j = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(tomenu){
|
||||||
|
toMenu();
|
||||||
|
}
|
||||||
|
keysDown = [];
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue