Skip to content

Commit d7ff68b

Browse files
committed
Initial commit
0 parents  commit d7ff68b

File tree

196 files changed

+286314
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+286314
-0
lines changed

LICENSE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Copyright (C) 2016 Milan Nikolic (gen2brain)
2+
3+
This software is provided 'as-is', without any express or implied
4+
warranty. In no event will the authors be held liable for any damages
5+
arising from the use of this software.
6+
7+
Permission is granted to anyone to use this software for any purpose,
8+
including commercial applications, and to alter it and redistribute it
9+
freely, subject to the following restrictions:
10+
11+
1. The origin of this software must not be misrepresented; you must not
12+
claim that you wrote the original software. If you use this software
13+
in a product, an acknowledgment in the product documentation would be
14+
appreciated but is not required.
15+
2. Altered source versions must be plainly marked as such, and must not be
16+
misrepresented as being the original software.
17+
3. This notice may not be removed or altered from any source distribution.

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## raylib-go [![GoDoc](https://godoc.org/github.com/gen2brain/raylib-go/raylib?status.svg)](https://godoc.org/github.com/gen2brain/raylib-go/raylib)
2+
3+
Golang bindings for [raylib](http://www.raylib.com/), a simple and easy-to-use library to learn videogames programming.
4+
5+
![screenshot](https://goo.gl/q6DAoy)
6+
7+
### Requirements
8+
9+
* [raylib](http://www.raylib.com/)
10+
* [GLFW3](http://www.glfw.org/)
11+
* [OpenAL Soft](http://kcat.strangesoft.net/openal.html)
12+
13+
### Installation
14+
15+
go get -v github.com/gen2brain/raylib-go
16+
17+
### Example
18+
19+
```go
20+
package main
21+
22+
import "github.com/gen2brain/raylib-go/raylib"
23+
24+
func main() {
25+
raylib.InitWindow(800, 450, "raylib [core] example - basic window")
26+
27+
raylib.SetTargetFPS(60)
28+
29+
for !raylib.WindowShouldClose() {
30+
raylib.BeginDrawing()
31+
32+
raylib.ClearBackground(raylib.RayWhite)
33+
34+
raylib.DrawText("Congrats! You created your first window!", 190, 200, 20, raylib.LightGray)
35+
36+
raylib.EndDrawing()
37+
}
38+
39+
raylib.CloseWindow()
40+
}
41+
```
42+
43+
Check more [examples](https://github.com/gen2brain/raylib-go/examples) organized by raylib modules.
44+
45+
46+
### License
47+
48+
raylib-go is licensed under an unmodified zlib/libpng license. View [LICENSE](https://github.com/gen2brain/raylib-go/blob/master/LICENSE).

easings/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## easings [![GoDoc](https://godoc.org/github.com/gen2brain/raylib-go/easings?status.svg)](https://godoc.org/github.com/gen2brain/raylib-go/easings)
2+
3+
Useful easing functions for values animation.
4+
5+
A port of Robert Penner's [easing equations](http://robertpenner.com/easing/).
6+
7+
![screenshot](https://goo.gl/crzRrH)

easings/easings.go

+263
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
// Useful easing functions for values animation
2+
//
3+
// A port of Robert Penner's easing equations (http://robertpenner.com/easing/)
4+
package easings
5+
6+
import (
7+
"math"
8+
)
9+
10+
// Linear Easing functions
11+
12+
func LinearNone(t, b, c, d float32) float32 {
13+
return c*t/d + b
14+
}
15+
16+
func LinearIn(t, b, c, d float32) float32 {
17+
return c*t/d + b
18+
}
19+
20+
func LinearOut(t, b, c, d float32) float32 {
21+
return c*t/d + b
22+
}
23+
24+
func LinearInOut(t, b, c, d float32) float32 {
25+
return c*t/d + b
26+
}
27+
28+
// Sine Easing functions
29+
30+
func SineIn(t, b, c, d float32) float32 {
31+
return -c*float32(math.Cos(float64(t/d)*(math.Pi/2))) + c + b
32+
}
33+
34+
func SineOut(t, b, c, d float32) float32 {
35+
return c*float32(math.Sin(float64(t/d)*(math.Pi/2))) + b
36+
}
37+
38+
func SineInOut(t, b, c, d float32) float32 {
39+
return -c/2*(float32(math.Cos(math.Pi*float64(t/d)))-1) + b
40+
}
41+
42+
// Circular Easing functions
43+
44+
func CircIn(t, b, c, d float32) float32 {
45+
t = t / d
46+
return -c*(float32(math.Sqrt(float64(1-t*t)))-1) + b
47+
}
48+
49+
func CircOut(t, b, c, d float32) float32 {
50+
return c*float32(math.Sqrt(1-float64((t/d-1)*t))) + b
51+
}
52+
53+
func CircInOut(t, b, c, d float32) float32 {
54+
t = t / d * 2
55+
56+
if t < 1 {
57+
return -c/2*(float32(math.Sqrt(float64(1-t*t)))-1) + b
58+
} else {
59+
t = t - 2
60+
return c/2*(float32(math.Sqrt(1-float64(t*t)))+1) + b
61+
}
62+
}
63+
64+
// Cubic Easing functions
65+
66+
func CubicIn(t, b, c, d float32) float32 {
67+
t = t / d
68+
return c*t*t*t + b
69+
}
70+
71+
func CubicOut(t, b, c, d float32) float32 {
72+
t = t/d - 1
73+
return c*(t*t*t+1) + b
74+
}
75+
76+
func CubicInOut(t, b, c, d float32) float32 {
77+
t = t / d * 2
78+
if t < 1 {
79+
return (c/2*t*t*t + b)
80+
} else {
81+
t = t - 2
82+
return c/2*(t*t*t+2) + b
83+
}
84+
}
85+
86+
// Quadratic Easing functions
87+
88+
func QuadIn(t, b, c, d float32) float32 {
89+
t = t / d
90+
return c*t*t + b
91+
}
92+
93+
func QuadOut(t, b, c, d float32) float32 {
94+
t = t / d
95+
return (-c*t*(t-2) + b)
96+
}
97+
98+
func QuadInOut(t, b, c, d float32) float32 {
99+
t = t / d * 2
100+
if t < 1 {
101+
return ((c / 2) * (t * t)) + b
102+
} else {
103+
return -c/2*((t-1)*(t-3)-1) + b
104+
}
105+
}
106+
107+
// Exponential Easing functions
108+
109+
func ExpoIn(t, b, c, d float32) float32 {
110+
if t == 0 {
111+
return b
112+
} else {
113+
return (c*float32(math.Pow(2, 10*float64(t/d-1))) + b)
114+
}
115+
}
116+
117+
func ExpoOut(t, b, c, d float32) float32 {
118+
if t == d {
119+
return (b + c)
120+
} else {
121+
return c*(-float32(math.Pow(2, -10*float64(t/d)))+1) + b
122+
}
123+
}
124+
125+
func ExpoInOut(t, b, c, d float32) float32 {
126+
if t == 0 {
127+
return b
128+
}
129+
if t == d {
130+
return (b + c)
131+
}
132+
133+
t = t / d * 2
134+
135+
if t < 1 {
136+
return (c/2*float32(math.Pow(2, 10*float64(t-1))) + b)
137+
} else {
138+
t = t - 1
139+
return (c/2*(-float32(math.Pow(2, -10*float64(t)))+2) + b)
140+
}
141+
}
142+
143+
// Back Easing functions
144+
145+
func BackIn(t, b, c, d float32) float32 {
146+
s := float32(1.70158)
147+
t = t / d
148+
return c*t*t*((s+1)*t-s) + b
149+
}
150+
151+
func BackOut(t, b, c, d float32) float32 {
152+
s := float32(1.70158)
153+
t = t/d - 1
154+
return c*(t*t*((s+1)*t+s)+1) + b
155+
}
156+
157+
func BackInOut(t, b, c, d float32) float32 {
158+
s := float32(1.70158)
159+
s = s * 1.525
160+
t = t / d * 2
161+
162+
if t < 1 {
163+
return c/2*(t*t*((s+1)*t-s)) + b
164+
} else {
165+
t = t - 2
166+
return c/2*(t*t*((s+1)*t+s)+2) + b
167+
}
168+
}
169+
170+
// Bounce Easing functions
171+
172+
func BounceIn(t, b, c, d float32) float32 {
173+
return (c - BounceOut(d-t, 0, c, d) + b)
174+
}
175+
176+
func BounceOut(t, b, c, d float32) float32 {
177+
t = t / d
178+
if t < (1 / 2.75) {
179+
return (c*(7.5625*t*t) + b)
180+
} else if t < (2 / 2.75) {
181+
t = t - (1.5 / 2.75)
182+
return c*(7.5625*t*t+0.75) + b
183+
} else if t < (2.5 / 2.75) {
184+
t = t - (2.25 / 2.75)
185+
return c*(7.5625*t*t+0.9375) + b
186+
} else {
187+
t = t - (2.625 / 2.75)
188+
return c*(7.5625*t*t+0.984375) + b
189+
}
190+
}
191+
192+
func BounceInOut(t, b, c, d float32) float32 {
193+
if t < d/2 {
194+
return BounceIn(t*2, 0, c, d)*0.5 + b
195+
} else {
196+
return BounceOut(t*2-d, 0, c, d)*0.5 + c*0.5 + b
197+
}
198+
}
199+
200+
// Elastic Easing functions
201+
202+
func ElasticIn(t, b, c, d float32) float32 {
203+
if t == 0 {
204+
return b
205+
}
206+
207+
t = t / d
208+
209+
if t == 1 {
210+
return b + c
211+
}
212+
213+
p := d * 0.3
214+
a := c
215+
s := p / 4
216+
postFix := a * float32(math.Pow(2, 10*float64(t-1)))
217+
218+
return -(postFix * float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
219+
}
220+
221+
func ElasticOut(t, b, c, d float32) float32 {
222+
if t == 0 {
223+
return b
224+
}
225+
226+
t = t / d
227+
228+
if t == 1 {
229+
return b + c
230+
}
231+
232+
p := d * 0.3
233+
a := c
234+
s := p / 4
235+
236+
return a*float32(math.Pow(2, -10*float64(t)))*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p))) + c + b
237+
}
238+
239+
func ElasticInOut(t, b, c, d float32) float32 {
240+
if t == 0 {
241+
return b
242+
}
243+
244+
t = t / d * 2
245+
246+
if t == 2 {
247+
return b + c
248+
}
249+
250+
p := d * (0.3 * 1.5)
251+
a := c
252+
s := p / 4
253+
254+
if t < 1 {
255+
t = t - 1
256+
postFix := a * float32(math.Pow(2, 10*float64(t)))
257+
return -0.5*(postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
258+
} else {
259+
t = t - 1
260+
postFix := a * float32(math.Pow(2, -10*(float64(t))))
261+
return postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))*0.5 + c + b
262+
}
263+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.github.gen2brain.raylib.go"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
8+
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
9+
10+
<!-- We do not have Java code. Therefore android:hasCode is set to false. -->
11+
<application android:allowBackup="false" android:hasCode="false"
12+
android:label="@string/app_name"
13+
android:icon="@drawable/icon"
14+
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
15+
16+
<!-- Our activity is the built-in NativeActivity framework class. -->
17+
<activity android:name="android.app.NativeActivity"
18+
android:configChanges="orientation|keyboardHidden|screenSize"
19+
android:screenOrientation="landscape"
20+
android:clearTaskOnLaunch="true">
21+
22+
<!-- Tell NativeActivity the name of our .so -->
23+
<meta-data android:name="android.app.lib_name" android:value="example" />
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
30+
</application>
31+
32+
</manifest>
Binary file not shown.
Binary file not shown.
9.29 KB
Binary file not shown.
Loading

0 commit comments

Comments
 (0)