Created
October 2, 2017 07:27
-
-
Save ysfzrn/f3dce7cd01cd90a83c2034c5d14ba7e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// src/stores/gameStore.js | |
class GameStore { | |
... | |
@observable food = { x: 50, y: 50 }; //elmanın başlangıçta belireceği yer. | |
... | |
@action("make food") | |
handleMakeFood() { | |
const frameX = (boardWidth -10) / segmentRate; | |
const frameY = BoardHeight / segmentRate; | |
this.food.x = this.getRandomInt(0, frameX) * segmentRate; | |
this.food.y = this.getRandomInt(0, frameY) * segmentRate; | |
} | |
getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment