Skip to content

Commit 9e3539f

Browse files
committed
added some spites
1 parent 0dbac0b commit 9e3539f

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class App extends Component {
117117

118118
renderDino = _ => {
119119
const { data } = this.state;
120-
document.body.style = 'background: black;';
120+
document.body.style = 'background: white;';
121121
return <Dino data={data} speed={this.getAverageGamma()} />;
122122
};
123123

src/dino/Dino.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ pipeSouthImg.src = pipeSouthPng;
2222
const verticalGap = 200;
2323
const horizontalGap = 75;
2424
const maxY = 20;
25-
const initialY = 100;
25+
const initialY = 200;
26+
const floorHeight = 280;
2627
let pipe = [];
2728
let constant = undefined;
2829
let score = 0;
@@ -50,7 +51,7 @@ class Dino extends React.Component {
5051
const { bX, bY } = this.state;
5152
const canvas = this.canvasRef.current;
5253
this.rAF = requestAnimationFrame(this.updateAnimationState);
53-
this.setState({ bY: maxY + this.props.yVelocity * 10 });
54+
this.setState({ bY: bY }); //maxY + this.props.yVelocity * 10
5455
for (let i = 0; i < pipe.length; i += 1) {
5556
constant = pipeNorthImg.height + verticalGap;
5657
pipe[i].x -= 1;
@@ -68,7 +69,7 @@ class Dino extends React.Component {
6869
bX <= pipe[i].x + pipeNorthImg.width &&
6970
(bY <= pipe[i].y + pipeNorthImg.height ||
7071
bY + brickImg.height >= pipe[i].y + constant)) ||
71-
bY + brickImg.height >= canvas.height // - fgImg.height
72+
bY + brickImg.height >= canvas.height // - fgImg.height
7273
) {
7374
score = 0;
7475
pipe = [
@@ -87,14 +88,14 @@ class Dino extends React.Component {
8788
};
8889

8990
moveUp = () => {
90-
this.setState({ bY: this.state.bY - 25 });
91+
this.setState({ bY: this.state.bY }); // - 25
9192
this.onFlap();
9293
};
9394

9495
componentDidMount() {
9596
const canvas = this.canvasRef.current;
9697
const context = canvas.getContext('2d');
97-
context.drawImage(bgImg, 0, 0);
98+
context.drawImage(bgImg, 0, floorHeight);
9899
this.rAF = requestAnimationFrame(this.updateAnimationState);
99100
pipe[0] = {
100101
x: canvas.width,
@@ -118,7 +119,7 @@ class Dino extends React.Component {
118119
const height = canvas.height;
119120
ctx.save();
120121
ctx.clearRect(0, 0, width, height);
121-
ctx.drawImage(bgImg, 0, 0);
122+
ctx.drawImage(bgImg, 0, floorHeight);
122123
ctx.drawImage(fgImg, 0, height - fgImg.height);
123124
for (let i = 0; i < pipe.length; i += 1) {
124125
ctx.drawImage(pipeNorthImg, pipe[i].x, pipe[i].y);

src/dino/assets/bird_up.PNG

-2.48 KB
Loading

src/dino/assets/dino_sprite.PNG

-1.46 KB
Loading

src/dino/assets/kektus_sprite.PNG

-2.9 KB
Loading

0 commit comments

Comments
 (0)