Version 0.6.3

Added 2 new particles to shoot. Added sounds for purple particle
exploding and for getting points. Added support for shoot per click.
Fixed particles shaking in selection box. Made identical level parts
after each other far less common.
This commit is contained in:
Markus Scully 2013-08-23 18:16:58 +01:00
parent 54d6cb3944
commit d5f7c2534d
4 changed files with 110 additions and 51 deletions

BIN
explode.wav Normal file

Binary file not shown.

View file

@ -94,29 +94,6 @@ function defineLevels(){
,'.####################' ,'.####################'
,false, '5n', 1, 1, 0 // What type of connection it has left, right, the minimum level it appears, the maximum, and the rarity ,false, '5n', 1, 1, 0 // What type of connection it has left, right, the minimum level it appears, the maximum, and the rarity
], ],
[
'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'...................'
,'###################'
,'###################'
,'###################'
,'###################'
,'###################'
,'5n', '5n', 1, 50, 2
],
[ [
'...................' '...................'
,'...................' ,'...................'

BIN
point.wav Normal file

Binary file not shown.

138
sint.js
View file

@ -125,7 +125,9 @@ function reset(){
finTime = false; finTime = false;
sound = { sound = {
shoot1: new Audio('sfx2.wav'), shoot1: new Audio('sfx2.wav'),
jump: new Audio('Funk.mp3'), point: new Audio('point.wav'),
explode: new Audio('explode.wav'),
jump: new Audio('Funk.mp3')
} }
music = { music = {
dash: { dash: {
@ -223,7 +225,7 @@ function toMenu(){
function play(){ function play(){
// Create player and its key controller // Create player and its key controller
actors[0] = new Actor(0, 'player', 200, 8, 200, 3, 128, 64, 16, 16); actors[0] = new Actor(0, 0, 200, 8, 200, 3, 128, 64, 16, 16);
controllers[0] = new Controller(actors[0], [[optionvars[4], 'moveRight'], [optionvars[3], 'moveLeft'], [optionvars[2], 'jump'], [27, 'quit'], [90, 'suicide', 0], ['c', 'current'], [optionvars[5], 'next', 0], [optionvars[6], 'prev', 0]]); controllers[0] = new Controller(actors[0], [[optionvars[4], 'moveRight'], [optionvars[3], 'moveLeft'], [optionvars[2], 'jump'], [27, 'quit'], [90, 'suicide', 0], ['c', 'current'], [optionvars[5], 'next', 0], [optionvars[6], 'prev', 0]]);
particles[0] = new Particle('mouse', 0, 'mouse', 10000000000, 0, 0, 0, 0, 0, [0, 0]); // Create reticule particles[0] = new Particle('mouse', 0, 'mouse', 10000000000, 0, 0, 0, 0, 0, [0, 0]); // Create reticule
@ -240,6 +242,21 @@ function animate() {
loopGame(); loopGame();
} }
function control(n){
if(actors[n]){
camera = [actors[n]];
for(var i in ais){
if(ais[i].actor == actors[n]){
ais.splice(i, 1);
}
controllers[0] = new Controller(actors[n], [[optionvars[4], 'moveRight'], [optionvars[3], 'moveLeft'], [optionvars[2], 'jump'], [27, 'quit'], [90, 'suicide', 0], ['c', 'current'], [optionvars[5], 'next', 0], [optionvars[6], 'prev', 0]]);
}
}else{
return false;
}
}
// Rounds a number. // Rounds a number.
function r(num){ function r(num){
return Math.round(num); return Math.round(num);
@ -247,7 +264,7 @@ function r(num){
function spawn(no){ function spawn(no){
for(i = 0 ; i < no; i++){ for(i = 0 ; i < no; i++){
actors[actors.length] = new Actor(7, 'all', 1, 6, 50, 3, lookx + 250 + ((Math.random() - 0.5) * 200), 0, 16, 16); actors[actors.length] = new Actor(7, 1, 1, 6, 50, 3, lookx + 250 + ((Math.random() - 0.5) * 200), 0, 16, 16);
ais[ais.length] = new Ai(actors.length - 1, 'alphaBot'); ais[ais.length] = new Ai(actors.length - 1, 'alphaBot');
} }
} }
@ -352,10 +369,15 @@ function Controller(object, actions){
this.actor.action(actions[i][1]); this.actor.action(actions[i][1]);
} }
} }
if(mouse.down && actions[i][0] == 'c'){ if(mouse.down && actions[i][0] == 'c' && singleActionUsed == false){
this.actor.action(actions[i][1]); if(this.actor.action(actions[i][1])){
singleActionUsed = true;
}
} }
} }
if(!mouse.down){
singleActionUsed = false;
}
this.actor.refreshActions(); this.actor.refreshActions();
} }
} }
@ -443,7 +465,7 @@ function Actor(image, type, health, moveSpeed, energy, powers, xpos, ypos, width
this.speed = moveSpeed; this.speed = moveSpeed;
this.tookDamage = 0; this.tookDamage = 0;
this.select = 0; this.select = 0;
this.powers = 1; this.powers = 3;
this.yvel = 0; this.yvel = 0;
this.xvel = 0; this.xvel = 0;
this.imageLoad = 2; this.imageLoad = 2;
@ -476,7 +498,7 @@ function Actor(image, type, health, moveSpeed, energy, powers, xpos, ypos, width
switch(type){ switch(type){
case 0: case 0:
if(this.energy >= 2){ if(this.energy >= 2){
particles.push(new Particle(0, 0, 0, Math.random() * 500 + 5000, this.x + 8, this.y - 8, Math.cos(angle) * 15 + this.xvel, Math.sin(angle) * 15 + this.yvel, 0.4, [0.997, 0.997])); particles.push(new Particle(0, this.type, 0, Math.random() * 500 + 5000, this.x + 8, this.y - 8, Math.cos(angle) * 15 + this.xvel, Math.sin(angle) * 15 + this.yvel, 0.4, [0.997, 0.997]));
if(distanceToSound < 500){ if(distanceToSound < 500){
sound.shoot1.volume = (r(distanceToSound < 100 ? 1 : (500 - distanceToSound) / 400) * optionvars[1]) / 100; sound.shoot1.volume = (r(distanceToSound < 100 ? 1 : (500 - distanceToSound) / 400) * optionvars[1]) / 100;
sound.shoot1.play(); sound.shoot1.play();
@ -484,6 +506,26 @@ function Actor(image, type, health, moveSpeed, energy, powers, xpos, ypos, width
this.energy -= 2; this.energy -= 2;
} }
break; break;
case 1:
if(this.energy >= 3){
particles.push(new Particle(1, this.type, 4, Math.random() * 500 + 4500, this.x + 8, this.y - 8, Math.cos(angle + ((Math.random() - 0.5) * 0.03)) * 8, Math.sin(angle + ((Math.random() - 0.5) * 0.03)) * 8, 0, [0.999, 0.999]));
if(distanceToSound < 500){
sound.shoot1.volume = (r(distanceToSound < 100 ? 1 : (500 - distanceToSound) / 400) * optionvars[1]) / 100;
sound.shoot1.play();
}
this.energy -= 3;
}
break;
case 2:
if(this.energy >= 100){
particles.push(new Particle(2, 2, 5, 200000, this.x + 8, this.y - 8, Math.cos(angle + ((Math.random() - 0.5) * 0.03)) * 12, Math.sin(angle + ((Math.random() - 0.5) * 0.03)) * 12, 0.5, [0.9975, 0.9975], false));
if(distanceToSound < 500){
sound.shoot1.volume = (r(distanceToSound < 100 ? 1 : (500 - distanceToSound) / 400) * optionvars[1]) / 100;
sound.shoot1.play();
}
this.energy -= 100;
}
break;
case 'en1': case 'en1':
if(this.energy >= 2){ if(this.energy >= 2){
particles.push(new Particle(0, 1, 1, Math.random() * 500 + 5000, this.x + 8, this.y - 8, Math.cos(this.vars[0]) * 15 + this.xvel, Math.sin(this.vars[0]) * 15 + this.yvel, 0.4, [0.995, 0.995])); particles.push(new Particle(0, 1, 1, Math.random() * 500 + 5000, this.x + 8, this.y - 8, Math.cos(this.vars[0]) * 15 + this.xvel, Math.sin(this.vars[0]) * 15 + this.yvel, 0.4, [0.995, 0.995]));
@ -513,6 +555,9 @@ function Actor(image, type, health, moveSpeed, energy, powers, xpos, ypos, width
break; break;
case 'current': case 'current':
this.action(this.select); this.action(this.select);
if(this.select == 2){
return true;
}
break; break;
case 'prev': case 'prev':
if(this.powers > 1){ if(this.powers > 1){
@ -531,6 +576,7 @@ function Actor(image, type, health, moveSpeed, energy, powers, xpos, ypos, width
tomenu = true; tomenu = true;
break; break;
} }
return false;
} }
this.actionsturn.push(type); this.actionsturn.push(type);
} }
@ -618,12 +664,18 @@ function Item(type, xpos, ypos){
break; break;
case 2: case 2:
score += 5; score += 5;
sound.point.volume = optionvars[1] / 150;
sound.point.play();
break; break;
case 3: case 3:
score += 10; score += 10;
sound.point.volume = optionvars[1] / 150;
sound.point.play();
break; break;
case 4: case 4:
score += 20; score += 20;
sound.point.volume = optionvars[1] / 150;
sound.point.play();
break; break;
} }
this.deleteme = true; this.deleteme = true;
@ -632,11 +684,12 @@ function Item(type, xpos, ypos){
} }
} }
function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel, gravity, airRes){ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel, gravity, airRes, actDeath){
this.gravity = typeof gravty !== 'undefined' ? gravity : 1; this.gravity = typeof gravty !== 'undefined' ? gravity : 1;
this.x = xpos; this.x = xpos;
this.y = ypos; this.y = ypos;
this.drawType = drawType; this.drawType = drawType;
this.actDeath = typeof actDeath === 'undefined' ? true : actDeath;
this.xvel = xvel; this.xvel = xvel;
this.yvel = yvel; this.yvel = yvel;
this.type = type; this.type = type;
@ -655,11 +708,21 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
this.box = new Box(this.x, this.y, this.size, this.size, this.xvel, this.yvel, 1, gravity, this.air); this.box = new Box(this.x, this.y, this.size, this.size, this.xvel, this.yvel, 1, gravity, this.air);
this.box.unstuck(); this.box.unstuck();
this.drawBox = function(alpha, width, color, size){ this.drawBox = function(alpha, width, color, size, fill, rel){
context.globalAlpha = alpha; context.globalAlpha = alpha;
context.lineWidth = width; context.lineWidth = width;
context.beginPath();
context.strokeStyle = color; context.strokeStyle = color;
context.strokeRect(r(this.x - lookx) + 0.5, r(this.y - looky) + 0.5, size, size); var add = (width % 2 == 0 ? 0 : 0.5);
var rel = (typeof rel === 'undefined' ? 1 : rel);
context.rect(r(this.x - (lookx * rel)) + add, r(this.y) + add, size, size);
if(typeof fill !== 'undefined'){
if(fill != false){
context.fillStyle = fill;
context.fill();
}
}
context.stroke();
}; };
this.draw = function(extendSize){ this.draw = function(extendSize){
@ -685,10 +748,13 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
this.drawBox(0.5, 1 * extendSize, '#000', 4 * extendSize); this.drawBox(0.5, 1 * extendSize, '#000', 4 * extendSize);
break; break;
case 4: case 4:
this.drawBox(0.8, 1 * extendSize, '#229', 3 * extendSize);
break; break;
case 5: case 5:
this.drawBox(1, 2 * extendSize, '#93b', 5 * extendSize, '#b7f');
break; break;
case 6: case 6:
this.drawBox(1, 1 * extendSize, '#93b', 2 * extendSize);
break; break;
case 7: case 7:
break; break;
@ -701,14 +767,23 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
for(var k = 0; k < 8; k++){ for(var k = 0; k < 8; k++){
//(480 - (k * 35)) + lookx; //(480 - (k * 35)) + lookx;
// 293; // 293;
this.x = (480.5 - (35 * k)) + r(lookx); this.x = 480.5 - (35 * k);
this.y = 293.5; this.y = 293.5;
switch(k){ switch(k){
case 0: case 0:
this.x -= 2; this.x -= 2;
this.y -= 2; this.y -= 2;
this.drawBox(1, 1.5, '#66b', 4); this.drawBox(1, 1.5, '#66b', 4, false, 0);
break; break;
case 1:
this.x -= 3;
this.y -= 3;
this.drawBox(0.8, 2, '#229', 6, false, 0);
break;
case 2:
this.x -= 5;
this.y -= 5;
this.drawBox(1, 3, '#93b', 10, '#b7f', 0);
} }
} }
this.drawType = 'mouse'; this.drawType = 'mouse';
@ -717,6 +792,7 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
} }
this.simulate = function(){ this.simulate = function(){
var distanceToSound = Math.abs(this.x - lookx - 250);
switch(this.type){ switch(this.type){
case 'mouse': case 'mouse':
if(this.vars[0] == false){ if(this.vars[0] == false){
@ -749,17 +825,21 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
} }
break; break;
case 0: case 0:
/*
for(j in actors){
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.yvel += (20 - Math.abs(this.y - (actors[j].y + 8))) / (this.y > (actors[j].y + 8) ? 5 : -5);
}
}
*/
break; break;
case 1: case 1:
break;
case 2:
if(this.yvel == 0){
this.deleteme = true;
for(var i = 0; i < 100; i++){
particles[particles.length] = new Particle(3, 2, 6, Math.random() * 500 + 2000, this.x, this.y, (Math.random() - 0.5) * 18, (Math.random() - 0.9) * 9, 0.4, [0.998, 0.998])
}
sound.explode.volume = (r(distanceToSound < 100 ? 1 : (500 - distanceToSound) / 400) * optionvars[1]) / 400;
sound.explode.play();
}
break;
case 3:
break;
default: default:
break; break;
} }
@ -768,7 +848,7 @@ function Particle(type, affiliation, drawType, lifespan, xpos, ypos, xvel, yvel,
var act = actors[j]; var act = actors[j];
if(this.y + 16 < act.y + act.h && this.y + 16 + this.size > act.y){ if(this.y + 16 < act.y + act.h && this.y + 16 + this.size > act.y){
if(this.x + this.size > act.x && this.x < act.x + act.w && (this.aff == 1 ? j == 0 : j > 0)){ if(this.x + this.size > act.x && this.x < act.x + act.w && (this.aff == 1 ? j == 0 : j > 0)){
actors[j].health -= (Math.abs(this.xvel) + Math.abs(this.yvel)) / 10; actors[j].health -= (Math.abs(this.xvel) + Math.abs(this.yvel)) / [10, 3, 0.2, 2][this.type];
actors[j].xvel += this.xvel / 8; actors[j].xvel += this.xvel / 8;
actors[j].yvel += this.yvel / 8; actors[j].yvel += this.yvel / 8;
actors[j].tookDamage = 40; actors[j].tookDamage = 40;
@ -845,6 +925,7 @@ function Box(x, y, w, h, xvel, yvel, colgroup, gravity, airRes){
}else if(lv[ycol - 1][xcol] == 'x'){ // If in lava }else if(lv[ycol - 1][xcol] == 'x'){ // If in lava
this.health -= 0.01 * speed; this.health -= 0.01 * speed;
this.inlava = true; this.inlava = true;
this.xvel *= Math.pow(0.997, speed); // Slow down velocity this.xvel *= Math.pow(0.997, speed); // Slow down velocity
this.yvel *= Math.pow(0.997, speed); this.yvel *= Math.pow(0.997, speed);
}else if(lv[ycol - 1][xcol] == 'w'){ // If in water }else if(lv[ycol - 1][xcol] == 'w'){ // If in water
@ -1009,7 +1090,7 @@ function drawLevel(lv){ // Draw level
} }
context.fillRect((j << 4) - r(lookx), i << 4, 16, 16); context.fillRect((j << 4) - r(lookx), i << 4, 16, 16);
}else if(lv[i][j] == 'E'){ }else if(lv[i][j] == 'E'){
actors[actors.length] = new Actor(Math.floor(Math.random() * lvDis[levelNo]) + 8, 'all', 100, 6, 50, 3, j << 4, i << 4, 16, 16); actors[actors.length] = new Actor(Math.floor(Math.random() * lvDis[levelNo]) + 8, 1, 100, 6, 50, 3, j << 4, i << 4, 16, 16);
ais[ais.length] = new Ai(actors.length - 1, 'alphaBot'); ais[ais.length] = new Ai(actors.length - 1, 'alphaBot');
level[i] = setStrChar(level[i], j, '.'); level[i] = setStrChar(level[i], j, '.');
}else if(lv[i][j] == 'H'){ }else if(lv[i][j] == 'H'){
@ -1049,13 +1130,14 @@ function loopGame(){
partFound = false; partFound = false;
if(partsInserted.length == 0){ if(partsInserted.length == 0){
var toInsert = levelparts[0]; var toInsert = levelparts[0];
partsInserted.push([false, '5n', 1, 1, 0]); partsInserted.push([false, '5n', 1, 1, 0, 0]);
partFound = true; partFound = true;
}else{ }else{
thisPart = levelparts[partIndex]; thisPart = levelparts[partIndex];
if(thisPart[20] == partsInserted[partsInserted.length - 1][1] && (Math.random() * thisPart[24]) < 1){ var prevPart = partsInserted[partsInserted.length - 1];
if(thisPart[20] == prevPart[1] && (Math.random() * thisPart[24]) < 1 && (prevPart[5] != partIndex || Math.random() <= 0.3)){
if(partsInserted[partsInserted.length - 1] != thisPart || Math.random() < 0){ if(partsInserted[partsInserted.length - 1] != thisPart || Math.random() < 0){
partsInserted.push([thisPart[20], thisPart[21], thisPart[22], thisPart[23], thisPart[24]]); partsInserted.push([thisPart[20], thisPart[21], thisPart[22], thisPart[23], thisPart[24], partIndex]);
toInsert = thisPart; toInsert = thisPart;
partFound = true; partFound = true;
} }
@ -1157,9 +1239,9 @@ function loopGame(){
if(mobile){ if(mobile){
context.fillText('RetX: ' + r(mouse.x), 420, 290); context.fillText('RetX: ' + r(mouse.x), 420, 290);
context.fillText('RetX: ' + r(mouse.y), 490, 290); context.fillText('RetX: ' + r(mouse.y), 490, 290);
context.fillText('Sint mobile version α 0.6.2', 490, 310); context.fillText('Sint mobile version α 0.6.3', 490, 310);
}else{ }else{
context.fillText('Sint version α 0.6.2', 490, 20); // β context.fillText('Sint version α 0.6.3', 490, 20); // β
if(cookies && game == 'menu'){ if(cookies && game == 'menu'){
context.fillText('Sint uses cookies to remember', 490, 290); context.fillText('Sint uses cookies to remember', 490, 290);
context.fillText('options and time trial records', 490, 310); context.fillText('options and time trial records', 490, 310);