-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from omenking/66-garbage-preview-thumbs
#66 garbage thumbs
- Loading branch information
Showing
10 changed files
with
267 additions
and
101 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import ComponentGarbageThumb from 'components/garbage_thumb' | ||
import ComponentPlayfield from 'components/playfield' | ||
|
||
export default class ComponentGarbagePreview { | ||
public playfield : ComponentPlayfield | ||
public thumbs : Array<ComponentGarbageThumb> | ||
public x : number | ||
public y : number | ||
|
||
constructor(){ | ||
this.thumbs = [ | ||
new ComponentGarbageThumb(0), | ||
new ComponentGarbageThumb(1), | ||
new ComponentGarbageThumb(2), | ||
new ComponentGarbageThumb(3) | ||
] | ||
} | ||
|
||
create(playfield : ComponentPlayfield, x: number, y : number){ | ||
this.playfield = playfield | ||
this.x = x | ||
this.y = y | ||
this.thumbs[0].create(this) | ||
this.thumbs[1].create(this) | ||
this.thumbs[2].create(this) | ||
this.thumbs[3].create(this) | ||
} | ||
|
||
update(){ | ||
this.thumbs[0].update() | ||
this.thumbs[1].update() | ||
this.thumbs[2].update() | ||
this.thumbs[3].update() | ||
} | ||
|
||
render(){ | ||
this.thumbs[0].render() | ||
this.thumbs[1].render() | ||
this.thumbs[2].render() | ||
this.thumbs[3].render() | ||
} | ||
|
||
get_index(kind : string, val : number){ | ||
this.thumbs[0].kind = kind | ||
this.thumbs[0].size = val | ||
return 0 | ||
} | ||
|
||
fly_pos(pos){ | ||
return { | ||
x: this.thumbs[0].x, | ||
y: this.thumbs[0].y | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,90 @@ | ||
import game from 'core/game' | ||
import ComponentGarbagePreview from 'components/garbage_preview' | ||
import ComponentParticleClear from 'components/particle_clear' | ||
import { | ||
CHAIN, | ||
COMBO | ||
} from 'core/data'; | ||
|
||
export default class ComponentGarbageThumb { | ||
private _size | ||
private _kind | ||
private preview : ComponentGarbagePreview | ||
private sprite : Phaser.Sprite | ||
public size : number | ||
public kind : string | ||
private pos : number | ||
public x : number | ||
public y : number | ||
public visible : boolean | ||
public particles : Array<ComponentParticleClear> | ||
|
||
constructor(pos : number){ | ||
this.pos = pos | ||
this.particles = [ | ||
new ComponentParticleClear(0), | ||
new ComponentParticleClear(1), | ||
new ComponentParticleClear(2), | ||
new ComponentParticleClear(3) | ||
] | ||
} | ||
|
||
get absolute_center_x(){ | ||
return this.x + this.sprite.width / 2 | ||
} | ||
|
||
get absolute_center_y(){ | ||
return this.y + this.sprite.height / 2 | ||
} | ||
|
||
create(preview){ | ||
this.preview = preview | ||
this.sprite = game.add.sprite(0,0,'garbage_thumb',0) | ||
this.y = this.preview.y | ||
this.x = this.preview.x + (this.pos * this.sprite.width) | ||
this.sprite.visible = false | ||
this.visible = false | ||
this.sprite.x = this.x | ||
this.sprite.y = this.y | ||
this.particles[0].create(this,this.preview.playfield.pi) | ||
this.particles[1].create(this,this.preview.playfield.pi) | ||
this.particles[2].create(this,this.preview.playfield.pi) | ||
this.particles[3].create(this,this.preview.playfield.pi) | ||
} | ||
|
||
pop_in(){ | ||
this.particles[0].set_counter() | ||
this.particles[1].set_counter() | ||
this.particles[2].set_counter() | ||
this.particles[3].set_counter() | ||
this.visible = true | ||
} | ||
|
||
update(){ | ||
this.particles[0].update() | ||
this.particles[1].update() | ||
this.particles[2].update() | ||
this.particles[3].update() | ||
} | ||
|
||
get frame(){ | ||
if (this.kind === COMBO){ | ||
if (this.size === 4) { | ||
return 0 | ||
} else if (this.size === 5) { | ||
return 1 | ||
} else if (this.size === 6) { | ||
return 2 | ||
} | ||
} else if (this.kind === CHAIN) { | ||
return 3 | ||
} | ||
} | ||
|
||
render(){ | ||
this.particles[0].render() | ||
this.particles[1].render() | ||
this.particles[2].render() | ||
this.particles[3].render() | ||
this.sprite.visible = this.visible | ||
this.sprite.frame = this.frame | ||
} | ||
} |
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
Oops, something went wrong.