Add more modules
This commit is contained in:
parent
0c63cb075b
commit
504f5fcc0c
18 changed files with 1448 additions and 11 deletions
|
@ -10,19 +10,39 @@ export const images = {
|
|||
},
|
||||
modules: {
|
||||
capsule: {
|
||||
small: 'modules/small_capsule.svg'
|
||||
small: 'modules/small_capsule.svg',
|
||||
large: 'modules/large_capsule.svg',
|
||||
advanced: 'modules/advanced_capsule.svg'
|
||||
},
|
||||
fuel: {
|
||||
small: 'modules/small_fuel_tank.svg'
|
||||
small: 'modules/small_fuel_tank.svg',
|
||||
large: 'modules/large_fuel_tank.svg',
|
||||
advanced: 'modules/advanced_fuel_tank.svg'
|
||||
},
|
||||
thruster: {
|
||||
light: {
|
||||
off: 'modules/light_thruster.svg',
|
||||
on: 'modules/light_thruster_on.svg',
|
||||
on: 'modules/light_thruster_on.svg'
|
||||
},
|
||||
heavy: {
|
||||
off: 'modules/light_thruster.svg',
|
||||
on: 'modules/light_thruster_on.svg'
|
||||
},
|
||||
advanced: {
|
||||
off: 'modules/light_thruster.svg',
|
||||
on: 'modules/light_thruster_on.svg'
|
||||
}
|
||||
},
|
||||
connector: {
|
||||
xheavy: 'modules/xheavy_connector.svg'
|
||||
xheavy: 'modules/xheavy_connector.svg',
|
||||
advanced: 'modules/advanced_connector.svg',
|
||||
},
|
||||
cargo: {
|
||||
small: 'modules/cargo_bay.svg'
|
||||
},
|
||||
gyroscope: {
|
||||
small: 'modules/small_gyroscope.svg',
|
||||
large: 'modules/large_gyroscope.svg'
|
||||
},
|
||||
fuelcan: 'modules/fuelcan.svg'
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ export const EDIT_MARGIN = 2;
|
|||
// Floating items.
|
||||
export const ENTITY_ROTATION_RATE = 0.01;
|
||||
// World generation.
|
||||
export const PLANET_SPAWN_RATE = 50;
|
||||
export const PLANET_SPAWN_RATE = 100;
|
||||
export const ENTITY_SPAWN_RATE = 8;
|
||||
export const MIN_CELESTIAL_SPACING = 15;
|
||||
export const FUEL_CAN_AMOUNT = 4;
|
||||
|
|
113
js/data.mjs
113
js/data.mjs
|
@ -9,9 +9,34 @@ export const modules = {
|
|||
type: 'capsule',
|
||||
id: 'small',
|
||||
mass: 2,
|
||||
value: 5,
|
||||
connectivity: [false, false, true, false],
|
||||
capacity: 2,
|
||||
rotation: 1
|
||||
},
|
||||
large: {
|
||||
name: 'Large Capsule',
|
||||
tooltip: 'A large, bulky capsule. Heavy, but has a lot of ' +
|
||||
'rotational power and storage space.',
|
||||
type: 'capsule',
|
||||
id: 'large',
|
||||
mass: 4,
|
||||
value: 10,
|
||||
connectivity: [false, false, true, false],
|
||||
capacity: 5,
|
||||
rotation: 4
|
||||
},
|
||||
advanced: {
|
||||
name: 'Advanced Capsule',
|
||||
tooltip: 'A futuristic rocket capsule. Has a lot of storage ' +
|
||||
'space and rotational power while still being light.',
|
||||
type: 'capsule',
|
||||
id: 'advanced',
|
||||
mass: 2,
|
||||
value: 30,
|
||||
connectivity: [false, false, true, false],
|
||||
capacity: 4,
|
||||
rotation: 5
|
||||
}
|
||||
},
|
||||
fuel: {
|
||||
|
@ -21,20 +46,62 @@ export const modules = {
|
|||
type: 'fuel',
|
||||
id: 'small',
|
||||
mass: 1,
|
||||
value: 1,
|
||||
connectivity: [true, false, true, false],
|
||||
fuelCapacity: 5
|
||||
},
|
||||
large: {
|
||||
name: 'Large Fuel Tank',
|
||||
tooltip: 'A large, heavy fuel tank capable of hold a lot of fuel.',
|
||||
type: 'fuel',
|
||||
id: 'large',
|
||||
mass: 2,
|
||||
value: 3,
|
||||
connectivity: [true, false, true, false],
|
||||
fuelCapacity: 15
|
||||
},
|
||||
advanced: {
|
||||
name: 'Advanced Fuel Tank',
|
||||
tooltip: 'A very efficient fuel storage tank.',
|
||||
type: 'fuel',
|
||||
id: 'advanced',
|
||||
mass: 1,
|
||||
value: 15,
|
||||
connectivity: [true, false, true, false],
|
||||
fuelCapacity: 12
|
||||
}
|
||||
},
|
||||
thruster: {
|
||||
light: {
|
||||
name: 'Light Main Thruster',
|
||||
name: 'Light Thruster',
|
||||
tooltip: 'Powerful enough to lift a small ship, but not much ' +
|
||||
'more.',
|
||||
type: 'thruster',
|
||||
id: 'light',
|
||||
mass: 2,
|
||||
value: 3,
|
||||
connectivity: [true, false, false, false],
|
||||
thrust: 10
|
||||
},
|
||||
heavy: {
|
||||
name: 'Heavy Thruster',
|
||||
tooltip: 'A powerful thruster for lifting heavy ships.',
|
||||
type: 'thruster',
|
||||
id: 'heavy',
|
||||
mass: 5,
|
||||
value: 6,
|
||||
connectivity: [true, false, false, false],
|
||||
thrust: 40
|
||||
},
|
||||
advanced: {
|
||||
name: 'Advanced Thruster',
|
||||
tooltip: 'A very efficient thruster using advanced technology. ',
|
||||
type: 'thruster',
|
||||
id: 'advanced',
|
||||
mass: 2,
|
||||
value: 20,
|
||||
connectivity: [true, false, false, false],
|
||||
thrust: 30
|
||||
}
|
||||
},
|
||||
connector: {
|
||||
|
@ -45,7 +112,51 @@ export const modules = {
|
|||
type: 'connector',
|
||||
id: 'xheavy',
|
||||
mass: 5,
|
||||
value: 3,
|
||||
connectivity: [true, true, true, true]
|
||||
},
|
||||
advanced: {
|
||||
name: 'Advanced 4-way Connector',
|
||||
tooltip: 'Connects ship parts while remaining light.',
|
||||
type: 'connector',
|
||||
id: 'advanced',
|
||||
mass: 1,
|
||||
value: 15,
|
||||
connectivity: [true, true, true, true]
|
||||
}
|
||||
},
|
||||
gyroscope: {
|
||||
small: {
|
||||
name: 'Small gyroscope',
|
||||
tooltip: 'Provides a small amount of rotational power to the ship.',
|
||||
type: 'gyroscope',
|
||||
id: 'small',
|
||||
mass: 3,
|
||||
value: 7,
|
||||
connectivity: [true, false, true, false],
|
||||
rotation: 2
|
||||
},
|
||||
large: {
|
||||
name: 'Large gyroscope',
|
||||
tooltip: 'Provides a lot of rotational force for large ships.',
|
||||
type: 'gyroscope',
|
||||
id: 'large',
|
||||
mass: 5,
|
||||
value: 15,
|
||||
connectivity: [true, false, true, false],
|
||||
rotation: 4
|
||||
}
|
||||
},
|
||||
cargo: {
|
||||
small: {
|
||||
name: 'Cargo bay',
|
||||
tooltip: 'A cargo bay for storing modules.',
|
||||
type: 'cargo',
|
||||
id: 'small',
|
||||
mass: 1,
|
||||
value: 5,
|
||||
connectivity: [true, false, true, false],
|
||||
capacity: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ function getAttributes() {
|
|||
thrust += t.module.thrust;
|
||||
} else if (t.type === 'gyroscope') {
|
||||
rotation += t.module.rotation;
|
||||
} else if (t.type === 'cargo') {
|
||||
cargo += t.module.capacity;
|
||||
}
|
||||
mass += t.module.mass;
|
||||
});
|
||||
|
|
|
@ -22,6 +22,10 @@ export function init() {
|
|||
shipLanded = false;
|
||||
}
|
||||
|
||||
export function outOfFuel() {
|
||||
gameOver('You ran out of fuel');
|
||||
}
|
||||
|
||||
export function playMusic() {
|
||||
audio.start('music');
|
||||
audio.volume('music', 0.4);
|
||||
|
@ -97,7 +101,6 @@ export function crash() {
|
|||
gameOver('You crashed');
|
||||
audio.play('crash');
|
||||
particle.createCrash(world.playerShip);
|
||||
|
||||
}
|
||||
|
||||
export function gameOver(reason) {
|
||||
|
|
|
@ -23,6 +23,7 @@ export default class Ship extends Body {
|
|||
this.cargoCapacity = 0;
|
||||
this.thrust = 0;
|
||||
this.crashed = false;
|
||||
this.timeWithoutFuel = 0;
|
||||
}
|
||||
|
||||
get com() {
|
||||
|
@ -69,6 +70,13 @@ export default class Ship extends Body {
|
|||
events.launchShip()
|
||||
}
|
||||
}
|
||||
|
||||
if (this.fuel === 0 && !state.gameOver) {
|
||||
if (this.timeWithoutFuel++ > 300)
|
||||
events.outOfFuel();
|
||||
} else {
|
||||
this.timeWithoutFuel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
clearModules() {
|
||||
|
@ -116,6 +124,8 @@ export default class Ship extends Body {
|
|||
this.thrust += m.data.thrust;
|
||||
} else if (m.type === 'gyroscope') {
|
||||
this.rotationPower += m.data.rotation;
|
||||
} else if (m.type === 'cargo') {
|
||||
this.cargoCapacity += m.data.capacity;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -105,10 +105,16 @@ function randomEntity(x, y) {
|
|||
if (Math.random() > 0.3) {
|
||||
entity = new Entity(x, y, 'fuelcan');
|
||||
} else {
|
||||
let arr = Object.entries(modules);
|
||||
[type, arr] = arr[Math.random() * arr.length | 0];
|
||||
arr = Object.keys(arr);
|
||||
entity = new Entity(x, y, type, arr[Math.random() * arr.length | 0]);
|
||||
let type, id;
|
||||
while (true) {
|
||||
let arr = Object.entries(modules);
|
||||
[type, arr] = arr[Math.random() * arr.length | 0];
|
||||
arr = Object.keys(arr);
|
||||
id = arr[Math.random() * arr.length | 0];
|
||||
let value = modules[type][id].value;
|
||||
if (Math.random() < (1 / value)) break;
|
||||
}
|
||||
entity = new Entity(x, y, type, id);
|
||||
}
|
||||
|
||||
world.entities.add(entity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue