generated from nighthawkcoders/teacher_portfolio
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/nighthawkcoders/platformer3x
- Loading branch information
Showing
10 changed files
with
125 additions
and
11 deletions.
There are no files selected for viewing
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,24 @@ | ||
import GameEnv from './GameEnv.js'; | ||
import Background from './Background.js'; | ||
|
||
export class BackgroundNarwhal extends Background { | ||
constructor(canvas, image, data) { | ||
super(canvas, image, data); | ||
|
||
this.parallaxSpeed = 2; | ||
} | ||
|
||
// speed is used to background parallax behavior | ||
update() { | ||
this.speed = this.parallaxSpeed; | ||
super.update(); | ||
} | ||
|
||
draw() { | ||
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight); | ||
super.draw(); | ||
} | ||
|
||
} | ||
|
||
export default BackgroundNarwhal; |
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
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,49 @@ | ||
import GameEnv from './GameEnv.js'; | ||
import GameObject from './GameObject.js'; | ||
|
||
export class TubeGreece extends GameObject { | ||
constructor(canvas, image, data, xPercentage, yPercentage) { | ||
super(canvas, image, data); | ||
this.tubeX = xPercentage * GameEnv.innerWidth; | ||
this.tubeY = yPercentage; | ||
} | ||
|
||
// Required, but no update action | ||
update() { | ||
} | ||
|
||
// Draw position is always 0,0 | ||
draw() { | ||
this.ctx.drawImage(this.image, 0, 0); | ||
} | ||
|
||
// Set Tube position | ||
size() { | ||
// Formula for Height should be on constant ratio, using a proportion of 832 | ||
const scaledHeight = GameEnv.innerWidth * (64 / 832); | ||
// Formula for Width is scaled: scaledWidth/scaledHeight == this.width/this.height | ||
const scaledWidth = scaledHeight/1.5; | ||
// const tubeX = 0.4 * GameEnv.innerWidth; | ||
const tubeX = this.tubeX; | ||
//const tubeY = (GameEnv.bottom - 0.1 * scaledHeight); | ||
const tubeY = (GameEnv.bottom - scaledHeight) * this.tubeY; | ||
|
||
|
||
// set variables used in Display and Collision algorithms | ||
this.bottom = tubeY; | ||
this.collisionHeight = scaledHeight; | ||
this.collisionWidth = scaledWidth; | ||
|
||
//this.canvas.width = this.width; | ||
//this.canvas.height = this.height; | ||
this.canvas.style.width = `${scaledWidth}px`; | ||
this.canvas.style.height = `${scaledHeight}px`; | ||
this.canvas.style.position = 'absolute'; | ||
this.canvas.style.left = `${tubeX}px`; | ||
this.canvas.style.top = `${tubeY}px`; | ||
|
||
|
||
} | ||
} | ||
|
||
export default TubeGreece; |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.