mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-03 06:33:42 +00:00
timer colors and frictions
This commit is contained in:
parent
d48c3aabdf
commit
56fcf3706e
5 changed files with 117 additions and 68 deletions
BIN
data/ui/game/transparency-fps.png
Normal file
BIN
data/ui/game/transparency-fps.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 255 B |
BIN
data/ui/game/transparency.png
Normal file
BIN
data/ui/game/transparency.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3 KiB |
|
|
@ -67,7 +67,11 @@ typedef VertexBucket = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class DifBuilder {
|
class DifBuilder {
|
||||||
static var materialDict = [
|
static var materialDict:Map<String, {
|
||||||
|
friction:Float,
|
||||||
|
restitution:Float,
|
||||||
|
?force:Float
|
||||||
|
}> = [
|
||||||
"friction_none" => {
|
"friction_none" => {
|
||||||
friction: 0.01,
|
friction: 0.01,
|
||||||
restitution: 0.5
|
restitution: 0.5
|
||||||
|
|
@ -95,8 +99,73 @@ class DifBuilder {
|
||||||
"ice.slick" => {
|
"ice.slick" => {
|
||||||
friction: 0.05,
|
friction: 0.05,
|
||||||
restitution: 0.5
|
restitution: 0.5
|
||||||
|
},
|
||||||
|
"grass" => {
|
||||||
|
friction: 1.5,
|
||||||
|
restitution: 0.35
|
||||||
|
},
|
||||||
|
"ice1" => {
|
||||||
|
friction: 0.03,
|
||||||
|
restitution: 0.95
|
||||||
|
},
|
||||||
|
"rug" => {
|
||||||
|
friction: 6.0,
|
||||||
|
restitution: 0.5,
|
||||||
|
},
|
||||||
|
"tarmac" => {
|
||||||
|
friction: 0.35,
|
||||||
|
restitution: 0.7
|
||||||
|
},
|
||||||
|
"carpet" => {
|
||||||
|
friction: 6.0,
|
||||||
|
restitution: 0.5
|
||||||
|
},
|
||||||
|
"sand" => {
|
||||||
|
friction: 4.0,
|
||||||
|
restitution: 0.1
|
||||||
|
},
|
||||||
|
"water" => {
|
||||||
|
friction: 6.0,
|
||||||
|
restitution: 0.0,
|
||||||
|
},
|
||||||
|
"floor_bounce" => {
|
||||||
|
friction: 0.2,
|
||||||
|
restitution: 0.0,
|
||||||
|
force: 15
|
||||||
|
},
|
||||||
|
"mbp_chevron_friction" => {
|
||||||
|
friction: -1.0,
|
||||||
|
restitution: 1.0
|
||||||
|
},
|
||||||
|
"mbp_chevron_friction2" => {
|
||||||
|
friction: -1.0,
|
||||||
|
restitution: 1.0
|
||||||
|
},
|
||||||
|
"mbp_chevron_friction3" => {
|
||||||
|
friction: -1.0,
|
||||||
|
restitution: 1.0
|
||||||
|
},
|
||||||
|
"mmg_grass" => {
|
||||||
|
friction: 0.9,
|
||||||
|
restitution: 0.5
|
||||||
|
},
|
||||||
|
"mmg_sand" => {
|
||||||
|
friction: 6.0,
|
||||||
|
restitution: 0.1
|
||||||
|
},
|
||||||
|
"mmg_water" => {
|
||||||
|
friction: 6.0,
|
||||||
|
restitution: 0.0
|
||||||
|
},
|
||||||
|
"mmg_ice" => {
|
||||||
|
friction: 0.03,
|
||||||
|
restitution: 0.95
|
||||||
|
},
|
||||||
|
"mmg_ice_shadow" => {
|
||||||
|
friction: 0.03,
|
||||||
|
restitution: 0.95
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function loadDif(path:String, itr:InteriorObject, onFinish:Void->Void, ?so:Int = -1) {
|
public static function loadDif(path:String, itr:InteriorObject, onFinish:Void->Void, ?so:Int = -1) {
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
|
|
@ -106,16 +175,11 @@ class DifBuilder {
|
||||||
var difresource = ResourceLoader.loadInterior(path);
|
var difresource = ResourceLoader.loadInterior(path);
|
||||||
difresource.acquire();
|
difresource.acquire();
|
||||||
var dif = difresource.resource;
|
var dif = difresource.resource;
|
||||||
|
|
||||||
var geo = so == -1 ? dif.interiors[0] : dif.subObjects[so];
|
var geo = so == -1 ? dif.interiors[0] : dif.subObjects[so];
|
||||||
|
|
||||||
var hulls = geo.convexHulls;
|
var hulls = geo.convexHulls;
|
||||||
|
|
||||||
var triangles = [];
|
var triangles = [];
|
||||||
var textures = [];
|
var textures = [];
|
||||||
|
|
||||||
var collider = new CollisionEntity(itr);
|
var collider = new CollisionEntity(itr);
|
||||||
|
|
||||||
function stripTexName(tex:String) {
|
function stripTexName(tex:String) {
|
||||||
var dotpos = tex.lastIndexOf(".");
|
var dotpos = tex.lastIndexOf(".");
|
||||||
var slashpos = tex.lastIndexOf("/") + 1;
|
var slashpos = tex.lastIndexOf("/") + 1;
|
||||||
|
|
@ -127,39 +191,29 @@ class DifBuilder {
|
||||||
}
|
}
|
||||||
return tex.substring(slashpos, dotpos);
|
return tex.substring(slashpos, dotpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
var vertexBuckets = new Map<Point3F, Array<VertexBucket>>();
|
var vertexBuckets = new Map<Point3F, Array<VertexBucket>>();
|
||||||
|
|
||||||
var edges = [];
|
var edges = [];
|
||||||
var colliderSurfaces = [];
|
var colliderSurfaces = [];
|
||||||
|
|
||||||
for (i in 0...hulls.length) {
|
for (i in 0...hulls.length) {
|
||||||
var hullTris = [];
|
var hullTris = [];
|
||||||
var hull = hulls[i];
|
var hull = hulls[i];
|
||||||
|
|
||||||
for (j in hull.surfaceStart...(hull.surfaceStart + hull.surfaceCount)) {
|
for (j in hull.surfaceStart...(hull.surfaceStart + hull.surfaceCount)) {
|
||||||
var surfaceindex = geo.hullSurfaceIndices[j];
|
var surfaceindex = geo.hullSurfaceIndices[j];
|
||||||
var surface = geo.surfaces[surfaceindex];
|
var surface = geo.surfaces[surfaceindex];
|
||||||
if (surface == null)
|
if (surface == null)
|
||||||
continue;
|
continue;
|
||||||
var planeindex = surface.planeIndex;
|
var planeindex = surface.planeIndex;
|
||||||
|
|
||||||
var planeFlipped = (planeindex & 0x8000) == 0x8000;
|
var planeFlipped = (planeindex & 0x8000) == 0x8000;
|
||||||
if (planeFlipped)
|
if (planeFlipped)
|
||||||
planeindex &= ~0x8000;
|
planeindex &= ~0x8000;
|
||||||
|
|
||||||
var plane = geo.planes[planeindex];
|
var plane = geo.planes[planeindex];
|
||||||
var normal = geo.normals[plane.normalIndex];
|
var normal = geo.normals[plane.normalIndex];
|
||||||
|
|
||||||
if (planeFlipped)
|
if (planeFlipped)
|
||||||
normal = normal.scalar(-1);
|
normal = normal.scalar(-1);
|
||||||
|
|
||||||
var texture = geo.materialList[surface.textureIndex];
|
var texture = geo.materialList[surface.textureIndex];
|
||||||
if (!textures.contains(texture))
|
if (!textures.contains(texture))
|
||||||
textures.push(texture);
|
textures.push(texture);
|
||||||
|
|
||||||
var points = geo.points;
|
var points = geo.points;
|
||||||
|
|
||||||
var colliderSurface = new CollisionSurface();
|
var colliderSurface = new CollisionSurface();
|
||||||
colliderSurface.points = [];
|
colliderSurface.points = [];
|
||||||
colliderSurface.normals = [];
|
colliderSurface.normals = [];
|
||||||
|
|
@ -168,7 +222,6 @@ class DifBuilder {
|
||||||
colliderSurface.edgeDots = [];
|
colliderSurface.edgeDots = [];
|
||||||
colliderSurface.originalIndices = [];
|
colliderSurface.originalIndices = [];
|
||||||
colliderSurface.originalSurfaceIndex = surfaceindex;
|
colliderSurface.originalSurfaceIndex = surfaceindex;
|
||||||
|
|
||||||
for (k in (surface.windingStart + 2)...(surface.windingStart + surface.windingCount)) {
|
for (k in (surface.windingStart + 2)...(surface.windingStart + surface.windingCount)) {
|
||||||
var p1, p2, p3;
|
var p1, p2, p3;
|
||||||
if ((k - (surface.windingStart + 2)) % 2 == 0) {
|
if ((k - (surface.windingStart + 2)) % 2 == 0) {
|
||||||
|
|
@ -186,17 +239,13 @@ class DifBuilder {
|
||||||
colliderSurface.originalIndices.push(geo.windings[k - 1]);
|
colliderSurface.originalIndices.push(geo.windings[k - 1]);
|
||||||
colliderSurface.originalIndices.push(geo.windings[k]);
|
colliderSurface.originalIndices.push(geo.windings[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var e1 = new TriangleEdge(geo.windings[k], geo.windings[k - 1], surfaceindex);
|
var e1 = new TriangleEdge(geo.windings[k], geo.windings[k - 1], surfaceindex);
|
||||||
var e2 = new TriangleEdge(geo.windings[k - 1], geo.windings[k - 2], surfaceindex);
|
var e2 = new TriangleEdge(geo.windings[k - 1], geo.windings[k - 2], surfaceindex);
|
||||||
var e3 = new TriangleEdge(geo.windings[k], geo.windings[k - 2], surfaceindex);
|
var e3 = new TriangleEdge(geo.windings[k], geo.windings[k - 2], surfaceindex);
|
||||||
|
|
||||||
edges.push(e1);
|
edges.push(e1);
|
||||||
edges.push(e2);
|
edges.push(e2);
|
||||||
edges.push(e3);
|
edges.push(e3);
|
||||||
|
|
||||||
var texgen = geo.texGenEQs[surface.texGenIndex];
|
var texgen = geo.texGenEQs[surface.texGenIndex];
|
||||||
|
|
||||||
var uv1 = new Point2F(p1.x * texgen.planeX.x
|
var uv1 = new Point2F(p1.x * texgen.planeX.x
|
||||||
+ p1.y * texgen.planeX.y
|
+ p1.y * texgen.planeX.y
|
||||||
+ p1.z * texgen.planeX.z
|
+ p1.z * texgen.planeX.z
|
||||||
|
|
@ -221,7 +270,6 @@ class DifBuilder {
|
||||||
+ p3.y * texgen.planeY.y
|
+ p3.y * texgen.planeY.y
|
||||||
+ p3.z * texgen.planeY.z
|
+ p3.z * texgen.planeY.z
|
||||||
+ texgen.planeY.d);
|
+ texgen.planeY.d);
|
||||||
|
|
||||||
var tri = new DifBuilderTriangle();
|
var tri = new DifBuilderTriangle();
|
||||||
tri.texture = texture;
|
tri.texture = texture;
|
||||||
tri.normal1 = normal;
|
tri.normal1 = normal;
|
||||||
|
|
@ -241,6 +289,7 @@ class DifBuilder {
|
||||||
var minfo = materialDict.get(materialName);
|
var minfo = materialDict.get(materialName);
|
||||||
colliderSurface.friction = minfo.friction;
|
colliderSurface.friction = minfo.friction;
|
||||||
colliderSurface.restitution = minfo.restitution;
|
colliderSurface.restitution = minfo.restitution;
|
||||||
|
colliderSurface.force = minfo.force != null ? minfo.force : 0;
|
||||||
}
|
}
|
||||||
colliderSurface.points.push(new Vector(-p1.x, p1.y, p1.z));
|
colliderSurface.points.push(new Vector(-p1.x, p1.y, p1.z));
|
||||||
colliderSurface.points.push(new Vector(-p2.x, p2.y, p2.z));
|
colliderSurface.points.push(new Vector(-p2.x, p2.y, p2.z));
|
||||||
|
|
@ -251,14 +300,12 @@ class DifBuilder {
|
||||||
colliderSurface.indices.push(colliderSurface.indices.length);
|
colliderSurface.indices.push(colliderSurface.indices.length);
|
||||||
colliderSurface.indices.push(colliderSurface.indices.length);
|
colliderSurface.indices.push(colliderSurface.indices.length);
|
||||||
colliderSurface.indices.push(colliderSurface.indices.length);
|
colliderSurface.indices.push(colliderSurface.indices.length);
|
||||||
|
|
||||||
for (v in [p1, p2, p3]) {
|
for (v in [p1, p2, p3]) {
|
||||||
var buckets = vertexBuckets.get(v);
|
var buckets = vertexBuckets.get(v);
|
||||||
if (buckets == null) {
|
if (buckets == null) {
|
||||||
buckets = [];
|
buckets = [];
|
||||||
vertexBuckets.set(v, buckets);
|
vertexBuckets.set(v, buckets);
|
||||||
}
|
}
|
||||||
|
|
||||||
var bucket:VertexBucket = null;
|
var bucket:VertexBucket = null;
|
||||||
for (j in 0...buckets.length) {
|
for (j in 0...buckets.length) {
|
||||||
bucket = buckets[j];
|
bucket = buckets[j];
|
||||||
|
|
@ -274,29 +321,22 @@ class DifBuilder {
|
||||||
};
|
};
|
||||||
buckets.push(bucket);
|
buckets.push(bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket.triangleIndices.push(triangles.length - 1);
|
bucket.triangleIndices.push(triangles.length - 1);
|
||||||
bucket.normals.push(normal);
|
bucket.normals.push(normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
colliderSurface.generateBoundingBox();
|
colliderSurface.generateBoundingBox();
|
||||||
collider.addSurface(colliderSurface);
|
collider.addSurface(colliderSurface);
|
||||||
colliderSurfaces.push(colliderSurface);
|
colliderSurfaces.push(colliderSurface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var edgeMap:Map<Int, TriangleEdge> = new Map();
|
var edgeMap:Map<Int, TriangleEdge> = new Map();
|
||||||
var internalEdges:Map<Int, Bool> = new Map();
|
var internalEdges:Map<Int, Bool> = new Map();
|
||||||
|
|
||||||
var difEdges:Map<Int, Edge> = [];
|
var difEdges:Map<Int, Edge> = [];
|
||||||
|
|
||||||
for (edge in edges) {
|
for (edge in edges) {
|
||||||
var edgeHash = edge.index1 >= edge.index2 ? edge.index1 * edge.index1 + edge.index1 + edge.index2 : edge.index1 + edge.index2 * edge.index2;
|
var edgeHash = edge.index1 >= edge.index2 ? edge.index1 * edge.index1 + edge.index1 + edge.index2 : edge.index1 + edge.index2 * edge.index2;
|
||||||
|
|
||||||
if (internalEdges.exists(edgeHash))
|
if (internalEdges.exists(edgeHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (edgeMap.exists(edgeHash)) {
|
if (edgeMap.exists(edgeHash)) {
|
||||||
if (edgeMap[edgeHash].surfaceIndex == edge.surfaceIndex) {
|
if (edgeMap[edgeHash].surfaceIndex == edge.surfaceIndex) {
|
||||||
// Internal edge
|
// Internal edge
|
||||||
|
|
@ -311,11 +351,9 @@ class DifBuilder {
|
||||||
edgeMap.set(edgeHash, edge);
|
edgeMap.set(edgeHash, edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hashEdge(i1:Int, i2:Int) {
|
function hashEdge(i1:Int, i2:Int) {
|
||||||
return i1 >= i2 ? i1 * i1 + i1 + i2 : i1 + i2 * i2;
|
return i1 >= i2 ? i1 * i1 + i1 + i2 : i1 + i2 * i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEdgeDot(edge:Edge) {
|
function getEdgeDot(edge:Edge) {
|
||||||
var edgeSurface0 = edge.surfaceIndex0;
|
var edgeSurface0 = edge.surfaceIndex0;
|
||||||
var surface0 = geo.surfaces[edgeSurface0];
|
var surface0 = geo.surfaces[edgeSurface0];
|
||||||
|
|
@ -351,7 +389,6 @@ class DifBuilder {
|
||||||
|
|
||||||
return dot;
|
return dot;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEdgeNormal(edge:Edge) {
|
function getEdgeNormal(edge:Edge) {
|
||||||
var edgeSurface0 = edge.surfaceIndex0;
|
var edgeSurface0 = edge.surfaceIndex0;
|
||||||
var surface0 = geo.surfaces[edgeSurface0];
|
var surface0 = geo.surfaces[edgeSurface0];
|
||||||
|
|
@ -389,14 +426,12 @@ class DifBuilder {
|
||||||
|
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (colliderSurface in colliderSurfaces) {
|
for (colliderSurface in colliderSurfaces) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (i < colliderSurface.indices.length) {
|
while (i < colliderSurface.indices.length) {
|
||||||
var e1e2 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 1]);
|
var e1e2 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 1]);
|
||||||
var e2e3 = hashEdge(colliderSurface.originalIndices[i + 1], colliderSurface.originalIndices[i + 2]);
|
var e2e3 = hashEdge(colliderSurface.originalIndices[i + 1], colliderSurface.originalIndices[i + 2]);
|
||||||
var e1e3 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 2]);
|
var e1e3 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 2]);
|
||||||
|
|
||||||
var edgeData = 0;
|
var edgeData = 0;
|
||||||
if (difEdges.exists(e1e2)) {
|
if (difEdges.exists(e1e2)) {
|
||||||
if (getEdgeDot(difEdges[e1e2]) < Math.cos(Math.PI / 12)) {
|
if (getEdgeDot(difEdges[e1e2]) < Math.cos(Math.PI / 12)) {
|
||||||
|
|
@ -430,21 +465,17 @@ class DifBuilder {
|
||||||
colliderSurface.edgeDots.push(0);
|
colliderSurface.edgeDots.push(0);
|
||||||
// colliderSurface.edgeNormals.push(new Vector(0, 0, 0));
|
// colliderSurface.edgeNormals.push(new Vector(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
colliderSurface.edgeData.push(edgeData);
|
colliderSurface.edgeData.push(edgeData);
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (vtex => buckets in vertexBuckets) {
|
for (vtex => buckets in vertexBuckets) {
|
||||||
for (i in 0...buckets.length) {
|
for (i in 0...buckets.length) {
|
||||||
var bucket = buckets[i];
|
var bucket = buckets[i];
|
||||||
var avgNormal = new Point3F();
|
var avgNormal = new Point3F();
|
||||||
|
|
||||||
for (normal in bucket.normals)
|
for (normal in bucket.normals)
|
||||||
avgNormal = avgNormal.add(normal);
|
avgNormal = avgNormal.add(normal);
|
||||||
avgNormal = avgNormal.scalarDiv(bucket.normals.length);
|
avgNormal = avgNormal.scalarDiv(bucket.normals.length);
|
||||||
|
|
||||||
for (j in 0...bucket.triangleIndices.length) {
|
for (j in 0...bucket.triangleIndices.length) {
|
||||||
var index = bucket.triangleIndices[j];
|
var index = bucket.triangleIndices[j];
|
||||||
var tri = triangles[index];
|
var tri = triangles[index];
|
||||||
|
|
@ -457,9 +488,7 @@ class DifBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mats = new Map<String, Array<DifBuilderTriangle>>();
|
var mats = new Map<String, Array<DifBuilderTriangle>>();
|
||||||
|
|
||||||
for (index => value in triangles) {
|
for (index => value in triangles) {
|
||||||
if (mats.exists(value.texture)) {
|
if (mats.exists(value.texture)) {
|
||||||
mats[value.texture].push(value);
|
mats[value.texture].push(value);
|
||||||
|
|
@ -467,11 +496,9 @@ class DifBuilder {
|
||||||
mats.set(value.texture, [value]);
|
mats.set(value.texture, [value]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
collider.difEdgeMap = difEdges;
|
collider.difEdgeMap = difEdges;
|
||||||
collider.finalize();
|
collider.finalize();
|
||||||
itr.collider = collider;
|
itr.collider = collider;
|
||||||
|
|
||||||
function canFindTex(tex:String) {
|
function canFindTex(tex:String) {
|
||||||
if (["NULL"].contains(tex)) {
|
if (["NULL"].contains(tex)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -501,7 +528,6 @@ class DifBuilder {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tex(tex:String):String {
|
function tex(tex:String):String {
|
||||||
if (tex.indexOf('/') != -1) {
|
if (tex.indexOf('/') != -1) {
|
||||||
tex = tex.split('/')[1];
|
tex = tex.split('/')[1];
|
||||||
|
|
@ -525,20 +551,17 @@ class DifBuilder {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var loadtexs = [];
|
var loadtexs = [];
|
||||||
for (grp => tris in mats) {
|
for (grp => tris in mats) {
|
||||||
if (canFindTex(grp)) {
|
if (canFindTex(grp)) {
|
||||||
loadtexs.push(tex(grp));
|
loadtexs.push(tex(grp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var worker = new ResourceLoaderWorker(() -> {
|
var worker = new ResourceLoaderWorker(() -> {
|
||||||
for (grp => tris in mats) {
|
for (grp => tris in mats) {
|
||||||
var points = [];
|
var points = [];
|
||||||
var normals = [];
|
var normals = [];
|
||||||
var uvs = [];
|
var uvs = [];
|
||||||
|
|
||||||
for (tri in tris) {
|
for (tri in tris) {
|
||||||
var p1 = new Point(-tri.p1.x, tri.p1.y, tri.p1.z);
|
var p1 = new Point(-tri.p1.x, tri.p1.y, tri.p1.z);
|
||||||
var p2 = new Point(-tri.p2.x, tri.p2.y, tri.p2.z);
|
var p2 = new Point(-tri.p2.x, tri.p2.y, tri.p2.z);
|
||||||
|
|
@ -559,11 +582,9 @@ class DifBuilder {
|
||||||
uvs.push(uv2);
|
uvs.push(uv2);
|
||||||
uvs.push(uv1);
|
uvs.push(uv1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var prim = new Polygon(points);
|
var prim = new Polygon(points);
|
||||||
prim.uvs = uvs;
|
prim.uvs = uvs;
|
||||||
prim.normals = normals;
|
prim.normals = normals;
|
||||||
|
|
||||||
var material:Material;
|
var material:Material;
|
||||||
var texture:Texture;
|
var texture:Texture;
|
||||||
if (canFindTex(grp)) {
|
if (canFindTex(grp)) {
|
||||||
|
|
@ -578,10 +599,8 @@ class DifBuilder {
|
||||||
material.receiveShadows = true;
|
material.receiveShadows = true;
|
||||||
// material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
// material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
||||||
// material.mainPass.wireframe = true;
|
// material.mainPass.wireframe = true;
|
||||||
|
|
||||||
var mesh = new Mesh(prim, material, itr);
|
var mesh = new Mesh(prim, material, itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
difresource.release();
|
difresource.release();
|
||||||
onFinish();
|
onFinish();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -953,12 +953,14 @@ class MarbleWorld extends Scheduler {
|
||||||
|
|
||||||
public function updateTimer(dt:Float) {
|
public function updateTimer(dt:Float) {
|
||||||
this.timeState.dt = dt;
|
this.timeState.dt = dt;
|
||||||
|
var timerColor = 1;
|
||||||
if (!this.isWatching) {
|
if (!this.isWatching) {
|
||||||
if (this.bonusTime != 0 && this.timeState.currentAttemptTime >= 3.5) {
|
if (this.bonusTime != 0 && this.timeState.currentAttemptTime >= 3.5) {
|
||||||
this.bonusTime -= dt;
|
this.bonusTime -= dt;
|
||||||
if (this.bonusTime < 0) {
|
if (this.bonusTime < 0) {
|
||||||
this.timeState.gameplayClock -= this.bonusTime;
|
this.timeState.gameplayClock -= this.bonusTime;
|
||||||
this.bonusTime = 0;
|
this.bonusTime = 0;
|
||||||
|
timerColor = 0;
|
||||||
}
|
}
|
||||||
if (timeTravelSound == null) {
|
if (timeTravelSound == null) {
|
||||||
var ttsnd = ResourceLoader.getResource("data/sound/timetravelactive.wav", ResourceLoader.getAudio, this.soundResources);
|
var ttsnd = ResourceLoader.getResource("data/sound/timetravelactive.wav", ResourceLoader.getAudio, this.soundResources);
|
||||||
|
|
@ -969,10 +971,12 @@ class MarbleWorld extends Scheduler {
|
||||||
timeTravelSound.stop();
|
timeTravelSound.stop();
|
||||||
timeTravelSound = null;
|
timeTravelSound = null;
|
||||||
}
|
}
|
||||||
if (this.timeState.currentAttemptTime >= 3.5)
|
if (this.timeState.currentAttemptTime >= 3.5) {
|
||||||
this.timeState.gameplayClock += dt;
|
this.timeState.gameplayClock += dt;
|
||||||
else if (this.timeState.currentAttemptTime + dt >= 3.5) {
|
timerColor = 0;
|
||||||
|
} else if (this.timeState.currentAttemptTime + dt >= 3.5) {
|
||||||
this.timeState.gameplayClock += (this.timeState.currentAttemptTime + dt) - 3.5;
|
this.timeState.gameplayClock += (this.timeState.currentAttemptTime + dt) - 3.5;
|
||||||
|
timerColor = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.timeState.currentAttemptTime += dt;
|
this.timeState.currentAttemptTime += dt;
|
||||||
|
|
@ -995,7 +999,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.timeState.timeSinceLoad += dt;
|
this.timeState.timeSinceLoad += dt;
|
||||||
if (finishTime != null)
|
if (finishTime != null)
|
||||||
this.timeState.gameplayClock = finishTime.gameplayClock;
|
this.timeState.gameplayClock = finishTime.gameplayClock;
|
||||||
playGui.formatTimer(this.timeState.gameplayClock);
|
playGui.formatTimer(this.timeState.gameplayClock, timerColor);
|
||||||
|
|
||||||
if (!this.isWatching && this.isRecording)
|
if (!this.isWatching && this.isRecording)
|
||||||
this.replay.recordTimeState(timeState.currentAttemptTime, timeState.gameplayClock, this.bonusTime);
|
this.replay.recordTimeState(timeState.currentAttemptTime, timeState.gameplayClock, this.bonusTime);
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ class PlayGui {
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
var timerNumbers:Array<GuiAnim> = [];
|
var timerNumbers:Array<GuiAnim> = [];
|
||||||
var timerPoint:GuiImage;
|
var timerPoint:GuiAnim;
|
||||||
var timerColon:GuiImage;
|
var timerColon:GuiAnim;
|
||||||
|
|
||||||
var gemCountNumbers:Array<GuiAnim> = [];
|
var gemCountNumbers:Array<GuiAnim> = [];
|
||||||
var gemCountSlash:GuiImage;
|
var gemCountSlash:GuiImage;
|
||||||
|
|
@ -108,6 +108,14 @@ class PlayGui {
|
||||||
var tile = ResourceLoader.getResource('data/ui/game/numbers/${i}.png', ResourceLoader.getImage, this.imageResources).toTile();
|
var tile = ResourceLoader.getResource('data/ui/game/numbers/${i}.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
numberTiles.push(tile);
|
numberTiles.push(tile);
|
||||||
}
|
}
|
||||||
|
for (i in 0...10) {
|
||||||
|
var tile = ResourceLoader.getResource('data/ui/game/numbers/${i}_green.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
|
numberTiles.push(tile);
|
||||||
|
}
|
||||||
|
for (i in 0...10) {
|
||||||
|
var tile = ResourceLoader.getResource('data/ui/game/numbers/${i}_red.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
|
numberTiles.push(tile);
|
||||||
|
}
|
||||||
|
|
||||||
for (i in 0...7) {
|
for (i in 0...7) {
|
||||||
timerNumbers.push(new GuiAnim(numberTiles));
|
timerNumbers.push(new GuiAnim(numberTiles));
|
||||||
|
|
@ -164,7 +172,13 @@ class PlayGui {
|
||||||
timerNumbers[1].position = new Vector(47, 0);
|
timerNumbers[1].position = new Vector(47, 0);
|
||||||
timerNumbers[1].extent = new Vector(43, 55);
|
timerNumbers[1].extent = new Vector(43, 55);
|
||||||
|
|
||||||
timerColon = new GuiImage(ResourceLoader.getResource('data/ui/game/numbers/colon.png', ResourceLoader.getImage, this.imageResources).toTile());
|
var colonCols = [
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/colon.png', ResourceLoader.getImage, this.imageResources).toTile(),
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/colon_green.png', ResourceLoader.getImage, this.imageResources).toTile(),
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/colon_red.png', ResourceLoader.getImage, this.imageResources).toTile()
|
||||||
|
];
|
||||||
|
|
||||||
|
timerColon = new GuiAnim(colonCols);
|
||||||
timerColon.position = new Vector(67, 0);
|
timerColon.position = new Vector(67, 0);
|
||||||
timerColon.extent = new Vector(43, 55);
|
timerColon.extent = new Vector(43, 55);
|
||||||
|
|
||||||
|
|
@ -174,7 +188,13 @@ class PlayGui {
|
||||||
timerNumbers[3].position = new Vector(107, 0);
|
timerNumbers[3].position = new Vector(107, 0);
|
||||||
timerNumbers[3].extent = new Vector(43, 55);
|
timerNumbers[3].extent = new Vector(43, 55);
|
||||||
|
|
||||||
timerPoint = new GuiImage(ResourceLoader.getResource('data/ui/game/numbers/point.png', ResourceLoader.getImage, this.imageResources).toTile());
|
var pointCols = [
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/point.png', ResourceLoader.getImage, this.imageResources).toTile(),
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/point_green.png', ResourceLoader.getImage, this.imageResources).toTile(),
|
||||||
|
ResourceLoader.getResource('data/ui/game/numbers/point_red.png', ResourceLoader.getImage, this.imageResources).toTile()
|
||||||
|
];
|
||||||
|
|
||||||
|
timerPoint = new GuiAnim(pointCols);
|
||||||
timerPoint.position = new Vector(127, 0);
|
timerPoint.position = new Vector(127, 0);
|
||||||
timerPoint.extent = new Vector(43, 55);
|
timerPoint.extent = new Vector(43, 55);
|
||||||
|
|
||||||
|
|
@ -465,7 +485,10 @@ class PlayGui {
|
||||||
gemCountNumbers[3].anim.currentFrame = totalOnes;
|
gemCountNumbers[3].anim.currentFrame = totalOnes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTimer(time:Float) {
|
// 0: default
|
||||||
|
// 1: green
|
||||||
|
// 2: red
|
||||||
|
public function formatTimer(time:Float, color:Int = 0) {
|
||||||
var et = time * 1000;
|
var et = time * 1000;
|
||||||
var thousandth = et % 10;
|
var thousandth = et % 10;
|
||||||
var hundredth = Math.floor((et % 1000) / 10);
|
var hundredth = Math.floor((et % 1000) / 10);
|
||||||
|
|
@ -480,13 +503,16 @@ class PlayGui {
|
||||||
var hundredthOne = hundredth % 10;
|
var hundredthOne = hundredth % 10;
|
||||||
var hundredthTen = (hundredth - hundredthOne) / 10;
|
var hundredthTen = (hundredth - hundredthOne) / 10;
|
||||||
|
|
||||||
timerNumbers[0].anim.currentFrame = minutesTen;
|
timerNumbers[0].anim.currentFrame = minutesTen + color * 10;
|
||||||
timerNumbers[1].anim.currentFrame = minutesOne;
|
timerNumbers[1].anim.currentFrame = minutesOne + color * 10;
|
||||||
timerNumbers[2].anim.currentFrame = secondsTen;
|
timerNumbers[2].anim.currentFrame = secondsTen + color * 10;
|
||||||
timerNumbers[3].anim.currentFrame = secondsOne;
|
timerNumbers[3].anim.currentFrame = secondsOne + color * 10;
|
||||||
timerNumbers[4].anim.currentFrame = hundredthTen;
|
timerNumbers[4].anim.currentFrame = hundredthTen + color * 10;
|
||||||
timerNumbers[5].anim.currentFrame = hundredthOne;
|
timerNumbers[5].anim.currentFrame = hundredthOne + color * 10;
|
||||||
timerNumbers[6].anim.currentFrame = thousandth;
|
timerNumbers[6].anim.currentFrame = thousandth + color * 10;
|
||||||
|
|
||||||
|
timerPoint.anim.currentFrame = color;
|
||||||
|
timerColon.anim.currentFrame = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(engine:h3d.Engine) {
|
public function render(engine:h3d.Engine) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue