1
0
Fork 0
Browse Source

refactor: boundary factory is now agnostic on top / bottom

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
combat-scorched-earth-from-outer-space
André Jaenisch 10 months ago
parent
commit
3fb776ca78
Signed by: ryuno-ki
GPG Key ID: 5A668E771F1ED854
  1. 4
      src/js/world.js
  2. 6
      test/js/world.test.js
  3. 4
      types/world.d.ts

4
src/js/world.js

@ -31,7 +31,7 @@ export function makeAstronaut () {
}
/**
* Creates a boundary at the bottom of the screen.
* Creates a boundary of the screen.
*
* @param {object} config
* @param {number} config.x
@ -40,7 +40,7 @@ export function makeAstronaut () {
* @param {number} config.width
* @returns {Shape}
*/
export function makeBottomBoundary ({ x, y, height, width }) {
export function makeBoundary ({ x, y, height, width }) {
const center = Vec2(x + width / 2, y + height / 2)
const friction = 20
const restitution = 0

6
test/js/world.test.js

@ -1,7 +1,7 @@
import { expect } from 'chai'
import { Vec2 } from '../../src/js/vector.js'
import { makeAstronaut, makeBottomBoundary } from '../../src/js/world.js'
import { makeAstronaut, makeBoundary } from '../../src/js/world.js'
describe('World', function () {
describe('makeAstronaut', function () {
@ -17,7 +17,7 @@ describe('World', function () {
})
})
describe('makeBottomBoundary', function () {
describe('makeBoundary', function () {
it('should make an immobil shape', function () {
// Arrange
const x = 0
@ -26,7 +26,7 @@ describe('World', function () {
const width = 200
// Act
const boundary = makeBottomBoundary({ x, y, height, width })
const boundary = makeBoundary({ x, y, height, width })
// Assert
expect(boundary.X[0]).to.deep.equal(Vec2(x, y))

4
types/world.d.ts vendored

@ -6,7 +6,7 @@
*/
export function makeAstronaut(): Shape;
/**
* Creates a boundary at the bottom of the screen.
* Creates a boundary of the screen.
*
* @param {object} config
* @param {number} config.x
@ -15,7 +15,7 @@ export function makeAstronaut(): Shape;
* @param {number} config.width
* @returns {Shape}
*/
export function makeBottomBoundary({ x, y, height, width }: {
export function makeBoundary({ x, y, height, width }: {
x: number;
y: number;
height: number;

Loading…
Cancel
Save