Skip to content

Commit

Permalink
begin working on robot customizability; now color of Hedgehog can be …
Browse files Browse the repository at this point in the history
…specified
  • Loading branch information
SillyFreak committed Oct 15, 2020
1 parent 83e12d8 commit 79d195b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/components/ide/Simulator/simulation/Robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Pose, Hedgehog } from '.';
import { DifferentialDrive } from './drives';
import { CollisionSensor, TouchSensor, LineSensor, DistanceSensor } from './sensors';
import { ServoArm } from './servo';
import * as SimulationSchema from '../../SimulatorEditor/SimulationSchema';

function createArray<T>(length: number, cb: (index: number) => T): T[] {
// Array.from({ length: n }, (v, i) => ...):
Expand All @@ -28,11 +29,13 @@ export default class Robot {

robot: Matter.Composite;

constructor() {
this.initBody();
constructor(options: SimulationSchema.RobotProps) {
this.initBody(options);
}

initBody() {
initBody({
render: renderBody,
}: SimulationSchema.RobotProps) {
const material = {
density: 1,
frictionAir: 0.4,
Expand All @@ -49,9 +52,7 @@ export default class Robot {
const styleBody = {
render: {
fillStyle: '#38b449',
// sprite: {
// texture: '/icon.png',
// },
...renderBody,
},
};
const styleLineSensor = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ide/Simulator/simulation/Simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ export default class Simulation {
name,
position: { x, y },
angle,
// color,
...options
} = object;
const robot = new Robot();
const robot = new Robot(options);
const pose = { x, y, angle };
robot.setPose(pose);
setInitialPose(robot.body);
Expand Down
2 changes: 1 addition & 1 deletion src/components/ide/SimulatorEditor/SimulationSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Label = {|
label?: string,
|};

type RobotProps = {|
export type RobotProps = {|
...Translation,
...Rotation,
render?: {
Expand Down

0 comments on commit 79d195b

Please sign in to comment.