Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KodyJKing committed Aug 17, 2019
1 parent c2765e3 commit f188b12
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
yarn-error.log
lib
node_modules
app.yaml
.gcloudignore
.npmrc
19 changes: 6 additions & 13 deletions src/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ export default class Card extends GameObject {
update( game: Game ) {
let { mouse, buttons } = Input
let { hand, discard, pawns, melter } = game
let { position } = this

// lock in positions
let fixedPos = hand.cardPosition( this )
if ( !this.grabbed && fixedPos.subtract( position ).length > 5 ) {
let fixVector = fixedPos.subtract( position )
this.position = position.add( fixVector.unit.multiply( fixVector.length / 10 ) )
}

if ( buttons.Mouse0 ) {
if ( this.contains( mouse ) && !game.grabbing ) {
Expand Down Expand Up @@ -76,15 +68,16 @@ export default class Card extends GameObject {

draw( color = "white" ) {
let { position, width, height } = this
let { x, y } = position
if ( color == "red" )
Canvas.image( getImage( "CardATK1" ), this.position.x, this.position.y, this.width, this.height )
Canvas.image( getImage( "CardATK1" ), x, y, width, height )
else if ( color == "redred" )
Canvas.image( getImage( "CardATK2" ), this.position.x, this.position.y, this.width, this.height )
Canvas.image( getImage( "CardATK2" ), x, y, width, height )
else if ( color == "blue" )
Canvas.image( getImage( "CardHP1" ), this.position.x, this.position.y, this.width, this.height )
Canvas.image( getImage( "CardHP1" ), x, y, width, height )
else if ( color == "blueblue" )
Canvas.image( getImage( "CardKarma" ), this.position.x, this.position.y, this.width, this.height )
Canvas.image( getImage( "CardKarma" ), x, y, width, height )
else
Canvas.image( getImage( "CardVolatile" ), this.position.x, this.position.y, this.width, this.height )
Canvas.image( getImage( "CardVolatile" ), x, y, width, height )
}
}
18 changes: 8 additions & 10 deletions src/Deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Deck extends GameObject {
for ( let i = 0; i < count; i++ ) {
let deckPos = new Vector( x + spreadX * i, y + spreadY * i )
// let rainbow = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
let rainbow = [ "red", "blue"]
let rainbow = [ "red", "blue" ]
let randColor = rainbow[ Math.floor( Math.random() * rainbow.length ) ]
let card = new Card( deckPos, randColor )
cards.push( card )
Expand Down Expand Up @@ -53,15 +53,13 @@ export default class Deck extends GameObject {
}

updateToFixed() {
if ( this.length > 0 ) {
this.cards.forEach( card => {
let fixedPos = this.cardPosition( card )
if ( fixedPos.subtract( card.position ).length > 1 ) {
let fixVector = fixedPos.subtract( card.position )
card.position = card.position.add( fixVector.unit.multiply( fixVector.length / 20 ) )
}
} )
}
this.cards.forEach( card => {
let fixedPos = this.cardPosition( card )
if ( fixedPos.subtract( card.position ).length > 1 ) {
let fixVector = fixedPos.subtract( card.position )
card.position = card.position.add( fixVector.unit.multiply( fixVector.length / 10 ) )
}
} )
}

cardPosition( card: Card ) {
Expand Down
2 changes: 2 additions & 0 deletions src/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export default class Game {
player.updateToFixed()

enemy.updateToFixed()

hand.updateToFixed()
discard.updateToFixed()
deck.updateToFixed()

Expand Down

0 comments on commit f188b12

Please sign in to comment.