11import { AnimatedSprite } from 'pixi.js' ;
2- import type { Container , Rectangle , Texture } from 'pixi.js' ;
2+ import type { Rectangle , Texture } from 'pixi.js' ;
33
44export interface AnimatedTextures {
55 down : Texture [ ] ;
@@ -8,26 +8,23 @@ export interface AnimatedTextures {
88 up : Texture [ ] ;
99}
1010
11- export class Monster {
11+ export class Player {
1212 bounds : Rectangle ;
1313
1414 positionX = 0 ;
1515 positionY = 0 ;
16- stage : Container ;
1716 view : AnimatedSprite ;
18- constructor ( textures : AnimatedTextures , bounds : Rectangle , stage : Container ) {
17+ constructor ( textures : AnimatedTextures , bounds : Rectangle ) {
1918 this . bounds = bounds ;
2019 this . view = new AnimatedSprite ( [
2120 ...textures . down ,
2221 ...textures . left ,
2322 ...textures . right ,
2423 ...textures . up ,
2524 ] ) ;
26- this . stage = stage ;
2725
2826 //TODO: Defaults to right, maybe it shouldn't
2927 this . view . currentFrame = 5 ;
30- this . stage . addChild ( this . view ) ;
3128 }
3229
3330 public down ( ) {
@@ -36,6 +33,7 @@ export class Monster {
3633 setTimeout ( ( ) => {
3734 this . view . gotoAndStop ( 1 ) ;
3835 this . view . position . y = this . view . position . y + this . bounds . height / 2 ;
36+ console . debug ( this . view . position ) ;
3937 } , 200 ) ;
4038 }
4139 public left ( ) {
@@ -44,6 +42,7 @@ export class Monster {
4442 setTimeout ( ( ) => {
4543 this . view . gotoAndStop ( 3 ) ;
4644 this . view . position . x = this . view . position . x - this . bounds . width / 2 ;
45+ console . debug ( this . view . position ) ;
4746 } , 200 ) ;
4847 }
4948 public right ( ) {
@@ -52,14 +51,16 @@ export class Monster {
5251 setTimeout ( ( ) => {
5352 this . view . gotoAndStop ( 5 ) ;
5453 this . view . position . x = this . view . position . x + this . bounds . width / 2 ;
54+ console . debug ( this . view . position ) ;
5555 } , 200 ) ;
5656 }
5757 public up ( ) {
5858 this . view . gotoAndStop ( 6 ) ;
5959 this . view . position . y = this . view . position . y - this . bounds . height / 2 ;
6060 setTimeout ( ( ) => {
61- this . view . position . y = this . view . position . y - this . bounds . height / 2 ;
6261 this . view . gotoAndStop ( 7 ) ;
62+ this . view . position . y = this . view . position . y - this . bounds . height / 2 ;
63+ console . debug ( this . view . position ) ;
6364 } , 200 ) ;
6465 }
6566}
0 commit comments