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
//src/stores/gameStore.js | |
const segmentRate = 10; // yılanın her hareketinde katedeceği mesafe | |
const boardWidth = SharedStyle.board.width; | |
const BoardHeight = SharedStyle.board.height - 10; | |
let globalID; | |
... | |
@action("Snake is moving") | |
handleMoveSnake =() => { | |
let temp = _.cloneDeep(this.snake.slice()); | |
this.lastSegment = temp[0]; |
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
//src/components/segment.js | |
import React, { Component } from "react"; | |
import { View, Text, StyleSheet } from "react-native"; | |
import SharedStyle from "../utils/sharedStyle"; | |
// create a component | |
class Segment extends Component { | |
render() { | |
const customStyle = { | |
left: this.props.x, | |
top: this.props.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
"use strict"; | |
import mobx, { observable, action } from "mobx"; | |
import { AsyncStorage } from "react-native"; | |
const segmentRate = 10; // yılanın her hareketinde katedeceği mesafe | |
class GameStore { | |
@observable highScore = 0; //yapılan en yüksek skoru tutar | |
@observable score = 0; // yiyilen elma sayısı | |
@observable intervalRate = 15; //yılanın hızı | |
@observable currentDirection = "right"; // Yılanın yönü, alacağı değerler: left / right / up / down | |
@observable lastSegment = 10; // her segmentin kendinden önce takip edeceği, segment |
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
import { Navigation } from "react-native-navigation"; | |
import { reaction } from "mobx"; | |
import { registerScreens } from "./registerScreens"; | |
import { observer } from "mobx-react/native"; | |
import Store from "./stores"; | |
registerScreens(); | |
export default class App { | |
constructor() { | |
reaction(() => Store.nav.route, () => this.startApp(Store.nav.route)); | |
Store.nav.appInitialized(); |
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
import { Navigation } from "react-native-navigation"; | |
import HomeScreen from './screens/home'; | |
import GameScreen from './screens/gameScreen'; | |
import Store from './stores' | |
import Provider from './Provider' | |
export function registerScreens() { | |
Navigation.registerComponent("crazySnake.HomeScreen", () => HomeScreen,Store,Provider); | |
Navigation.registerComponent("crazySnake.GameScreen", () => GameScreen,Store,Provider); | |
} |
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
//import libraries | |
import React, { Component } from 'react'; | |
import { View, Text, StyleSheet, StatusBar } from 'react-native'; | |
import { inject, observer } from "mobx-react/native"; | |
import SharedStyle from "../utils/sharedStyle"; | |
import { Button, ScoreText} from "../components"; | |
// create a component | |
@inject("nav", "gameStore") | |
@observer | |
class Home extends Component { |
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
//src/util/SharedStyle.js | |
import { Dimensions, Platform } from "react-native"; | |
const { width, height } = Dimensions.get("window"); | |
function definiteWidth(width){ | |
const reminder = width % 10; | |
if( reminder !== 0 ){ | |
return width - reminder; | |
}else{ | |
return width; | |
} |
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
import { observer } from "mobx-react/native"; | |
import TodoStore from './store' | |
@observer | |
export default class hellomobx extends Component { | |
render() { | |
console.log(this.props); | |
return ( | |
<View style={styles.container}> | |
<Text>{TodoStore.selectedStatus}</Text> | |
</View> |
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
Show hidden characters
{ | |
'presets': ['react-native'], | |
'plugins': ['transform-decorators-legacy'] | |
} |