Skip to content

Commit

Permalink
Issue #98 Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hal255 committed Dec 1, 2018
2 parents 8a9be0c + 9bb228d commit a2174dd
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 38 deletions.
Binary file added LTC_game_jam.zip
Binary file not shown.
Binary file added client/assets/img/Title_Image_For_Git.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 24 additions & 19 deletions client/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ const config = {
quarter: {}
}
},
neutralMap:{
//velocity: 120,
//mapsCount: 2,
xRegion: 0.5,
zOrder: -1,
imgKey: "neutralMap",
imgSrc: "assets/img/floorBgAsset.png"
},
gameOverState: {
gameOverLabel: {
xRegion: 0.5,
Expand Down Expand Up @@ -147,12 +139,12 @@ const config = {
}
}
};
//Settings should be initated 1st out of all defaults
//Settings should be initiated 1st out of all defaults
config.default.settings = {
tileHeight: 58,
tileWidth: 74,
wrapOffset: -1,
mapVelocity: 10,
mapVelocity: 50,
maxMapVelocity: 150,
difficultyInterval: 10000, //10 seconds
difficulty: "easy"
Expand Down Expand Up @@ -185,11 +177,11 @@ config.default.particles = {
}

config.default.blocks = {
full: {
score: 25,
src: "assets/img/fullBlock.png",
key: "fullBlock"
},
full: {
score: 25,
src: "assets/img/fullBlock.png",
key: "fullBlock"
},
half: {
score: 50,
src: "assets/img/halfBlock.png",
Expand All @@ -200,7 +192,7 @@ config.default.blocks = {
src: "assets/img/quarterBlock.png",
key: "quarterBlock"
}
}
};

config.default.score = {
amount: 0,
Expand Down Expand Up @@ -276,8 +268,7 @@ config.default.debug = {
};

config.default.neutralMap = {
mapsCount: 2,
mapScale : 0,
xRegion: 0.5,
key: "neutralMap",
src: "assets/img/floorBgAsset.png"
};
Expand Down Expand Up @@ -346,6 +337,21 @@ config.default.colors = {
}
};

config.default.colorPickup = {
colorOptions: [
config.default.colors.red,
config.default.colors.yellow,
config.default.colors.blue
],
pickupScore: 0,
tilesBetweenSpawns: {
min: 25,
max: 100
},
src: "assets/img/pickUpAsset.png",
key: "colorPickup"
};

config.default.colorStates = {
activeColors: ["color1", "color2"],
spawnedPickups: [],
Expand All @@ -372,4 +378,3 @@ config.default.gameInformation = {
hackable: true,
devModeSimple: true
};

2 changes: 2 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
<script type="text/javascript" src="js/load.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="js/gameLoopTools/colorUtilities.js"></script>
<script type="text/javascript" src="js/gameLoopTools/randomUtilities.js"></script>
<script type="text/javascript" src="js/gameLoopTools/mapController.js"></script>
<script type="text/javascript" src="js/gameLoopTools/neutralMap.js"></script>
<script type="text/javascript" src="js/gameLoopTools/objectSpawner.js"></script>
<script type="text/javascript" src="js/gameLoopTools/playerUtilities.js"></script>
<script type="text/javascript" src="js/gameLoopTools/blockUtilities.js"></script>
<script type="text/javascript" src="js/gameLoopTools/darknessUtilities.js"></script>
Expand Down
14 changes: 12 additions & 2 deletions client/js/gameLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ gameLoop = {

mapController.init();
neutralMap.init();
objectSpawner.init();
},

create: () => {
game.physics.startSystem(Phaser.Physics.ARCADE);
neutralMap.create(); // setup neutral map sprites
objectSpawner.create();
blockUtilities.init();

//setup player object
let playerStartData = [
gameLoop.width * gameLoop.xStartRegion,
Expand All @@ -42,18 +45,22 @@ gameLoop = {
darknessUtilities.create(gameLoop.player);
particlesUtilities.create(gameLoop.particles, gameLoop.player);

//interface pickups with player using event style callback
objectSpawner.onSpawn = playerUtilities.collisionInit;

//setup score UI
scoreUtilities.create(gameLoop.score);

if (gameLoop.debugMode === true) {
gameLoop.debug.controls = game.input.keyboard;
gameLoop.debug.controls = game.input.keyboard;
};

//gameLoop.difficultyIncrease = gameLoop.manageDifficulty(); // idk what this does lol
},

update: () => {
mapController.update();
objectSpawner.update();
playerUtilities.update(gameLoop.player, gameLoop.player.controlType);
particlesUtilities.update(gameLoop.particles, gameLoop.player);

Expand All @@ -71,7 +78,10 @@ gameLoop = {
}

},

render:() => {
game.debug.body(gameLoop.player.sprite);
//game.debug.body(sprite2);
},
//This will eventually be an isolated module
manageDifficulty: () => {
let data = config.default.difficultyModifiers[gameLoop.difficulty];
Expand Down
8 changes: 4 additions & 4 deletions client/js/gameLoopTools/blockUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ blockUtilities.initMarkers = () => {
}

blockUtilities.init = (data) => {
let markers = blockUtilities.initMarkers();
blockUtilities.startMarker = markers[0];
blockUtilities.endMarker = markers[1];
//let markers = blockUtilities.initMarkers();
// blockUtilities.startMarker = markers[0];
// blockUtilities.endMarker = markers[1];
blockUtilities.collection = game.add.group();
blockUtilities.collection.enableBody = true;
blockUtilities.collection.physicsBodyType = Phaser.Physics.ARCADE;
Expand Down Expand Up @@ -84,5 +84,5 @@ blockUtilities.create = (controller, data) => {
return block;
};
blockUtilities.update = (data) => {

};
4 changes: 0 additions & 4 deletions client/js/gameLoopTools/colorUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ colorUtilities.setNextFullBlockColor = (fullBlock) => {
}
};

// colorUtiliites.matchPrimaryColor = (
//
// )

colorUtilities.getColorCombo = (color1, color2) => {
const colorsAreTheSame = color1 === color2;
let results = colorsAreTheSame ? color1 : colorUtilities.mixColors(color1, color2);
Expand Down
22 changes: 16 additions & 6 deletions client/js/gameLoopTools/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const mapController = {};
mapController.bottom;
mapController.top;
mapController.speed;
mapController.traveledDistance;
mapController.mapObjects; // Anything in here will move down with the map
// Anything in mapObjects must have a .height, .anchor, and .y component so that their positions can be defined and manipulated.
// Anything in mapObjects must also not use its .fullyOnMap property
Expand All @@ -20,6 +21,7 @@ mapController.init = (data) => {
// assign to internal member data
mapController.top = 0;
mapController.speed = mapController.settings.mapVelocity;
mapController.traveledDistance;
mapController.mapObjects = [];
};

Expand Down Expand Up @@ -54,18 +56,26 @@ mapController.addToTopOfMap = (object) => {
};

mapController.update = () => {
mapController.traveledDistance += mapController.speed;
for (i = mapController.mapObjects.length - 1; i >= 0; i--) { // Backwards iteration since items could be removed from the array
let object = mapController.mapObjects[i];

if (object.y == null) { // This is in case the mapController is not destroyed upon game state change
if (object.y == null || object.enabled === false) { // This is in case the mapController is not destroyed upon game state change, or the object is explicitly disabled
mapController.mapObjects.splice(i, 1);
continue;
}

object.y += mapController.speed;
if (object.body != null) {
object.body.velocity.y = mapController.speed;
}

if (object._mapType){
object.y += mapController.speed;
}


let objectTop = transformUtilities.getTopPosition(object.y, object.height, object.anchor.y);

if (object.fullyOnMap === false) {
if (mapController.top <= objectTop) {
if (typeof (object.onFullyOnMap) === "function") {
Expand All @@ -83,16 +93,16 @@ mapController.update = () => {

if (mapController.bottom <= objectTop) {
if (typeof (object.onFullyLeftMap) === "function") {
object.onFullyLeftMap(); // This delegate acts as an override to the default auto-destroy behavior
object.onFullyLeftMap(object); // This delegate acts as an override to the default auto-destroy behavior
}
else {
object.destroy();
mapController.mapObjects.splice(i, 1);
}
mapController.mapObjects.splice(i, 1);
}
}
};

mapController.destroy = () => {
mapController.mapObjects = [];
};
};
9 changes: 6 additions & 3 deletions client/js/gameLoopTools/neutralMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ neutralMap.mapSprites = [];

neutralMap.init = (data) => {
data = typeof data === "undefined" ? {} : data;
neutralMap.mapData = data.neutralMap || config.neutralMap;
neutralMap.mapData = data.neutralMap || config.default.neutralMap;
neutralMap.width = data.width || config.init.screenWidth;
neutralMap.height = data.height || config.init.screenHeight;

Expand All @@ -18,9 +18,12 @@ neutralMap.createMaps = () => {
let mapSpriteData = [
neutralMap.width * neutralMap.mapData.xRegion,
0, // this will be changed
neutralMap.mapData.imgKey
neutralMap.mapData.key
];
latestMapSprite = game.add.sprite(...mapSpriteData);
latestMapSprite.alpha = 0.35;
//latestMapSprite._mapType = true;
//game.physics.enable(latestMapSprite);
latestMapSprite.anchor.setTo(...neutralMap.graphicCenter);
latestMapSprite.scale.x = latestMapSprite.scale.y =
transformUtilities.getScaleValueToEnvelopeRect(latestMapSprite.width, latestMapSprite.height, neutralMap.width, neutralMap.height);
Expand All @@ -46,4 +49,4 @@ neutralMap.reorderBottomSpriteToTop = (topPosition) => {
// setup neutral map
neutralMap.create = () => {
neutralMap.createMaps();
};
};
84 changes: 84 additions & 0 deletions client/js/gameLoopTools/objectSpawner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const objectSpawner = {};

objectSpawner.inactiveObjectPool;
objectSpawner.activeObjectPool = {};
objectSpawner.distanceUntilNextColorPickupSpawn;

objectSpawner.init = (data) => {
data = typeof data === "undefined" ? {} : data;
objectSpawner.colorPickup = data.colorPickup || config.default.colorPickup;
objectSpawner.tiles = data.settings || config.default.settings;
objectSpawner.width = data.screenWidth || config.init.screenWidth;

objectSpawner.id = 0;
objectSpawner.inactiveObjectPool = [];
objectSpawner.graphicCenter = [0.5, 0.5];
};

objectSpawner.create = () => {
objectSpawner.assignNextDistanceUntilColorPickupSpawn();
};

objectSpawner.update = () => {
objectSpawner.distanceUntilNextColorPickupSpawn -= mapController.speed;
if (objectSpawner.distanceUntilNextColorPickupSpawn <= 0) {
objectSpawner.assignNextDistanceUntilColorPickupSpawn();
let pickup = objectSpawner.spawnColorPickup();

let pickupEventInitiated = typeof objectSpawner.onSpawn === "function"
if (pickupEventInitiated){
objectSpawner.onSpawn(pickup)
}
}
};

objectSpawner.assignNextDistanceUntilColorPickupSpawn = () => {
let minDistance = objectSpawner.colorPickup.tilesBetweenSpawns.min * objectSpawner.tiles.tileHeight;
let maxDistance = objectSpawner.colorPickup.tilesBetweenSpawns.max * objectSpawner.tiles.tileHeight;
objectSpawner.distanceUntilNextColorPickupSpawn = randomUtilities.randomRange(minDistance, maxDistance);
};

objectSpawner.spawnColorPickup = () => {
let colorPickup = {
type: "color",
color: objectSpawner.colorPickup.colorOptions[randomUtilities.randomInt(0, objectSpawner.colorPickup.colorOptions.length)],
id: objectSpawner.id++
};

const theresNoItemsToDeploy = objectSpawner.inactiveObjectPool.length === 0;
if (theresNoItemsToDeploy) {
let colorPickupData = [
0,
0,
objectSpawner.colorPickup.key
];
colorPickup.sprite = game.add.sprite(...colorPickupData);
colorPickup.sprite.anchor.setTo(...objectSpawner.graphicCenter);
}
else {
colorPickup.sprite = objectSpawner.inactiveObjectPool.pop();
}
game.physics.enable(colorPickup.sprite, Phaser.Physics.ARCADE);
colorPickup.sprite.enableBody = true;
let minX = colorPickup.sprite.width * colorPickup.sprite.anchor.x;
let maxX = objectSpawner.width - colorPickup.sprite.width * (1 - colorPickup.sprite.anchor.x);
colorPickup.sprite._spawnParent = colorPickup;
objectSpawner.activeObjectPool[colorPickup.id] = colorPickup;
colorPickup.sprite.x = randomUtilities.randomRange(minX, maxX);
colorPickup.sprite.tint = colorPickup.color.value;
colorPickup.sprite.onFullyLeftMap = objectSpawner.disableObject;
colorPickup.sprite.enabled = true;
mapController.addToTopOfMap(colorPickup.sprite);

return colorPickup;
};

objectSpawner.disableObject = (object) => {

object.enabled = false;
object.enableBody = false;
delete objectSpawner.activeObjectPool[object._spawnParent.id];
objectSpawner.inactiveObjectPool.push(object);
};

objectSpawner.onSpawn = null;
Loading

0 comments on commit a2174dd

Please sign in to comment.