Bug fixes
This commit is contained in:
parent
69fee5e73d
commit
ce6a707526
5 changed files with 30 additions and 9 deletions
|
@ -18,8 +18,8 @@ export const MAX_ZOOM = 100;
|
||||||
export const DEFAULT_ZOOM = 10;
|
export const DEFAULT_ZOOM = 10;
|
||||||
export const ZOOM_SPEED = 0.01;
|
export const ZOOM_SPEED = 0.01;
|
||||||
// Ship landing. Angle in radians.
|
// Ship landing. Angle in radians.
|
||||||
export const TIP_ANGLE = 0.3;
|
export const TIP_ANGLE = 0.25;
|
||||||
export const TIP_SPEED = 0.015;
|
export const TIP_SPEED = 0.03;
|
||||||
// Ship flight mechanics. Speed measured in units per tick.
|
// Ship flight mechanics. Speed measured in units per tick.
|
||||||
export const FUEL_BURN_RATE = 0.01;
|
export const FUEL_BURN_RATE = 0.01;
|
||||||
export const THRUST_POWER = 0.007;
|
export const THRUST_POWER = 0.007;
|
||||||
|
|
|
@ -48,6 +48,8 @@ function tickPlaying() {
|
||||||
if (pressed[mapping.inventory]) {
|
if (pressed[mapping.inventory]) {
|
||||||
state.inventory = !state.inventory;
|
state.inventory = !state.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pressed['KeyR']) events.startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tickEditing() {
|
function tickEditing() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import {state} from './index.mjs';
|
||||||
import {modules} from '../data.mjs';
|
import {modules} from '../data.mjs';
|
||||||
import {images as assets} from '../assets.mjs';
|
import {images as assets} from '../assets.mjs';
|
||||||
import * as events from './events.mjs';
|
import * as events from './events.mjs';
|
||||||
|
@ -5,6 +6,8 @@ import * as events from './events.mjs';
|
||||||
export const items = new Map();
|
export const items = new Map();
|
||||||
export let currentItem = null;
|
export let currentItem = null;
|
||||||
|
|
||||||
|
let onupdate = () => {};
|
||||||
|
|
||||||
export function init() {
|
export function init() {
|
||||||
items.clear();
|
items.clear();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +23,7 @@ export function addItem(type, id) {
|
||||||
if (!items.has(mapId)) items.set(mapId, new Tile(type, id));
|
if (!items.has(mapId)) items.set(mapId, new Tile(type, id));
|
||||||
let tile = items.get(mapId);
|
let tile = items.get(mapId);
|
||||||
tile.increase();
|
tile.increase();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeItem(type, id) {
|
export function removeItem(type, id) {
|
||||||
|
@ -31,11 +35,22 @@ export function removeItem(type, id) {
|
||||||
items.delete(mapId);
|
items.delete(mapId);
|
||||||
currentItem = null;
|
currentItem = null;
|
||||||
}
|
}
|
||||||
events.tossItem();
|
if (!state.editing)
|
||||||
|
events.tossItem();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectItem(type, id) {
|
export function selectItem(type, id) {
|
||||||
currentItem = items.get(toId(type, id));
|
currentItem = items.get(toId(type, id));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setOnupdate(func) {
|
||||||
|
onupdate = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
onupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toId(type, id) {
|
function toId(type, id) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ export default class GuiInventory extends GuiElement {
|
||||||
this.tileWidth = 4;
|
this.tileWidth = 4;
|
||||||
this.tileHeight = 5;
|
this.tileHeight = 5;
|
||||||
this.currentPage = 0;
|
this.currentPage = 0;
|
||||||
|
inventory.setOnupdate(this.updateTiles.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTiles() {
|
updateTiles() {
|
||||||
|
|
|
@ -111,16 +111,19 @@ export default class Ship extends Body {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveCelestialCollision(pos, cel) {
|
resolveCelestialCollision(pos, cel) {
|
||||||
//debugger;
|
// I don't even know why this works, don't touch it.
|
||||||
let theta = this.angleTo(...this.com, ...cel.com);
|
let theta = this.angleTo(...this.com, ...cel.com);
|
||||||
let angleToCom = this.angleTo(...this.com, ...pos);
|
let angleToCom = this.angleTo(...this.com, ...pos);
|
||||||
let angle = angleToCom - theta;
|
let turnAngle = angleToCom - theta;
|
||||||
let [force] = this.rotateVector(0, 1, angle);
|
let checkAngle = theta - this.r - Math.PI / 2;
|
||||||
if (Math.abs(angle) < consts.TIP_ANGLE) {
|
let [force] = this.rotateVector(0, 1, turnAngle);
|
||||||
|
if (Math.abs(checkAngle) < consts.TIP_ANGLE) {
|
||||||
force *= -1;
|
force *= -1;
|
||||||
}
|
}
|
||||||
if (Math.abs(angle) < 0.003
|
let canLand = Math.abs(checkAngle) < 0.03
|
||||||
&& Math.abs(this.rvel) < 0.001) {
|
&& Math.abs(this.rvel) < 0.001;
|
||||||
|
|
||||||
|
if (canLand) {
|
||||||
this.landed = true;
|
this.landed = true;
|
||||||
this.rvel = 0;
|
this.rvel = 0;
|
||||||
this.r = theta - Math.PI / 2;
|
this.r = theta - Math.PI / 2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue