-
Notifications
You must be signed in to change notification settings - Fork 4
/
renderers.js
113 lines (101 loc) · 2.62 KB
/
renderers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { PureComponent } from 'react';
import { StyleSheet, Image, Animated, View, Text } from 'react-native';
import { Font } from 'expo';
class Character extends PureComponent {
render() {
if (!this.props.b) {
let x = this.props.position[0]
let y = this.props.position[1]
let w = this.props.size[0]
let h = this.props.size[1]
let side = this.props.side
return (
<Image style={[styles.char, {transform: [ { rotateY: side ? side : '0deg' } ]}, {left: x, top: y, width: w, height: h}]} source={require('./assets/astronaut.png')} />
)
} else {
return (
<Image style={[styles.char, {left: this.props.b[0], bottom: this.props.b[1]}]} source={require('./assets/astronaut.png')} />
)
}
}
}
class Platform extends PureComponent {
constructor() {
super()
let images = [require('./assets/ground_grass.png'), require('./assets/ground_grass_broken.png'), require('./assets/ground_stone.png'), require('./assets/ground_stone_broken.png')]
let i = Math.round(Math.random() * 3)
let image = images[i]
this.state = {
image: image
}
}
render() {
let x = this.props.position[0]
let y = this.props.position[1]
let w = this.props.size[0]
let h = this.props.size[1]
let image = this.state.image
if (this.props.effects == 'lava')
image = require('./assets/ground_lava.png')
return (
<Image style={[styles.platform, {left: x, top: y, width: w, height: h} ]} source={image}/>
)
}
};
class Score extends PureComponent {
constructor(props) {
super(props)
}
render() {
return (
<View style={styles.center}>
<Text style={styles.score}>{this.props.score ? this.props.score : 0}</Text>
</View>
)
}
}
class Logo extends PureComponent {
constructor(props) {
super(props)
}
render() {
return (
<View style={{width: '100%', alignItems: 'center', position: 'absolute', top: 100}}>
<Image style={[styles.logo]} source={require('./assets/logo.png')} />
</View>
)
}
}
const styles = StyleSheet.create({
char: {
height: 80,
width: 43.80,
position: 'absolute',
zIndex: 3,
// top: 100,
resizeMode: 'stretch'
},
center: {
width: '100%',
height: 100,
alignItems: 'center',
justifyContent: 'center'
},
score: {
fontSize: 32,
zIndex: 4,
fontFamily: 'nasalization',
color: '#fff'
},
platform: {
position: 'absolute',
// resizeMode: 'contain',
zIndex: 2
},
platforms: {
position: 'absolute',
zIndex: 1,
flex: 1
}
});
export { Character, Platform, Score, Logo }