-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored rendering information into separate Sprite class to prepar…
…e for animated sprites
- Loading branch information
Philipp Sehmisch
committed
Sep 19, 2020
1 parent
6649b77
commit 1a9abe7
Showing
11 changed files
with
56 additions
and
51 deletions.
There are no files selected for viewing
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
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,10 @@ | ||
abstract class Entity { | ||
public pos: Point | ||
public sprite?: Sprite | ||
collisionRadiusSqare: number = 0 | ||
|
||
constructor(pos: Point) { | ||
this.pos = { x: pos.x, y: pos.y } | ||
} | ||
public update(deltaTime: number, state:State) : void { }; | ||
} |
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
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,29 @@ | ||
abstract class Sprite { | ||
public rotation: number = 0 | ||
public renderPivot: Point = { x:0, y:0 } | ||
|
||
public abstract getImage() : CanvasImageSource | ||
} | ||
|
||
class SimpleSprite extends Sprite { | ||
|
||
private image: CanvasImageSource; | ||
public isLoaded: boolean; | ||
|
||
public constructor(src: ImageResource) { | ||
super() | ||
this.image = new Image(); | ||
this.image.src = src; | ||
this.image.onload = () => { | ||
this.isLoaded = true | ||
} | ||
this.image.onerror = () => { | ||
console.error("Could not load image " + src) | ||
} | ||
} | ||
|
||
public getImage() : CanvasImageSource { | ||
return this.image | ||
} | ||
} | ||
|
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