-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
414 additions
and
164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/mainScreen/shootingModes/moving/MovingConfigure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import {Row, Col, Button, OverlayTrigger, Tooltip} from "react-bootstrap"; | ||
|
||
class MovingConfigure extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
} | ||
|
||
} | ||
|
||
saveSettings() { | ||
this.props.saveSettings(this.state) | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<Row style={{marginTop: "20px"}}> | ||
<Col sm={12} className={"text-center"}> | ||
<Button variant={"customPrimary"} onClick={() => {this.saveSettings()}} size={"lg"}>Shoot!</Button> | ||
</Col> | ||
</Row> | ||
|
||
</> | ||
) | ||
} | ||
} | ||
|
||
export default MovingConfigure; |
108 changes: 108 additions & 0 deletions
108
src/components/mainScreen/shootingModes/moving/MovingShoot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React from 'react'; | ||
import {Row, Col, Button} from "react-bootstrap"; | ||
import ShotFeed from "../../shooting/ShotFeed"; | ||
import ShotRecord from "../../shooting/ShotRecord"; | ||
import TargetUtils from "../../../../util/TargetUtils" | ||
import {bindActionCreators} from "redux"; | ||
import {addTarget, wipeTargets, tickTargets} from "../../../../app/slices/targetSlice"; | ||
import {wipeNonTargetElements} from "../../../../app/slices/projectorSlice" | ||
import {wipeShots} from "../../../../app/slices/shotSlice"; | ||
import {connect} from "react-redux"; | ||
|
||
class StandardShoot extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.timerRef = React.createRef(); | ||
} | ||
|
||
componentDidMount() { | ||
this.resetTargets() | ||
} | ||
|
||
resetTargets() { | ||
this.props.wipeTargets(); | ||
this.props.wipeNonTargetElements(); | ||
this.props.wipeShots(); | ||
const {canvasWidth, canvasHeight} = this.props.canvasDimensions; | ||
const targetName = "bullseye" | ||
const target = TargetUtils.getTargetByName(targetName); | ||
let targetHeight = canvasHeight * .2; | ||
const targetWidth = TargetUtils.getTargetWidthForHeight(target.name, targetHeight) | ||
|
||
for (let i = 0; i < 5; i++) { | ||
|
||
let displayTarget = { | ||
name: "bullseye", | ||
x: Math.random() * canvasWidth * .8, | ||
y: Math.random() * canvasHeight * .8, | ||
width: targetWidth, | ||
height: targetHeight, | ||
requestedScaleRatio: targetHeight / target.defaultHeight, | ||
id: TargetUtils.generateId(), | ||
dx: Math.random() > .5 ? -8: 8, | ||
dy: Math.random() > .5 ? -8 : 8, | ||
maxX: canvasWidth - targetWidth, | ||
maxY: canvasHeight - targetHeight | ||
} | ||
this.props.addTarget(displayTarget) | ||
} | ||
|
||
if (this.hasOwnProperty("interval")) | ||
clearInterval(this.interval) | ||
|
||
const fps = 40; | ||
let delay = 1000 / fps; | ||
this.interval = setInterval(() => { | ||
this.props.tickTargets() | ||
}, delay) | ||
} | ||
|
||
componentWillUnmount() { | ||
if (this.hasOwnProperty("interval")) | ||
clearInterval(this.interval) | ||
} | ||
|
||
getFeed() { | ||
return <ShotFeed videoRef={this.props.videoRef} /> | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<Row> | ||
<Col sm={12} className={"text-center"}> | ||
<p>Start shooting!</p> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col sm={4}> | ||
<ShotRecord /> | ||
</Col> | ||
<Col sm={8}> | ||
{this.getFeed()} | ||
</Col> | ||
</Row> | ||
<Row style={{marginTop: "30px"}}> | ||
<Col sm={12} className={"text-center"}> | ||
<Button variant={"customPrimary"} onClick={() => {this.resetTargets()}} size={"lg"} style={{marginBottom: "10px"}}>Reset Target</Button> <br /> | ||
<Button variant={"customPrimary"} onClick={() => {this.props.backToSettings()}} size={"lg"}>Back To Settings</Button> | ||
</Col> | ||
</Row> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
canvasDimensions: { | ||
canvasHeight: state.projector.canvasHeight, | ||
canvasWidth: state.projector.canvasWidth | ||
} | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => { | ||
return bindActionCreators({addTarget, wipeShots, wipeTargets, wipeNonTargetElements, tickTargets}, dispatch) | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(StandardShoot); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
|
||
const Bullseye = ({x=0, y=0, width=251, height=251}) => { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 251 251" x={x} y={y} width={width} height={height}> | ||
<g id="Bullseye"> | ||
<path id="_4-ring" data-name="4-ring" style={{stroke: "#000", strokeMiterlimit: 10, fill: "#000"}} | ||
d="M250.5,125.5A125,125,0,1,1,125.5.5,125,125,0,0,1,250.5,125.5Z"/> | ||
<path id="_6-ring" data-name="6-ring" style={{stroke: "#000", strokeMiterlimit: 10, fill: "#0071bc"}} | ||
d="M225.5,125.5a100,100,0,1,1-100-100A100,100,0,0,1,225.5,125.5Z"/> | ||
<path id="_8-ring" data-name="8-ring" style={{stroke: "#000", strokeMiterlimit: 10, fill: "red"}} | ||
d="M200.5,125.5a75,75,0,1,1-75-75A75,75,0,0,1,200.5,125.5Z"/> | ||
<path id="_10-ring" data-name="10-ring" style={{stroke: "#000", strokeMiterlimit: 10, fill: "#ff0"}} | ||
d="M175.5,125.5a50,50,0,1,1-50-50A50,50,0,0,1,175.5,125.5Z"/> | ||
</g> | ||
</svg> | ||
) | ||
} | ||
|
||
export default Bullseye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters