Skip to content

Commit

Permalink
added some spites
Browse files Browse the repository at this point in the history
  • Loading branch information
bquinn17 committed May 1, 2019
1 parent 34b549d commit c1461cc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class App extends Component {

renderDino = _ => {
const { data } = this.state;
document.body.style = 'background: black;';
document.body.style = 'background: white;';
return <Dino data={data} speed={this.getAverageGamma()} />;
};

Expand Down
13 changes: 7 additions & 6 deletions src/dino/Dino.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pipeSouthImg.src = pipeSouthPng;
const verticalGap = 200;
const horizontalGap = 75;
const maxY = 20;
const initialY = 100;
const initialY = 200;
const floorHeight = 280;
let pipe = [];
let constant = undefined;
let score = 0;
Expand Down Expand Up @@ -50,7 +51,7 @@ class Dino extends React.Component {
const { bX, bY } = this.state;
const canvas = this.canvasRef.current;
this.rAF = requestAnimationFrame(this.updateAnimationState);
this.setState({ bY: maxY + this.props.yVelocity * 10 });
this.setState({ bY: bY }); //maxY + this.props.yVelocity * 10
for (let i = 0; i < pipe.length; i += 1) {
constant = pipeNorthImg.height + verticalGap;
pipe[i].x -= 1;
Expand All @@ -68,7 +69,7 @@ class Dino extends React.Component {
bX <= pipe[i].x + pipeNorthImg.width &&
(bY <= pipe[i].y + pipeNorthImg.height ||
bY + brickImg.height >= pipe[i].y + constant)) ||
bY + brickImg.height >= canvas.height // - fgImg.height
bY + brickImg.height >= canvas.height // - fgImg.height
) {
score = 0;
pipe = [
Expand All @@ -87,14 +88,14 @@ class Dino extends React.Component {
};

moveUp = () => {
this.setState({ bY: this.state.bY - 25 });
this.setState({ bY: this.state.bY }); // - 25
this.onFlap();
};

componentDidMount() {
const canvas = this.canvasRef.current;
const context = canvas.getContext('2d');
context.drawImage(bgImg, 0, 0);
context.drawImage(bgImg, 0, floorHeight);
this.rAF = requestAnimationFrame(this.updateAnimationState);
pipe[0] = {
x: canvas.width,
Expand All @@ -118,7 +119,7 @@ class Dino extends React.Component {
const height = canvas.height;
ctx.save();
ctx.clearRect(0, 0, width, height);
ctx.drawImage(bgImg, 0, 0);
ctx.drawImage(bgImg, 0, floorHeight);
ctx.drawImage(fgImg, 0, height - fgImg.height);
for (let i = 0; i < pipe.length; i += 1) {
ctx.drawImage(pipeNorthImg, pipe[i].x, pipe[i].y);
Expand Down
Binary file modified src/dino/assets/bird_up.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/dino/assets/dino_sprite.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/dino/assets/kektus_sprite.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1461cc

Please sign in to comment.