[Pages] Make directory structure lowercase.

This commit is contained in:
RHY3756547 committed 2017-09-08 17:10:13 +01:00
1 parent 3b47a86756
commit 65ca7d7455
96 files changed
+20116

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
//
// controlDefault.js
//--------------------
// Provides default (keyboard) controls for kart. In future there will be an AI controller and default will support gamepad.
// by RHY3756547
//
// includes: main.js
//
window.controlDefault = function() {
var thisObj = this;
this.local = true;
var kart;
this.setKart = function(k) {
kart = k;
thisObj.kart = k;
}
this.fetchInput = fetchInput;
function fetchInput() {
return {
accel: keysArray[88], //x
decel: keysArray[90], //z
drift: keysArray[83], //s
item: keysArray[65], //a
//-1 to 1, intensity.
turn: (keysArray[37]?-1:0)+(keysArray[39]?1:0),
airTurn: (keysArray[40]?-1:0)+(keysArray[38]?1:0) //air excitebike turn, doesn't really have much function
};
}
}
+41
View File
@@ -0,0 +1,41 @@
//
// controlDefault.js
//--------------------
// Provides default (keyboard) controls for kart. In future there will be an AI controller and default will support gamepad.
// by RHY3756547
//
// includes: main.js
//
window.controlNetwork = function() {
var t = this;
var kart;
this.local = false;
this.turn = 0;
this.airTurn = 0;
this.binput = 0;
this.setKart = function(k) {
kart = k;
t.kart = k;
}
this.fetchInput = fetchInput;
function fetchInput() {
//local controllers generally just return input and handle items - the network controller restores kart data from the stream sent from the server. Obviously this data needs to be verified by the server...
return {
accel: t.binput&1, //x
decel: t.binput&2, //z
drift: t.binput&4, //s
item: false,//keysArray[65], //a
//-1 to 1, intensity.
turn: t.turn,//(keysArray[37]?-1:0)+(keysArray[39]?1:0),
airTurn: t.airTurn//(keysArray[40]?-1:0)+(keysArray[38]?1:0) //air excitebike turn, doesn't really have much function
};
}
}
+141
View File
@@ -0,0 +1,141 @@
//
// controlRaceCPU.js
//--------------------
// Provides AI control for default races
// by RHY3756547
//
// includes: main.js
//
window.controlRaceCPU = function(nkm) {
var thisObj = this;
var kart;
this.setKart = function(k) {
kart = k;
thisObj.kart = k;
calcDestNorm();
}
this.fetchInput = fetchInput;
var battleMode = (nkm.sections["EPAT"] == null);
var paths, points;
if (battleMode) { //MEEPO!!
var paths = nkm.sections["MEPA"].entries;
var points = nkm.sections["MEPO"].entries;
} else {
var paths = nkm.sections["EPAT"].entries;
var points = nkm.sections["EPOI"].entries;
}
var ePath = paths[0];
var ePoiInd = ePath.startInd;
var ePoi = points[ePath.startInd];
var posOffset = [0, 0, 0];
var destOff = [0, 0, 0];
var offTrans = 0;
chooseNewOff();
var destNorm;
var destConst;
var destPoint;
function fetchInput() {
//basically as a cpu, we're really dumb and need a constant supply of points to drive to.
//battle mode AI is a lot more complex, but since we're only going in one direction it can be kept simple.
var accel = true; //currently always driving forward. should change for sharp turns and when we get stuck on a wall
//(drive in direction of wall? we may need to reverse, "if stuck for too long we can just call lakitu and the players won't even notice" - Nintendo)
var dist = vec3.dot(destNorm, kart.pos) + destConst;
if (dist < ePoi.pointSize) advancePoint();
destPoint = vec3.add([], ePoi.pos, vec3.scale([], vec3.lerp([], posOffset, destOff, offTrans), ePoi.pointSize));
var dirToPt = Math.atan2(destPoint[0]-kart.pos[0], kart.pos[2]-destPoint[2]);
var diff = dirDiff(dirToPt, kart.physicalDir);
var turn = Math.min(Math.max(-1, (diff*3)), 1);
offTrans += 1/240;
if (offTrans >= 1) chooseNewOff();
return {
accel: accel, //x
decel: false, //z
drift: false, //s
item: false, //a
//-1 to 1, intensity.
turn: turn,
airTurn: 0 //air excitebike turn, doesn't really have much function
};
}
function chooseNewOff() {
posOffset = destOff;
var ang = Math.random()*Math.PI*2;
var strength = Math.random();
destOff = [Math.sin(ang)*strength, 0, Math.cos(ang)*strength];
offTrans = 0;
}
function calcDestNorm() {
var norm = vec3.sub([], kart.pos, ePoi.pos);
vec3.normalize(norm, norm);
destNorm = norm;
destConst = -vec3.dot(ePoi.pos, norm)
}
function advancePoint() {
if (++ePoiInd < ePath.startInd+ePath.pathLen) {
//next within this path
ePoi = points[ePoiInd];
} else {
//advance to one of next possible paths
if (battleMode) {
var pathInd = ((Math.random()>0.5 && ePath.source.length>0)?ePath.source:ePath.dest)[Math.floor(Math.random()*ePath.dest.length)];
ePoiInd = pathInd;
ePoi = points[ePoiInd];
recomputePath();
} else {
var pathInd = ePath.dest[Math.floor(Math.random()*ePath.dest.length)];
ePath = paths[pathInd];
ePoi = points[ePath.startInd];
ePoiInd = ePath.startInd;
}
}
calcDestNorm();
}
function recomputePath() { //use if point is set by anything but the path system, eg. respawn
for (var i=0; i<paths.length; i++) {
var rel = (ePoiInd-paths[i].startInd);
if (rel >= 0 && rel < paths[i].pathLen) {
ePath = paths[i];
}
}
}
function fixDir(dir) {
return posMod(dir, Math.PI*2);
}
function dirDiff(dir1, dir2) {
var d = fixDir(dir1-dir2);
return (d>Math.PI)?(-2*Math.PI+d):d;
}
function posMod(i, n) {
return (i % n + n) % n;
}
}