step
|
@ -1,3 +0,0 @@
|
|||
## Examples
|
||||
|
||||
Live (web/emscripten) examples are available on [raylib website](http://www.raylib.com/examples.html).
|
|
@ -1,66 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing")
|
||||
|
||||
rl.InitAudioDevice() // Initialize audio device
|
||||
|
||||
fxWav := rl.LoadSound("sound.wav") // Load WAV audio file
|
||||
fxOgg := rl.LoadSound("target.ogg") // Load OGG audio file
|
||||
|
||||
rl.SetSoundVolume(fxWav, 0.2)
|
||||
|
||||
rl.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
for !rl.WindowShouldClose() { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
rl.PlaySoundMulti(fxWav)
|
||||
} // Play a new wav sound instance
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.PlaySoundMulti(fxOgg)
|
||||
} // Play a new ogg sound instance
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("MULTICHANNEL SOUND PLAYING", 20, 20, 20, rl.Gray)
|
||||
rl.DrawText("Press SPACE to play new ogg instance!", 200, 120, 20, rl.LightGray)
|
||||
rl.DrawText("Press ENTER to play new wav instance!", 200, 180, 20, rl.LightGray)
|
||||
|
||||
rl.DrawText(fmt.Sprintf("CONCURRENT SOUNDS PLAYING: %02d", rl.GetSoundsPlaying()), 220, 280, 20, rl.Red)
|
||||
|
||||
rl.EndDrawing()
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
rl.StopSoundMulti() // We must stop the buffer pool before unloading
|
||||
|
||||
rl.UnloadSound(fxWav) // Unload sound data
|
||||
rl.UnloadSound(fxOgg) // Unload sound data
|
||||
|
||||
rl.CloseAudioDevice() // Close audio device
|
||||
|
||||
rl.CloseWindow() // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const maxCircles = 64
|
||||
|
||||
type circleWave struct {
|
||||
Position rl.Vector2
|
||||
Radius float32
|
||||
Alpha float32
|
||||
Speed float32
|
||||
Color rl.Color
|
||||
}
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint) // NOTE: Try to enable MSAA 4X
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)")
|
||||
|
||||
rl.InitAudioDevice()
|
||||
|
||||
colors := []rl.Color{
|
||||
rl.Orange, rl.Red, rl.Gold, rl.Lime, rl.Blue,
|
||||
rl.Violet, rl.Brown, rl.LightGray, rl.Pink,
|
||||
rl.Yellow, rl.Green, rl.SkyBlue, rl.Purple, rl.Beige,
|
||||
}
|
||||
|
||||
circles := make([]circleWave, maxCircles)
|
||||
|
||||
for i := maxCircles - 1; i >= 0; i-- {
|
||||
c := circleWave{}
|
||||
|
||||
c.Alpha = 0
|
||||
c.Radius = float32(rl.GetRandomValue(10, 40))
|
||||
|
||||
x := rl.GetRandomValue(int32(c.Radius), screenWidth-int32(c.Radius))
|
||||
y := rl.GetRandomValue(int32(c.Radius), screenHeight-int32(c.Radius))
|
||||
c.Position = rl.NewVector2(float32(x), float32(y))
|
||||
|
||||
c.Speed = float32(rl.GetRandomValue(1, 100)) / 20000.0
|
||||
c.Color = colors[rl.GetRandomValue(0, int32(len(colors)-1))]
|
||||
|
||||
circles[i] = c
|
||||
}
|
||||
|
||||
xm := rl.LoadMusicStream("mini1111.xm")
|
||||
rl.PlayMusicStream(xm)
|
||||
|
||||
pause := false
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateMusicStream(xm) // Update music buffer with new stream data
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.StopMusicStream(xm)
|
||||
rl.PlayMusicStream(xm)
|
||||
}
|
||||
|
||||
// Pause/Resume music playing
|
||||
if rl.IsKeyPressed(rl.KeyP) {
|
||||
pause = !pause
|
||||
|
||||
if pause {
|
||||
rl.PauseMusicStream(xm)
|
||||
} else {
|
||||
rl.ResumeMusicStream(xm)
|
||||
}
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions
|
||||
timePlayed := int32(rl.GetMusicTimePlayed(xm)/rl.GetMusicTimeLength(xm)*float32(screenWidth-40)) * 2
|
||||
|
||||
// Color circles animation
|
||||
for i := maxCircles - 1; (i >= 0) && !pause; i-- {
|
||||
circles[i].Alpha += circles[i].Speed
|
||||
circles[i].Radius += circles[i].Speed * 10.0
|
||||
|
||||
if circles[i].Alpha > 1.0 {
|
||||
circles[i].Speed *= -1
|
||||
}
|
||||
|
||||
if circles[i].Alpha <= 0.0 {
|
||||
circles[i].Alpha = 0.0
|
||||
circles[i].Radius = float32(rl.GetRandomValue(10, 40))
|
||||
circles[i].Position.X = float32(rl.GetRandomValue(int32(circles[i].Radius), screenWidth-int32(circles[i].Radius)))
|
||||
circles[i].Position.Y = float32(rl.GetRandomValue(int32(circles[i].Radius), screenHeight-int32(circles[i].Radius)))
|
||||
circles[i].Color = colors[rl.GetRandomValue(0, 13)]
|
||||
circles[i].Speed = float32(rl.GetRandomValue(1, 100)) / 20000.0
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
for i := maxCircles - 1; i >= 0; i-- {
|
||||
rl.DrawCircleV(circles[i].Position, float32(circles[i].Radius), rl.Fade(circles[i].Color, circles[i].Alpha))
|
||||
}
|
||||
|
||||
// Draw time bar
|
||||
rl.DrawRectangle(20, screenHeight-20-12, screenWidth-40, 12, rl.LightGray)
|
||||
rl.DrawRectangle(20, screenHeight-20-12, timePlayed, 12, rl.Maroon)
|
||||
rl.DrawRectangleLines(20, screenHeight-20-12, screenWidth-40, 12, rl.Gray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadMusicStream(xm)
|
||||
|
||||
rl.CloseAudioDevice()
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [audio] example - music playing (streaming)")
|
||||
rl.InitAudioDevice()
|
||||
|
||||
music := rl.LoadMusicStream("guitar_noodling.ogg")
|
||||
pause := false
|
||||
|
||||
rl.PlayMusicStream(music)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateMusicStream(music) // Update music buffer with new stream data
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.StopMusicStream(music)
|
||||
rl.PlayMusicStream(music)
|
||||
}
|
||||
|
||||
// Pause/Resume music playing
|
||||
if rl.IsKeyPressed(rl.KeyP) {
|
||||
pause = !pause
|
||||
|
||||
if pause {
|
||||
rl.PauseMusicStream(music)
|
||||
} else {
|
||||
rl.ResumeMusicStream(music)
|
||||
}
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions (400 pixels)
|
||||
timePlayed := rl.GetMusicTimePlayed(music) / rl.GetMusicTimeLength(music) * 100 * 4
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.LightGray)
|
||||
|
||||
rl.DrawRectangle(200, 200, 400, 12, rl.LightGray)
|
||||
rl.DrawRectangle(200, 200, int32(timePlayed), 12, rl.Maroon)
|
||||
rl.DrawRectangleLines(200, 200, 400, 12, rl.Gray)
|
||||
|
||||
rl.DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.LightGray)
|
||||
rl.DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadMusicStream(music) // Unload music stream buffers from RAM
|
||||
rl.CloseAudioDevice() // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
maxSamples = 22050
|
||||
maxSamplesPerUpdate = 4096
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [audio] example - raw audio streaming")
|
||||
|
||||
rl.InitAudioDevice()
|
||||
|
||||
// Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
|
||||
stream := rl.LoadAudioStream(22050, 32, 1)
|
||||
|
||||
//// Fill audio stream with some samples (sine wave)
|
||||
data := make([]float32, maxSamples)
|
||||
|
||||
for i := 0; i < maxSamples; i++ {
|
||||
data[i] = float32(math.Sin(float64((2*rl.Pi*float32(i))/2) * rl.Deg2rad))
|
||||
}
|
||||
|
||||
// NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
|
||||
// for that reason, there is a clip everytime audio stream is looped
|
||||
rl.PlayAudioStream(stream)
|
||||
|
||||
totalSamples := int32(maxSamples)
|
||||
samplesLeft := int32(totalSamples)
|
||||
|
||||
position := rl.NewVector2(0, 0)
|
||||
|
||||
rl.SetTargetFPS(30)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Refill audio stream if required
|
||||
if rl.IsAudioStreamProcessed(stream) {
|
||||
numSamples := int32(0)
|
||||
if samplesLeft >= maxSamplesPerUpdate {
|
||||
numSamples = maxSamplesPerUpdate
|
||||
} else {
|
||||
numSamples = samplesLeft
|
||||
}
|
||||
|
||||
rl.UpdateAudioStream(stream, data[totalSamples-samplesLeft:], numSamples)
|
||||
|
||||
samplesLeft -= numSamples
|
||||
|
||||
// Reset samples feeding (loop audio)
|
||||
if samplesLeft <= 0 {
|
||||
samplesLeft = totalSamples
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, rl.LightGray)
|
||||
|
||||
// NOTE: Draw a part of the sine wave (only screen width)
|
||||
for i := 0; i < int(rl.GetScreenWidth()); i++ {
|
||||
position.X = float32(i)
|
||||
position.Y = 250 + 50*data[i]
|
||||
|
||||
rl.DrawPixelV(position, rl.Red)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadAudioStream(stream) // Close raw audio stream and delete buffers from RAM
|
||||
|
||||
rl.CloseAudioDevice() // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [audio] example - sound loading and playing")
|
||||
|
||||
rl.InitAudioDevice()
|
||||
|
||||
fxWav := rl.LoadSound("weird.wav")
|
||||
fxOgg := rl.LoadSound("tanatana.ogg")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.PlaySound(fxWav)
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
rl.PlaySound(fxOgg)
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.LightGray)
|
||||
rl.DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadSound(fxWav)
|
||||
rl.UnloadSound(fxOgg)
|
||||
|
||||
rl.CloseAudioDevice()
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
var (
|
||||
maxBuildings int = 100
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera")
|
||||
|
||||
player := rl.NewRectangle(400, 280, 40, 40)
|
||||
|
||||
buildings := make([]rl.Rectangle, maxBuildings)
|
||||
buildColors := make([]rl.Color, maxBuildings)
|
||||
|
||||
spacing := float32(0)
|
||||
|
||||
for i := 0; i < maxBuildings; i++ {
|
||||
r := rl.Rectangle{}
|
||||
r.Width = float32(rl.GetRandomValue(50, 200))
|
||||
r.Height = float32(rl.GetRandomValue(100, 800))
|
||||
r.Y = float32(screenHeight) - 130 - r.Height
|
||||
r.X = -6000 + spacing
|
||||
|
||||
spacing += r.Width
|
||||
|
||||
c := rl.NewColor(byte(rl.GetRandomValue(200, 240)), byte(rl.GetRandomValue(200, 240)), byte(rl.GetRandomValue(200, 250)), byte(255))
|
||||
|
||||
buildings[i] = r
|
||||
buildColors[i] = c
|
||||
}
|
||||
|
||||
camera := rl.Camera2D{}
|
||||
camera.Target = rl.NewVector2(float32(player.X+20), float32(player.Y+20))
|
||||
camera.Offset = rl.NewVector2(float32(screenWidth/2), float32(screenHeight/2))
|
||||
camera.Rotation = 0.0
|
||||
camera.Zoom = 1.0
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
player.X += 2 // Player movement
|
||||
} else if rl.IsKeyDown(rl.KeyLeft) {
|
||||
player.X -= 2 // Player movement
|
||||
}
|
||||
|
||||
// Camera target follows player
|
||||
camera.Target = rl.NewVector2(float32(player.X+20), float32(player.Y+20))
|
||||
|
||||
// Camera rotation controls
|
||||
if rl.IsKeyDown(rl.KeyA) {
|
||||
camera.Rotation--
|
||||
} else if rl.IsKeyDown(rl.KeyS) {
|
||||
camera.Rotation++
|
||||
}
|
||||
|
||||
// Limit camera rotation to 80 degrees (-40 to 40)
|
||||
if camera.Rotation > 40 {
|
||||
camera.Rotation = 40
|
||||
} else if camera.Rotation < -40 {
|
||||
camera.Rotation = -40
|
||||
}
|
||||
|
||||
// Camera zoom controls
|
||||
camera.Zoom += float32(rl.GetMouseWheelMove()) * 0.05
|
||||
|
||||
if camera.Zoom > 3.0 {
|
||||
camera.Zoom = 3.0
|
||||
} else if camera.Zoom < 0.1 {
|
||||
camera.Zoom = 0.1
|
||||
}
|
||||
|
||||
// Camera reset (zoom and rotation)
|
||||
if rl.IsKeyPressed(rl.KeyR) {
|
||||
camera.Zoom = 1.0
|
||||
camera.Rotation = 0.0
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode2D(camera)
|
||||
|
||||
rl.DrawRectangle(-6000, 320, 13000, 8000, rl.DarkGray)
|
||||
|
||||
for i := 0; i < maxBuildings; i++ {
|
||||
rl.DrawRectangleRec(buildings[i], buildColors[i])
|
||||
}
|
||||
|
||||
rl.DrawRectangleRec(player, rl.Red)
|
||||
|
||||
rl.DrawRectangle(int32(camera.Target.X), -500, 1, screenHeight*4, rl.Green)
|
||||
rl.DrawRectangle(-500, int32(camera.Target.Y), screenWidth*4, 1, rl.Green)
|
||||
|
||||
rl.EndMode2D()
|
||||
|
||||
rl.DrawText("SCREEN AREA", 640, 10, 20, rl.Red)
|
||||
|
||||
rl.DrawRectangle(0, 0, screenWidth, 5, rl.Red)
|
||||
rl.DrawRectangle(0, 5, 5, screenHeight-10, rl.Red)
|
||||
rl.DrawRectangle(screenWidth-5, 5, 5, screenHeight-10, rl.Red)
|
||||
rl.DrawRectangle(0, screenHeight-5, screenWidth, 5, rl.Red)
|
||||
|
||||
rl.DrawRectangle(10, 10, 250, 113, rl.Fade(rl.SkyBlue, 0.5))
|
||||
rl.DrawRectangleLines(10, 10, 250, 113, rl.Blue)
|
||||
|
||||
rl.DrawText("Free 2d camera controls:", 20, 20, 10, rl.Black)
|
||||
rl.DrawText("- Right/Left to move Offset", 40, 40, 10, rl.DarkGray)
|
||||
rl.DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, rl.DarkGray)
|
||||
rl.DrawText("- A / S to Rotate", 40, 80, 10, rl.DarkGray)
|
||||
rl.DrawText("- R to reset Zoom and Rotation", 40, 100, 10, rl.DarkGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const colorCount = 23
|
||||
|
||||
func main() {
|
||||
const screenWidth, screenHeight int32 = 800, 450
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raypaint")
|
||||
|
||||
// Colors to choose from
|
||||
var colors = [colorCount]rl.Color{
|
||||
rl.RayWhite, rl.Yellow, rl.Gold, rl.Orange, rl.Pink, rl.Red, rl.Maroon, rl.Green, rl.Lime, rl.DarkGreen,
|
||||
rl.SkyBlue, rl.Blue, rl.DarkBlue, rl.Purple, rl.Violet, rl.DarkPurple, rl.Beige, rl.Brown, rl.DarkBrown,
|
||||
rl.LightGray, rl.Gray, rl.DarkGray, rl.Black,
|
||||
}
|
||||
|
||||
// Define colorsRecs data (for every rectangle)
|
||||
var colorRecs = [colorCount]rl.Rectangle{}
|
||||
|
||||
for i := 0; i < colorCount; i++ {
|
||||
colorRecs[i].X = float32(10 + 30*i + 2*i)
|
||||
colorRecs[i].Y = 10
|
||||
colorRecs[i].Width = 30
|
||||
colorRecs[i].Height = 30
|
||||
}
|
||||
|
||||
colorSelected := 0
|
||||
colorSelectedPrev := colorSelected
|
||||
colorMouseHover := 0
|
||||
brushSize := 20
|
||||
|
||||
var btnSaveRec = rl.Rectangle{750, 10, 40, 30}
|
||||
btnSaveMouseHover := false
|
||||
showSaveMessage := false
|
||||
saveMessageCounter := 0
|
||||
|
||||
checkSaveHover := func() rl.Color {
|
||||
if btnSaveMouseHover {
|
||||
return rl.Red
|
||||
}
|
||||
return rl.Black
|
||||
}
|
||||
|
||||
// Create a RenderTexture2D to use as a canvas
|
||||
var target rl.RenderTexture2D = rl.LoadRenderTexture(screenWidth, screenHeight)
|
||||
|
||||
// Clear render texture before entering the game loop
|
||||
rl.BeginTextureMode(target)
|
||||
rl.ClearBackground(colors[0])
|
||||
rl.EndTextureMode()
|
||||
|
||||
rl.SetTargetFPS(120)
|
||||
|
||||
// Main game loop
|
||||
for !rl.WindowShouldClose() {
|
||||
mousePos := rl.GetMousePosition()
|
||||
|
||||
// Move between colors with keys
|
||||
if rl.IsKeyPressed(rl.KeyRight) {
|
||||
colorSelected++
|
||||
} else if rl.IsKeyPressed(rl.KeyLeft) {
|
||||
colorSelected--
|
||||
}
|
||||
|
||||
if colorSelected >= colorCount {
|
||||
colorSelected = colorCount - 1
|
||||
} else if colorSelected < 0 {
|
||||
colorSelected = 0
|
||||
}
|
||||
|
||||
// Choose color with mouse
|
||||
for i := 0; i < colorCount; i++ {
|
||||
if rl.CheckCollisionPointRec(mousePos, colorRecs[i]) {
|
||||
colorMouseHover = i
|
||||
break
|
||||
} else {
|
||||
colorMouseHover = -1
|
||||
}
|
||||
}
|
||||
|
||||
if colorMouseHover >= 0 && rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
colorSelected = colorMouseHover
|
||||
colorSelectedPrev = colorSelected
|
||||
}
|
||||
|
||||
// Change brush size
|
||||
brushSize += int(rl.GetMouseWheelMove() * 5)
|
||||
if brushSize < 2 {
|
||||
brushSize = 2
|
||||
}
|
||||
|
||||
if brushSize > 50 {
|
||||
brushSize = 50
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyC) {
|
||||
// Clear render texture to clear color
|
||||
rl.BeginTextureMode(target)
|
||||
rl.ClearBackground(colors[0])
|
||||
rl.EndTextureMode()
|
||||
}
|
||||
|
||||
if rl.IsMouseButtonDown(rl.MouseLeftButton) || rl.GetGestureDetected() == rl.GestureDrag {
|
||||
// Clear render texture to clear color
|
||||
rl.BeginTextureMode(target)
|
||||
|
||||
if mousePos.Y > 50 {
|
||||
rl.DrawCircle(int32(mousePos.X), int32(mousePos.Y), float32(brushSize), colors[colorSelected])
|
||||
}
|
||||
|
||||
rl.EndTextureMode()
|
||||
}
|
||||
|
||||
if rl.IsMouseButtonDown(rl.MouseRightButton) {
|
||||
colorSelected = 0
|
||||
|
||||
// Erase circle from render texture
|
||||
rl.BeginTextureMode(target)
|
||||
|
||||
if mousePos.Y > 50 {
|
||||
rl.DrawCircle(int32(mousePos.X), int32(mousePos.Y), float32(brushSize), colors[0])
|
||||
}
|
||||
|
||||
rl.EndTextureMode()
|
||||
} else {
|
||||
colorSelected = colorSelectedPrev
|
||||
}
|
||||
|
||||
if rl.CheckCollisionPointRec(mousePos, btnSaveRec) {
|
||||
btnSaveMouseHover = true
|
||||
} else {
|
||||
btnSaveMouseHover = false
|
||||
}
|
||||
|
||||
if btnSaveMouseHover && rl.IsMouseButtonReleased(rl.MouseLeftButton) || rl.IsKeyPressed(rl.KeyS) {
|
||||
image := rl.LoadImageFromTexture(target.Texture)
|
||||
rl.ImageFlipVertical(*&image)
|
||||
rl.ExportImage(*image, "export.png")
|
||||
rl.UnloadImage(image)
|
||||
showSaveMessage = true
|
||||
}
|
||||
|
||||
if showSaveMessage {
|
||||
// On saving, show a full screen message for 2 seconds
|
||||
saveMessageCounter++
|
||||
if saveMessageCounter > 240 {
|
||||
showSaveMessage = false
|
||||
saveMessageCounter = 0
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
rl.DrawTextureRec(target.Texture, rl.Rectangle{0, 0, float32(target.Texture.Width), float32(-target.Texture.Height)}, rl.Vector2{0, 0}, rl.White)
|
||||
|
||||
if mousePos.Y > 50 {
|
||||
if rl.IsMouseButtonDown(rl.MouseRightButton) {
|
||||
rl.DrawCircleLines(int32(mousePos.X), int32(mousePos.Y), float32(brushSize), rl.Gray)
|
||||
} else {
|
||||
rl.DrawCircle(rl.GetMouseX(), rl.GetMouseY(), float32(brushSize), colors[colorSelected])
|
||||
}
|
||||
}
|
||||
|
||||
// Draw top panel
|
||||
rl.DrawRectangle(0, 0, int32(rl.GetScreenWidth()), 50, rl.RayWhite)
|
||||
rl.DrawLine(0, 50, int32(rl.GetScreenWidth()), 50, rl.LightGray)
|
||||
|
||||
// Draw color selection rectangles
|
||||
for i := 0; i < colorCount; i++ {
|
||||
rl.DrawRectangleRec(colorRecs[i], colors[i])
|
||||
}
|
||||
|
||||
rl.DrawRectangleLines(10, 10, 30, 30, rl.LightGray)
|
||||
|
||||
if colorMouseHover >= 0 {
|
||||
rl.DrawRectangleRec(colorRecs[colorMouseHover], rl.Fade(rl.White, 0.0))
|
||||
}
|
||||
|
||||
rl.DrawRectangleLinesEx(rl.Rectangle{
|
||||
colorRecs[colorSelected].X - 2, colorRecs[colorSelected].Y - 2, colorRecs[colorSelected].Width + 4, colorRecs[colorSelected].Height + 4,
|
||||
}, 2, rl.Black)
|
||||
|
||||
// Draw save image button
|
||||
rl.DrawRectangleLinesEx(btnSaveRec, 2, checkSaveHover())
|
||||
rl.DrawText("SAVE!", 755, 20, 10, checkSaveHover())
|
||||
|
||||
if showSaveMessage {
|
||||
rl.DrawRectangle(0, 0, int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()), rl.Fade(rl.RayWhite, 0.8))
|
||||
rl.DrawRectangle(0, 150, int32(rl.GetScreenWidth()), 80, rl.Black)
|
||||
rl.DrawText("IMAGE SAVED: export.png", 150, 180, 20, rl.RayWhite)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
rl.UnloadRenderTexture(target)
|
||||
|
||||
rl.CloseWindow()
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
maxColumns = 20
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - 3d camera first person")
|
||||
|
||||
camera := rl.Camera3D{}
|
||||
camera.Position = rl.NewVector3(4.0, 2.0, 4.0)
|
||||
camera.Target = rl.NewVector3(0.0, 1.8, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 60.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
// Generates some random columns
|
||||
heights := make([]float32, maxColumns)
|
||||
positions := make([]rl.Vector3, maxColumns)
|
||||
colors := make([]rl.Color, maxColumns)
|
||||
|
||||
for i := 0; i < maxColumns; i++ {
|
||||
heights[i] = float32(rl.GetRandomValue(1, 12))
|
||||
positions[i] = rl.NewVector3(float32(rl.GetRandomValue(-15, 15)), heights[i]/2, float32(rl.GetRandomValue(-15, 15)))
|
||||
colors[i] = rl.NewColor(uint8(rl.GetRandomValue(20, 255)), uint8(rl.GetRandomValue(10, 55)), 30, 255)
|
||||
}
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFirstPerson) // Set a first person camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawPlane(rl.NewVector3(0.0, 0.0, 0.0), rl.NewVector2(32.0, 32.0), rl.LightGray) // Draw ground
|
||||
rl.DrawCube(rl.NewVector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Blue) // Draw a blue wall
|
||||
rl.DrawCube(rl.NewVector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Lime) // Draw a green wall
|
||||
rl.DrawCube(rl.NewVector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, rl.Gold) // Draw a yellow wall
|
||||
|
||||
// Draw some cubes around
|
||||
for i := 0; i < maxColumns; i++ {
|
||||
rl.DrawCube(positions[i], 2.0, heights[i], 2.0, colors[i])
|
||||
rl.DrawCubeWires(positions[i], 2.0, heights[i], 2.0, rl.Maroon)
|
||||
}
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawRectangle(10, 10, 220, 70, rl.Fade(rl.SkyBlue, 0.5))
|
||||
rl.DrawRectangleLines(10, 10, 220, 70, rl.Blue)
|
||||
|
||||
rl.DrawText("First person camera default controls:", 20, 20, 10, rl.Black)
|
||||
rl.DrawText("- Move with keys: W, A, S, D", 40, 40, 10, rl.DarkGray)
|
||||
rl.DrawText("- Mouse move to look around", 40, 60, 10, rl.DarkGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - 3d camera free")
|
||||
|
||||
camera := rl.Camera3D{}
|
||||
camera.Position = rl.NewVector3(10.0, 10.0, 10.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFree) // Set a free camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
if rl.IsKeyDown(rl.KeyZ) {
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
|
||||
rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
|
||||
|
||||
rl.DrawGrid(10, 1.0)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawRectangle(10, 10, 320, 133, rl.Fade(rl.SkyBlue, 0.5))
|
||||
rl.DrawRectangleLines(10, 10, 320, 133, rl.Blue)
|
||||
|
||||
rl.DrawText("Free camera default controls:", 20, 20, 10, rl.Black)
|
||||
rl.DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, rl.DarkGray)
|
||||
rl.DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, rl.DarkGray)
|
||||
rl.DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, rl.DarkGray)
|
||||
rl.DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, rl.DarkGray)
|
||||
rl.DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, rl.DarkGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - 3d mode")
|
||||
|
||||
camera := rl.Camera3D{}
|
||||
camera.Position = rl.NewVector3(0.0, 10.0, 10.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
|
||||
rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
|
||||
|
||||
rl.DrawGrid(10, 1.0)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawText("Welcome to the third dimension!", 10, 40, 20, rl.DarkGray)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")
|
||||
|
||||
camera := rl.Camera3D{}
|
||||
camera.Position = rl.NewVector3(10.0, 10.0, 10.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
cubePosition := rl.NewVector3(0.0, 1.0, 0.0)
|
||||
cubeSize := rl.NewVector3(2.0, 2.0, 2.0)
|
||||
|
||||
var ray rl.Ray
|
||||
var collision rl.RayCollision
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFree) // Set a free camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
if !collision.Hit {
|
||||
ray = rl.GetMouseRay(rl.GetMousePosition(), camera)
|
||||
|
||||
// Check collision between ray and box
|
||||
min := rl.NewVector3(cubePosition.X-cubeSize.X/2, cubePosition.Y-cubeSize.Y/2, cubePosition.Z-cubeSize.Z/2)
|
||||
max := rl.NewVector3(cubePosition.X+cubeSize.X/2, cubePosition.Y+cubeSize.Y/2, cubePosition.Z+cubeSize.Z/2)
|
||||
collision = rl.GetRayCollisionBox(ray, rl.NewBoundingBox(min, max))
|
||||
} else {
|
||||
collision.Hit = false
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
if collision.Hit {
|
||||
rl.DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, rl.Red)
|
||||
rl.DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, rl.Maroon)
|
||||
|
||||
rl.DrawCubeWires(cubePosition, cubeSize.X+0.2, cubeSize.Y+0.2, cubeSize.Z+0.2, rl.Green)
|
||||
} else {
|
||||
rl.DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, rl.Gray)
|
||||
rl.DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, rl.DarkGray)
|
||||
}
|
||||
|
||||
rl.DrawRay(ray, rl.Maroon)
|
||||
|
||||
rl.DrawGrid(10, 1.0)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawText("Try selecting the box with mouse!", 240, 10, 20, rl.DarkGray)
|
||||
|
||||
if collision.Hit {
|
||||
rl.DrawText("BOX SELECTED", (screenWidth-rl.MeasureText("BOX SELECTED", 30))/2, int32(float32(screenHeight)*0.1), 30, rl.Green)
|
||||
}
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package main
|
||||
|
||||
import "github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
func main() {
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
rl.InitWindow(800, 450, "raylib [core] example - basic window")
|
||||
|
||||
//rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - color selection (collision detection)")
|
||||
|
||||
colors := [21]rl.Color{
|
||||
rl.DarkGray, rl.Maroon, rl.Orange, rl.DarkGreen, rl.DarkBlue, rl.DarkPurple,
|
||||
rl.DarkBrown, rl.Gray, rl.Red, rl.Gold, rl.Lime, rl.Blue, rl.Violet, rl.Brown,
|
||||
rl.LightGray, rl.Pink, rl.Yellow, rl.Green, rl.SkyBlue, rl.Purple, rl.Beige,
|
||||
}
|
||||
|
||||
colorsRecs := make([]rl.Rectangle, 21) // Rectangles array
|
||||
|
||||
// Fills colorsRecs data (for every rectangle)
|
||||
for i := 0; i < 21; i++ {
|
||||
r := rl.Rectangle{}
|
||||
r.X = float32(20 + 100*(i%7) + 10*(i%7))
|
||||
r.Y = float32(60 + 100*(i/7) + 10*(i/7))
|
||||
r.Width = 100
|
||||
r.Height = 100
|
||||
|
||||
colorsRecs[i] = r
|
||||
}
|
||||
|
||||
selected := make([]bool, 21) // Selected rectangles indicator
|
||||
|
||||
mousePoint := rl.Vector2{}
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
mousePoint = rl.GetMousePosition()
|
||||
|
||||
for i := 0; i < 21; i++ { // Iterate along all the rectangles
|
||||
if rl.CheckCollisionPointRec(mousePoint, colorsRecs[i]) {
|
||||
colors[i].A = 120
|
||||
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
selected[i] = !selected[i]
|
||||
}
|
||||
} else {
|
||||
colors[i].A = 255
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
for i := 0; i < 21; i++ { // Draw all rectangles
|
||||
rl.DrawRectangleRec(colorsRecs[i], colors[i])
|
||||
|
||||
// Draw four rectangles around selected rectangle
|
||||
if selected[i] {
|
||||
rl.DrawRectangle(int32(colorsRecs[i].X), int32(colorsRecs[i].Y), 100, 10, rl.RayWhite) // Square top rectangle
|
||||
rl.DrawRectangle(int32(colorsRecs[i].X), int32(colorsRecs[i].Y), 10, 100, rl.RayWhite) // Square left rectangle
|
||||
rl.DrawRectangle(int32(colorsRecs[i].X+90), int32(colorsRecs[i].Y), 10, 100, rl.RayWhite) // Square right rectangle
|
||||
rl.DrawRectangle(int32(colorsRecs[i].X), int32(colorsRecs[i].Y)+90, 100, 10, rl.RayWhite) // Square bottom rectangle
|
||||
}
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
var count int
|
||||
var droppedFiles []string
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsFileDropped() {
|
||||
droppedFiles = rl.LoadDroppedFiles()
|
||||
count = len(droppedFiles)
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
if count == 0 {
|
||||
rl.DrawText("Drop your files to this window!", 100, 40, 20, rl.DarkGray)
|
||||
} else {
|
||||
rl.DrawText("Dropped files:", 100, 40, 20, rl.DarkGray)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
if i%2 == 0 {
|
||||
rl.DrawRectangle(0, int32(85+40*i), screenWidth, 40, rl.Fade(rl.LightGray, 0.5))
|
||||
} else {
|
||||
rl.DrawRectangle(0, int32(85+40*i), screenWidth, 40, rl.Fade(rl.LightGray, 0.3))
|
||||
}
|
||||
|
||||
rl.DrawText(droppedFiles[i], 120, int32(100+i*40), 10, rl.Gray)
|
||||
}
|
||||
|
||||
rl.DrawText("Drop new files...", 100, int32(150+count*40), 20, rl.DarkGray)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadDroppedFiles()
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
var (
|
||||
maxGestureStrings int = 20
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection")
|
||||
|
||||
touchPosition := rl.NewVector2(0, 0)
|
||||
touchArea := rl.NewRectangle(220, 10, float32(screenWidth)-230, float32(screenHeight)-20)
|
||||
|
||||
gestureStrings := make([]string, 0)
|
||||
|
||||
currentGesture := rl.GestureNone
|
||||
lastGesture := rl.GestureNone
|
||||
|
||||
//rl.SetGesturesEnabled(uint32(rl.GestureHold | rl.GestureDrag)) // Enable only some gestures to be detected
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
lastGesture = currentGesture
|
||||
currentGesture = rl.GetGestureDetected()
|
||||
touchPosition = rl.GetTouchPosition(0)
|
||||
|
||||
if rl.CheckCollisionPointRec(touchPosition, touchArea) && currentGesture != rl.GestureNone {
|
||||
if currentGesture != lastGesture {
|
||||
switch currentGesture {
|
||||
case rl.GestureTap:
|
||||
gestureStrings = append(gestureStrings, "GESTURE TAP")
|
||||
case rl.GestureDoubletap:
|
||||
gestureStrings = append(gestureStrings, "GESTURE DOUBLETAP")
|
||||
case rl.GestureHold:
|
||||
gestureStrings = append(gestureStrings, "GESTURE HOLD")
|
||||
case rl.GestureDrag:
|
||||
gestureStrings = append(gestureStrings, "GESTURE DRAG")
|
||||
case rl.GestureSwipeRight:
|
||||
gestureStrings = append(gestureStrings, "GESTURE SWIPE RIGHT")
|
||||
case rl.GestureSwipeLeft:
|
||||
gestureStrings = append(gestureStrings, "GESTURE SWIPE LEFT")
|
||||
case rl.GestureSwipeUp:
|
||||
gestureStrings = append(gestureStrings, "GESTURE SWIPE UP")
|
||||
case rl.GestureSwipeDown:
|
||||
gestureStrings = append(gestureStrings, "GESTURE SWIPE DOWN")
|
||||
case rl.GesturePinchIn:
|
||||
gestureStrings = append(gestureStrings, "GESTURE PINCH IN")
|
||||
case rl.GesturePinchOut:
|
||||
gestureStrings = append(gestureStrings, "GESTURE PINCH OUT")
|
||||
}
|
||||
|
||||
if len(gestureStrings) >= maxGestureStrings {
|
||||
gestureStrings = make([]string, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawRectangleRec(touchArea, rl.Gray)
|
||||
rl.DrawRectangle(225, 15, screenWidth-240, screenHeight-30, rl.RayWhite)
|
||||
|
||||
rl.DrawText("GESTURES TEST AREA", screenWidth-270, screenHeight-40, 20, rl.Fade(rl.Gray, 0.5))
|
||||
|
||||
for i := 0; i < len(gestureStrings); i++ {
|
||||
if i%2 == 0 {
|
||||
rl.DrawRectangle(10, int32(30+20*i), 200, 20, rl.Fade(rl.LightGray, 0.5))
|
||||
} else {
|
||||
rl.DrawRectangle(10, int32(30+20*i), 200, 20, rl.Fade(rl.LightGray, 0.3))
|
||||
}
|
||||
|
||||
if i < len(gestureStrings)-1 {
|
||||
rl.DrawText(gestureStrings[i], 35, int32(36+20*i), 10, rl.DarkGray)
|
||||
} else {
|
||||
rl.DrawText(gestureStrings[i], 35, int32(36+20*i), 10, rl.Maroon)
|
||||
}
|
||||
}
|
||||
|
||||
rl.DrawRectangleLines(10, 29, 200, screenHeight-50, rl.Gray)
|
||||
rl.DrawText("DETECTED GESTURES", 50, 15, 10, rl.Gray)
|
||||
|
||||
if currentGesture != rl.GestureNone {
|
||||
rl.DrawCircleV(touchPosition, 30, rl.Maroon)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
xbox360NameID = "Xbox 360 Controller"
|
||||
ps3NameID = "PLAYSTATION(R)3 Controller"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint) // Set MSAA 4X hint before windows creation
|
||||
|
||||
rl.InitWindow(800, 450, "raylib [core] example - gamepad input")
|
||||
|
||||
texPs3Pad := rl.LoadTexture("ps3.png")
|
||||
texXboxPad := rl.LoadTexture("xbox.png")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
if rl.IsGamepadAvailable(rl.GamepadPlayer1) {
|
||||
rl.DrawText(fmt.Sprintf("GP1: %s", rl.GetGamepadName(rl.GamepadPlayer1)), 10, 10, 10, rl.Black)
|
||||
|
||||
if rl.GetGamepadName(rl.GamepadPlayer1) == xbox360NameID {
|
||||
rl.DrawTexture(texXboxPad, 0, 0, rl.DarkGray)
|
||||
|
||||
// Draw buttons: xbox home
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonHome) {
|
||||
rl.DrawCircle(394, 89, 19, rl.Red)
|
||||
}
|
||||
|
||||
// Draw buttons: basic
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonStart) {
|
||||
rl.DrawCircle(436, 150, 9, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonSelect) {
|
||||
rl.DrawCircle(352, 150, 9, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonX) {
|
||||
rl.DrawCircle(501, 151, 15, rl.Blue)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonA) {
|
||||
rl.DrawCircle(536, 187, 15, rl.Lime)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonB) {
|
||||
rl.DrawCircle(572, 151, 15, rl.Maroon)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonY) {
|
||||
rl.DrawCircle(536, 115, 15, rl.Gold)
|
||||
}
|
||||
|
||||
// Draw buttons: d-pad
|
||||
rl.DrawRectangle(317, 202, 19, 71, rl.Black)
|
||||
rl.DrawRectangle(293, 228, 69, 19, rl.Black)
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonUp) {
|
||||
rl.DrawRectangle(317, 202, 19, 26, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonDown) {
|
||||
rl.DrawRectangle(317, 202+45, 19, 26, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonLeft) {
|
||||
rl.DrawRectangle(292, 228, 25, 19, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonRight) {
|
||||
rl.DrawRectangle(292+44, 228, 26, 19, rl.Red)
|
||||
}
|
||||
|
||||
// Draw buttons: left-right back
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonLb) {
|
||||
rl.DrawCircle(259, 61, 20, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadXboxButtonRb) {
|
||||
rl.DrawCircle(536, 61, 20, rl.Red)
|
||||
}
|
||||
|
||||
// Draw axis: left joystick
|
||||
rl.DrawCircle(259, 152, 39, rl.Black)
|
||||
rl.DrawCircle(259, 152, 34, rl.LightGray)
|
||||
rl.DrawCircle(int32(259+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisLeftX)*20)),
|
||||
int32(152-(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisLeftY)*20)), 25, rl.Black)
|
||||
|
||||
// Draw axis: right joystick
|
||||
rl.DrawCircle(461, 237, 38, rl.Black)
|
||||
rl.DrawCircle(461, 237, 33, rl.LightGray)
|
||||
rl.DrawCircle(int32(461+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisRightX)*20)),
|
||||
int32(237-(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisRightY)*20)), 25, rl.Black)
|
||||
|
||||
// Draw axis: left-right triggers
|
||||
rl.DrawRectangle(170, 30, 15, 70, rl.Gray)
|
||||
rl.DrawRectangle(604, 30, 15, 70, rl.Gray)
|
||||
rl.DrawRectangle(170, 30, 15, int32(((1.0+rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisLt))/2.0)*70), rl.Red)
|
||||
rl.DrawRectangle(604, 30, 15, int32(((1.0+rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadXboxAxisRt))/2.0)*70), rl.Red)
|
||||
|
||||
} else if rl.GetGamepadName(rl.GamepadPlayer1) == ps3NameID {
|
||||
rl.DrawTexture(texPs3Pad, 0, 0, rl.DarkGray)
|
||||
|
||||
// Draw buttons: ps
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonPs) {
|
||||
rl.DrawCircle(396, 222, 13, rl.Red)
|
||||
}
|
||||
|
||||
// Draw buttons: basic
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonSelect) {
|
||||
rl.DrawRectangle(328, 170, 32, 13, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonStart) {
|
||||
rl.DrawTriangle(rl.NewVector2(436, 168), rl.NewVector2(436, 185), rl.NewVector2(464, 177), rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonTriangle) {
|
||||
rl.DrawCircle(557, 144, 13, rl.Lime)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonCircle) {
|
||||
rl.DrawCircle(586, 173, 13, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonCross) {
|
||||
rl.DrawCircle(557, 203, 13, rl.Violet)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonSquare) {
|
||||
rl.DrawCircle(527, 173, 13, rl.Pink)
|
||||
}
|
||||
|
||||
// Draw buttons: d-pad
|
||||
rl.DrawRectangle(225, 132, 24, 84, rl.Black)
|
||||
rl.DrawRectangle(195, 161, 84, 25, rl.Black)
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonUp) {
|
||||
rl.DrawRectangle(225, 132, 24, 29, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonDown) {
|
||||
rl.DrawRectangle(225, 132+54, 24, 30, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonLeft) {
|
||||
rl.DrawRectangle(195, 161, 30, 25, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonRight) {
|
||||
rl.DrawRectangle(195+54, 161, 30, 25, rl.Red)
|
||||
}
|
||||
|
||||
// Draw buttons: left-right back buttons
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonL1) {
|
||||
rl.DrawCircle(239, 82, 20, rl.Red)
|
||||
}
|
||||
if rl.IsGamepadButtonDown(rl.GamepadPlayer1, rl.GamepadPs3ButtonR1) {
|
||||
rl.DrawCircle(557, 82, 20, rl.Red)
|
||||
}
|
||||
|
||||
// Draw axis: left joystick
|
||||
rl.DrawCircle(319, 255, 35, rl.Black)
|
||||
rl.DrawCircle(319, 255, 31, rl.LightGray)
|
||||
rl.DrawCircle(int32(319+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisLeftX)*20)),
|
||||
int32(255+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisLeftY)*20)), 25, rl.Black)
|
||||
|
||||
// Draw axis: right joystick
|
||||
rl.DrawCircle(475, 255, 35, rl.Black)
|
||||
rl.DrawCircle(475, 255, 31, rl.LightGray)
|
||||
rl.DrawCircle(int32(475+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisRightX)*20)),
|
||||
int32(255+(rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisRightY)*20)), 25, rl.Black)
|
||||
|
||||
// Draw axis: left-right triggers
|
||||
rl.DrawRectangle(169, 48, 15, 70, rl.Gray)
|
||||
rl.DrawRectangle(611, 48, 15, 70, rl.Gray)
|
||||
rl.DrawRectangle(169, 48, 15, int32(((1.0-rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisL2))/2.0)*70), rl.Red)
|
||||
rl.DrawRectangle(611, 48, 15, int32(((1.0-rl.GetGamepadAxisMovement(rl.GamepadPlayer1, rl.GamepadPs3AxisR2))/2.0)*70), rl.Red)
|
||||
} else {
|
||||
rl.DrawText("- GENERIC GAMEPAD -", 280, 180, 20, rl.Gray)
|
||||
|
||||
// TODO: Draw generic gamepad
|
||||
}
|
||||
|
||||
rl.DrawText(fmt.Sprintf("DETECTED AXIS [%d]:", rl.GetGamepadAxisCount(rl.GamepadPlayer1)), 10, 50, 10, rl.Maroon)
|
||||
|
||||
for i := int32(0); i < rl.GetGamepadAxisCount(rl.GamepadPlayer1); i++ {
|
||||
rl.DrawText(fmt.Sprintf("AXIS %d: %.02f", i, rl.GetGamepadAxisMovement(rl.GamepadPlayer1, i)), 20, 70+20*i, 10, rl.DarkGray)
|
||||
}
|
||||
|
||||
if rl.GetGamepadButtonPressed() != -1 {
|
||||
rl.DrawText(fmt.Sprintf("DETECTED BUTTON: %d", rl.GetGamepadButtonPressed()), 10, 430, 10, rl.Red)
|
||||
} else {
|
||||
rl.DrawText("DETECTED BUTTON: NONE", 10, 430, 10, rl.Gray)
|
||||
}
|
||||
} else {
|
||||
rl.DrawText("GP1: NOT DETECTED", 10, 10, 10, rl.Gray)
|
||||
|
||||
rl.DrawTexture(texXboxPad, 0, 0, rl.LightGray)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(texPs3Pad)
|
||||
rl.UnloadTexture(texXboxPad)
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 16 KiB |
|
@ -1,41 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input")
|
||||
|
||||
ballPosition := rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)/2)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
ballPosition.X += 0.8
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyLeft) {
|
||||
ballPosition.X -= 0.8
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyUp) {
|
||||
ballPosition.Y -= 0.8
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyDown) {
|
||||
ballPosition.Y += 0.8
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("move the ball with arrow keys", 10, 10, 20, rl.DarkGray)
|
||||
rl.DrawCircleV(ballPosition, 50, rl.Maroon)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - mouse input")
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
ballColor := rl.DarkBlue
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
ballPosition := rl.GetMousePosition()
|
||||
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
ballColor = rl.Maroon
|
||||
} else if rl.IsMouseButtonPressed(rl.MouseMiddleButton) {
|
||||
ballColor = rl.Lime
|
||||
} else if rl.IsMouseButtonPressed(rl.MouseRightButton) {
|
||||
ballColor = rl.DarkBlue
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.DrawCircleV(ballPosition, 40, ballColor)
|
||||
|
||||
rl.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.DarkGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel")
|
||||
|
||||
boxPositionY := screenHeight/2 - 40
|
||||
scrollSpeed := int32(4) // Scrolling speed in pixels
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
boxPositionY -= int32(rl.GetMouseWheelMove()) * scrollSpeed
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawRectangle(screenWidth/2-40, boxPositionY, 80, 80, rl.Maroon)
|
||||
|
||||
rl.DrawText("Use mouse wheel to move the square up and down!", 10, 10, 20, rl.Gray)
|
||||
rl.DrawText(fmt.Sprintf("Box position Y: %d", boxPositionY), 10, 40, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - generate random values")
|
||||
|
||||
framesCounter := 0 // Variable used to count frames
|
||||
randValue := rl.GetRandomValue(-8, 5) // Get a random integer number between -8 and 5 (both included)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
framesCounter++
|
||||
|
||||
// Every two seconds (120 frames) a new random value is generated
|
||||
if ((framesCounter / 120) % 2) == 1 {
|
||||
randValue = rl.GetRandomValue(-8, 5)
|
||||
framesCounter = 0
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, rl.Maroon)
|
||||
|
||||
rl.DrawText(fmt.Sprintf("%d", randValue), 360, 180, 80, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(10.0, 10.0, 10.0) // Camera position
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0) // Camera looking at point
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0) // Camera up vector (rotation towards target)
|
||||
camera.Fovy = 45.0 // Camera field-of-view Y
|
||||
|
||||
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
||||
cubeScreenPosition := rl.Vector2{}
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFree) // Set a free camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
// Calculate cube screen space position (with a little offset to be in top)
|
||||
cubeScreenPosition = rl.GetWorldToScreen(rl.NewVector3(cubePosition.X, cubePosition.Y+2.5, cubePosition.Z), camera)
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
|
||||
rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
|
||||
|
||||
rl.DrawGrid(10, 1.0)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawText("Enemy: 100 / 100", int32(cubeScreenPosition.X)-rl.MeasureText("Enemy: 100 / 100", 20)/2, int32(cubeScreenPosition.Y), 20, rl.Black)
|
||||
rl.DrawText("Text is always on top of the cube", (screenWidth-rl.MeasureText("Text is always on top of the cube", 20))/2, 25, 20, rl.Gray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/easings"
|
||||
"github.com/gen2brain/raylib-go/raygui"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [easings] example - easings")
|
||||
|
||||
currentTime := 0
|
||||
duration := float32(60)
|
||||
startPositionX := float32(screenWidth) / 4
|
||||
finalPositionX := startPositionX * 3
|
||||
currentPositionX := startPositionX
|
||||
|
||||
ballPosition := rl.NewVector2(startPositionX, float32(screenHeight)/2)
|
||||
|
||||
comboActive := 0
|
||||
comboLastActive := 0
|
||||
|
||||
easingTypes := []string{"SineIn", "SineOut", "SineInOut", "BounceIn", "BounceOut", "BounceInOut", "BackIn", "BackOut", "BackInOut"}
|
||||
ease := easingTypes[comboActive]
|
||||
|
||||
//rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyDown(rl.KeyR) {
|
||||
currentTime = 0
|
||||
currentPositionX = startPositionX
|
||||
ballPosition.X = currentPositionX
|
||||
}
|
||||
|
||||
if comboLastActive != comboActive {
|
||||
currentTime = 0
|
||||
currentPositionX = startPositionX
|
||||
ballPosition.X = currentPositionX
|
||||
|
||||
ease = easingTypes[comboActive]
|
||||
comboLastActive = comboActive
|
||||
}
|
||||
|
||||
if currentPositionX < finalPositionX {
|
||||
switch ease {
|
||||
case "SineIn":
|
||||
currentPositionX = easings.SineIn(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "SineOut":
|
||||
currentPositionX = easings.SineOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "SineInOut":
|
||||
currentPositionX = easings.SineInOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BounceIn":
|
||||
currentPositionX = easings.BounceIn(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BounceOut":
|
||||
currentPositionX = easings.BounceOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BounceInOut":
|
||||
currentPositionX = easings.BounceInOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BackIn":
|
||||
currentPositionX = easings.BackIn(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BackOut":
|
||||
currentPositionX = easings.BackOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
case "BackInOut":
|
||||
currentPositionX = easings.BackInOut(float32(currentTime), startPositionX, finalPositionX-startPositionX, duration)
|
||||
}
|
||||
|
||||
ballPosition.X = currentPositionX
|
||||
currentTime++
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raygui.Label(rl.NewRectangle(20, 20, 200, 20), "Easing Type:")
|
||||
comboActive = raygui.ComboBox(rl.NewRectangle(20, 40, 200, 20), easingTypes, comboActive)
|
||||
|
||||
raygui.Label(rl.NewRectangle(20, 80, 200, 20), "Press R to reset")
|
||||
|
||||
rl.DrawCircleV(ballPosition, 50, rl.Maroon)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,277 +0,0 @@
|
|||
package main
|
||||
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib - sample game: arkanoid
|
||||
*
|
||||
* Sample game Marc Palau and Ramon Santamaria
|
||||
*
|
||||
* This game has been created using raylib v1.3 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Ported to raylib-go by Nehpe (@nehpe), July 2019
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
PLAYER_MAX_LIFE = 5
|
||||
LINES_OF_BRICKS = 5
|
||||
BRICKS_PER_LINE = 20
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
position rl.Vector2
|
||||
size rl.Vector2
|
||||
life int
|
||||
}
|
||||
|
||||
type Ball struct {
|
||||
position rl.Vector2
|
||||
speed rl.Vector2
|
||||
radius float32
|
||||
active bool
|
||||
}
|
||||
|
||||
type Brick struct {
|
||||
position rl.Vector2
|
||||
active bool
|
||||
}
|
||||
|
||||
const (
|
||||
screenWidth = 800
|
||||
screenHeight = 450
|
||||
)
|
||||
|
||||
type Game struct {
|
||||
gameOver bool
|
||||
pause bool
|
||||
player Player
|
||||
ball Ball
|
||||
brick [LINES_OF_BRICKS][BRICKS_PER_LINE]Brick
|
||||
brickSize rl.Vector2
|
||||
}
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(screenWidth, screenHeight, "sample game: arkanoid")
|
||||
|
||||
// Init game
|
||||
game := NewGame()
|
||||
game.gameOver = true
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
game.Update()
|
||||
|
||||
game.Draw()
|
||||
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
|
||||
}
|
||||
|
||||
// For android
|
||||
func init() {
|
||||
rl.SetCallbackFunc(main)
|
||||
}
|
||||
|
||||
// NewGame - Create a new game instance
|
||||
func NewGame() (g Game) {
|
||||
g.Init()
|
||||
return
|
||||
}
|
||||
|
||||
// Init - initialize game
|
||||
func (g *Game) Init() {
|
||||
g.brickSize = rl.Vector2{float32(rl.GetScreenWidth() / BRICKS_PER_LINE), 40}
|
||||
|
||||
// Initialize player
|
||||
g.player.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight * 7 / 8)}
|
||||
g.player.size = rl.Vector2{float32(screenWidth / 10), 20}
|
||||
g.player.life = PLAYER_MAX_LIFE
|
||||
|
||||
// Initialize ball
|
||||
g.ball.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight*7/8 - 30)}
|
||||
g.ball.speed = rl.Vector2{0, 0}
|
||||
g.ball.radius = 7
|
||||
g.ball.active = false
|
||||
|
||||
initialDownPosition := int(50)
|
||||
|
||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||
g.brick[i][j].position = rl.Vector2{float32(j)*g.brickSize.X + g.brickSize.X/2, float32(i)*g.brickSize.Y + float32(initialDownPosition)}
|
||||
g.brick[i][j].active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update - update game state
|
||||
func (g *Game) Update() {
|
||||
if !g.gameOver {
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyP) {
|
||||
g.pause = !g.pause
|
||||
}
|
||||
|
||||
if !g.pause {
|
||||
|
||||
if rl.IsKeyDown(rl.KeyLeft) || rl.IsKeyDown(rl.KeyA) {
|
||||
g.player.position.X -= 5
|
||||
}
|
||||
if (g.player.position.X - g.player.size.X/2) <= 0 {
|
||||
g.player.position.X = g.player.size.X / 2
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyRight) || rl.IsKeyDown(rl.KeyD) {
|
||||
g.player.position.X += 5
|
||||
}
|
||||
if (g.player.position.X + g.player.size.X/2) >= screenWidth {
|
||||
g.player.position.X = screenWidth - g.player.size.X/2
|
||||
}
|
||||
|
||||
if !g.ball.active {
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
g.ball.active = true
|
||||
g.ball.speed = rl.Vector2{0, -5}
|
||||
}
|
||||
}
|
||||
|
||||
if g.ball.active {
|
||||
g.ball.position.X += g.ball.speed.X
|
||||
g.ball.position.Y += g.ball.speed.Y
|
||||
} else {
|
||||
g.ball.position = rl.Vector2{g.player.position.X, screenHeight*7/8 - 30}
|
||||
}
|
||||
|
||||
// Collision logic: ball vs walls
|
||||
if ((g.ball.position.X + g.ball.radius) >= screenWidth) || ((g.ball.position.X - g.ball.radius) <= 0) {
|
||||
g.ball.speed.X *= -1
|
||||
}
|
||||
if (g.ball.position.Y - g.ball.radius) <= 0 {
|
||||
g.ball.speed.Y *= -1
|
||||
}
|
||||
if (g.ball.position.Y + g.ball.radius) >= screenHeight {
|
||||
g.ball.speed = rl.Vector2{0, 0}
|
||||
g.ball.active = false
|
||||
|
||||
g.player.life--
|
||||
}
|
||||
if (rl.CheckCollisionCircleRec(g.ball.position, g.ball.radius,
|
||||
rl.Rectangle{g.player.position.X - g.player.size.X/2, g.player.position.Y - g.player.size.Y/2, g.player.size.X, g.player.size.Y})) {
|
||||
if g.ball.speed.Y > 0 {
|
||||
g.ball.speed.Y *= -1
|
||||
g.ball.speed.X = (g.ball.position.X - g.player.position.X) / (g.player.size.X / 2) * 5
|
||||
}
|
||||
}
|
||||
// Collision logic: ball vs bricks
|
||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||
if g.brick[i][j].active {
|
||||
if ((g.ball.position.Y - g.ball.radius) <= (g.brick[i][j].position.Y + g.brickSize.Y/2)) &&
|
||||
((g.ball.position.Y - g.ball.radius) > (g.brick[i][j].position.Y + g.brickSize.Y/2 + g.ball.speed.Y)) &&
|
||||
((float32(math.Abs(float64(g.ball.position.X - g.brick[i][j].position.X)))) < (g.brickSize.X/2 + g.ball.radius*2/3)) &&
|
||||
(g.ball.speed.Y < 0) {
|
||||
// Hit below
|
||||
g.brick[i][j].active = false
|
||||
g.ball.speed.Y *= -1
|
||||
} else if ((g.ball.position.Y + g.ball.radius) >= (g.brick[i][j].position.Y - g.brickSize.Y/2)) &&
|
||||
((g.ball.position.Y + g.ball.radius) < (g.brick[i][j].position.Y - g.brickSize.Y/2 + g.ball.speed.Y)) &&
|
||||
((float32(math.Abs(float64(g.ball.position.X - g.brick[i][j].position.X)))) < (g.brickSize.X/2 + g.ball.radius*2/3)) &&
|
||||
(g.ball.speed.Y > 0) {
|
||||
// Hit above
|
||||
g.brick[i][j].active = false
|
||||
g.ball.speed.Y *= -1
|
||||
} else if ((g.ball.position.X + g.ball.radius) >= (g.brick[i][j].position.X - g.brickSize.X/2)) &&
|
||||
((g.ball.position.X + g.ball.radius) < (g.brick[i][j].position.X - g.brickSize.X/2 + g.ball.speed.X)) &&
|
||||
((float32(math.Abs(float64(g.ball.position.Y - g.brick[i][j].position.Y)))) < (g.brickSize.Y/2 + g.ball.radius*2/3)) &&
|
||||
(g.ball.speed.X > 0) {
|
||||
// Hit left
|
||||
g.brick[i][j].active = false
|
||||
g.ball.speed.X *= -1
|
||||
} else if ((g.ball.position.X - g.ball.radius) <= (g.brick[i][j].position.X + g.brickSize.X/2)) &&
|
||||
((g.ball.position.X - g.ball.radius) > (g.brick[i][j].position.X + g.brickSize.X/2 + g.ball.speed.X)) &&
|
||||
((float32(math.Abs(float64(g.ball.position.Y - g.brick[i][j].position.Y)))) < (g.brickSize.Y/2 + g.ball.radius*2/3)) &&
|
||||
(g.ball.speed.X < 0) {
|
||||
// Hit right
|
||||
g.brick[i][j].active = false
|
||||
g.ball.speed.X *= -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Game over logic
|
||||
if g.player.life <= 0 {
|
||||
g.gameOver = true
|
||||
} else {
|
||||
g.gameOver = true
|
||||
|
||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||
if g.brick[i][j].active {
|
||||
g.gameOver = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
g.Init()
|
||||
g.gameOver = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw - draw game
|
||||
func (g *Game) Draw() {
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.White)
|
||||
|
||||
if !g.gameOver {
|
||||
// Draw player bar
|
||||
rl.DrawRectangle(int32(g.player.position.X-g.player.size.X/2), int32(g.player.position.Y-g.player.size.Y/2), int32(g.player.size.X), int32(g.player.size.Y), rl.Black)
|
||||
|
||||
// Draw player lives
|
||||
for i := 0; i < g.player.life; i++ {
|
||||
rl.DrawRectangle(int32(20+40*i), screenHeight-30, 35, 10, rl.LightGray)
|
||||
}
|
||||
|
||||
// Draw Ball
|
||||
rl.DrawCircleV(g.ball.position, g.ball.radius, rl.Maroon)
|
||||
|
||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||
if g.brick[i][j].active {
|
||||
if (i+j)%2 == 0 {
|
||||
rl.DrawRectangle(int32(g.brick[i][j].position.X-g.brickSize.X/2), int32(g.brick[i][j].position.Y-g.brickSize.Y/2), int32(g.brickSize.X), int32(g.brickSize.Y), rl.Gray)
|
||||
} else {
|
||||
rl.DrawRectangle(int32(g.brick[i][j].position.X-g.brickSize.X/2), int32(g.brick[i][j].position.Y-g.brickSize.Y/2), int32(g.brickSize.X), int32(g.brickSize.Y), rl.DarkGray)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if g.pause {
|
||||
rl.DrawText("GAME PAUSED", screenWidth/2-rl.MeasureText("GAME PAUSED", 40)/2, screenHeight/2+screenHeight/4-40, 40, rl.Gray)
|
||||
}
|
||||
|
||||
} else {
|
||||
str := "PRESS [ENTER] TO PLAY AGAIN"
|
||||
x := int(rl.GetScreenWidth()/2) - int(rl.MeasureText(str, 20)/2)
|
||||
y := rl.GetScreenHeight()/2 - 50
|
||||
rl.DrawText(str, int32(x), int32(y), 20, rl.Gray)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
## Floppy Gopher
|
||||
|
||||

|
||||
|
||||
[Android APK](https://gist.github.com/gen2brain/ae96bc92d2c2e307af35f5583f30ea25)
|
|
@ -1,2 +0,0 @@
|
|||
The Gopher sprites were created by Renee French and are distributed
|
||||
under the Creative Commons Attributions 3.0 license.
|
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 27 KiB |
|
@ -1,452 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
// Screen width
|
||||
screenWidth = 504
|
||||
// Screen height
|
||||
screenHeight = 896
|
||||
|
||||
// Maximum number of pipes
|
||||
maxPipes = 100
|
||||
// Maximum number of particles
|
||||
maxParticles = 50
|
||||
|
||||
// Pipes width
|
||||
pipesWidth = 60
|
||||
// Sprite size
|
||||
spriteSize = 48
|
||||
|
||||
// Pipes speed
|
||||
pipesSpeedX = 2.5
|
||||
// Clouds speed
|
||||
cloudsSpeedX = 1
|
||||
|
||||
// Gravity
|
||||
gravity = 1.2
|
||||
)
|
||||
|
||||
// Floppy type
|
||||
type Floppy struct {
|
||||
Position rl.Vector2
|
||||
}
|
||||
|
||||
// Pipe type
|
||||
type Pipe struct {
|
||||
Rec rl.Rectangle
|
||||
Color rl.Color
|
||||
Active bool
|
||||
}
|
||||
|
||||
// Particle type
|
||||
type Particle struct {
|
||||
Position rl.Vector2
|
||||
Color rl.Color
|
||||
Alpha float32
|
||||
Size float32
|
||||
Rotation float32
|
||||
Active bool
|
||||
}
|
||||
|
||||
// Game type
|
||||
type Game struct {
|
||||
FxFlap rl.Sound
|
||||
FxSlap rl.Sound
|
||||
FxPoint rl.Sound
|
||||
FxClick rl.Sound
|
||||
|
||||
TxSprites rl.Texture2D
|
||||
TxSmoke rl.Texture2D
|
||||
TxClouds rl.Texture2D
|
||||
|
||||
CloudRec rl.Rectangle
|
||||
FrameRec rl.Rectangle
|
||||
|
||||
GameOver bool
|
||||
Dead bool
|
||||
Pause bool
|
||||
SuperFX bool
|
||||
|
||||
Score int
|
||||
HiScore int
|
||||
FramesCounter int32
|
||||
|
||||
WindowShouldClose bool
|
||||
|
||||
Floppy Floppy
|
||||
Particles []Particle
|
||||
|
||||
Pipes []Pipe
|
||||
PipesPos []rl.Vector2
|
||||
}
|
||||
|
||||
// NewGame - Start new game
|
||||
func NewGame() (g Game) {
|
||||
g.Init()
|
||||
return
|
||||
}
|
||||
|
||||
// On Android this sets callback function to be used for android_main
|
||||
func init() {
|
||||
rl.SetCallbackFunc(main)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Initialize game
|
||||
game := NewGame()
|
||||
game.GameOver = true
|
||||
|
||||
// Initialize window
|
||||
rl.InitWindow(screenWidth, screenHeight, "Floppy Gopher")
|
||||
|
||||
// Initialize audio
|
||||
rl.InitAudioDevice()
|
||||
|
||||
// NOTE: Textures and Sounds MUST be loaded after Window/Audio initialization
|
||||
game.Load()
|
||||
|
||||
// Limit FPS
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
// Main loop
|
||||
for !game.WindowShouldClose {
|
||||
// Update game
|
||||
game.Update()
|
||||
|
||||
// Draw game
|
||||
game.Draw()
|
||||
}
|
||||
|
||||
// Free resources
|
||||
game.Unload()
|
||||
|
||||
// Close audio
|
||||
rl.CloseAudioDevice()
|
||||
|
||||
// Close window
|
||||
rl.CloseWindow()
|
||||
|
||||
// Exit
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Init - Initialize game
|
||||
func (g *Game) Init() {
|
||||
|
||||
// Gopher
|
||||
g.Floppy = Floppy{rl.NewVector2(80, float32(screenHeight)/2-spriteSize/2)}
|
||||
|
||||
// Sprite rectangle
|
||||
g.FrameRec = rl.NewRectangle(0, 0, spriteSize, spriteSize)
|
||||
|
||||
// Cloud rectangle
|
||||
g.CloudRec = rl.NewRectangle(0, 0, float32(screenWidth), float32(g.TxClouds.Height))
|
||||
|
||||
// Initialize particles
|
||||
g.Particles = make([]Particle, maxParticles)
|
||||
for i := 0; i < maxParticles; i++ {
|
||||
g.Particles[i].Position = rl.NewVector2(0, 0)
|
||||
g.Particles[i].Color = rl.RayWhite
|
||||
g.Particles[i].Alpha = 1.0
|
||||
g.Particles[i].Size = float32(rl.GetRandomValue(1, 30)) / 20.0
|
||||
g.Particles[i].Rotation = float32(rl.GetRandomValue(0, 360))
|
||||
g.Particles[i].Active = false
|
||||
}
|
||||
|
||||
// Pipes positions
|
||||
g.PipesPos = make([]rl.Vector2, maxPipes)
|
||||
for i := 0; i < maxPipes; i++ {
|
||||
g.PipesPos[i].X = float32(480 + 360*i)
|
||||
g.PipesPos[i].Y = -float32(rl.GetRandomValue(0, 240))
|
||||
}
|
||||
|
||||
// Pipes colors
|
||||
colors := []rl.Color{
|
||||
rl.Orange, rl.Red, rl.Gold, rl.Lime,
|
||||
rl.Violet, rl.Brown, rl.LightGray, rl.Blue,
|
||||
rl.Yellow, rl.Green, rl.Purple, rl.Beige,
|
||||
}
|
||||
|
||||
// Pipes
|
||||
g.Pipes = make([]Pipe, maxPipes*2)
|
||||
for i := 0; i < maxPipes*2; i += 2 {
|
||||
g.Pipes[i].Rec.X = g.PipesPos[i/2].X
|
||||
g.Pipes[i].Rec.Y = g.PipesPos[i/2].Y
|
||||
g.Pipes[i].Rec.Width = pipesWidth
|
||||
g.Pipes[i].Rec.Height = 550
|
||||
g.Pipes[i].Color = colors[rl.GetRandomValue(0, int32(len(colors)-1))]
|
||||
|
||||
g.Pipes[i+1].Rec.X = g.PipesPos[i/2].X
|
||||
g.Pipes[i+1].Rec.Y = 1200 + g.PipesPos[i/2].Y - 550
|
||||
g.Pipes[i+1].Rec.Width = pipesWidth
|
||||
g.Pipes[i+1].Rec.Height = 550
|
||||
|
||||
g.Pipes[i/2].Active = true
|
||||
}
|
||||
|
||||
g.Score = 0
|
||||
g.FramesCounter = 0
|
||||
g.WindowShouldClose = false
|
||||
|
||||
g.GameOver = false
|
||||
g.Dead = false
|
||||
g.SuperFX = false
|
||||
g.Pause = false
|
||||
}
|
||||
|
||||
// Load - Load resources
|
||||
func (g *Game) Load() {
|
||||
g.FxFlap = rl.LoadSound("sounds/flap.wav")
|
||||
g.FxSlap = rl.LoadSound("sounds/slap.wav")
|
||||
g.FxPoint = rl.LoadSound("sounds/point.wav")
|
||||
g.FxClick = rl.LoadSound("sounds/click.wav")
|
||||
g.TxSprites = rl.LoadTexture("images/sprite.png")
|
||||
g.TxSmoke = rl.LoadTexture("images/smoke.png")
|
||||
g.TxClouds = rl.LoadTexture("images/clouds.png")
|
||||
}
|
||||
|
||||
// Unload - Unload resources
|
||||
func (g *Game) Unload() {
|
||||
rl.UnloadSound(g.FxFlap)
|
||||
rl.UnloadSound(g.FxSlap)
|
||||
rl.UnloadSound(g.FxPoint)
|
||||
rl.UnloadSound(g.FxClick)
|
||||
rl.UnloadTexture(g.TxSprites)
|
||||
rl.UnloadTexture(g.TxSmoke)
|
||||
rl.UnloadTexture(g.TxClouds)
|
||||
}
|
||||
|
||||
// Update - Update game
|
||||
func (g *Game) Update() {
|
||||
if rl.WindowShouldClose() {
|
||||
g.WindowShouldClose = true
|
||||
}
|
||||
|
||||
if !g.GameOver {
|
||||
if rl.IsKeyPressed(rl.KeyP) || rl.IsKeyPressed(rl.KeyBack) {
|
||||
rl.PlaySound(g.FxClick)
|
||||
|
||||
if runtime.GOOS == "android" && g.Pause {
|
||||
g.WindowShouldClose = true
|
||||
}
|
||||
|
||||
g.Pause = !g.Pause
|
||||
}
|
||||
|
||||
if !g.Pause {
|
||||
if !g.Dead {
|
||||
// Scroll pipes
|
||||
for i := 0; i < maxPipes; i++ {
|
||||
g.PipesPos[i].X -= float32(pipesSpeedX)
|
||||
}
|
||||
|
||||
for i := 0; i < maxPipes*2; i += 2 {
|
||||
g.Pipes[i].Rec.X = g.PipesPos[i/2].X
|
||||
g.Pipes[i+1].Rec.X = g.PipesPos[i/2].X
|
||||
}
|
||||
|
||||
// Scroll clouds
|
||||
g.CloudRec.X += cloudsSpeedX
|
||||
if g.CloudRec.X > float32(g.TxClouds.Width) {
|
||||
g.CloudRec.X = 0
|
||||
}
|
||||
|
||||
// Movement/Controls
|
||||
if rl.IsKeyDown(rl.KeySpace) || rl.IsMouseButtonDown(rl.MouseLeftButton) {
|
||||
rl.PlaySound(g.FxFlap)
|
||||
|
||||
// Activate one particle every frame
|
||||
for i := 0; i < maxParticles; i++ {
|
||||
if !g.Particles[i].Active {
|
||||
g.Particles[i].Active = true
|
||||
g.Particles[i].Alpha = 1.0
|
||||
g.Particles[i].Position = g.Floppy.Position
|
||||
g.Particles[i].Position.X += spriteSize / 2
|
||||
g.Particles[i].Position.Y += spriteSize / 2
|
||||
i = maxParticles
|
||||
}
|
||||
}
|
||||
|
||||
// Switch flap sprites every 8 frames
|
||||
g.FramesCounter++
|
||||
if g.FramesCounter >= 8 {
|
||||
g.FramesCounter = 0
|
||||
g.FrameRec.X = spriteSize * 3
|
||||
} else {
|
||||
g.FrameRec.X = spriteSize * 2
|
||||
}
|
||||
|
||||
// Floppy go up
|
||||
g.Floppy.Position.Y -= 3
|
||||
} else {
|
||||
// Switch run sprites every 8 frames
|
||||
g.FramesCounter++
|
||||
if g.FramesCounter >= 8 {
|
||||
g.FramesCounter = 0
|
||||
g.FrameRec.X = spriteSize
|
||||
} else {
|
||||
g.FrameRec.X = 0
|
||||
}
|
||||
|
||||
// Floppy fall down
|
||||
g.Floppy.Position.Y += gravity
|
||||
}
|
||||
|
||||
// Update active particles
|
||||
for i := 0; i < maxParticles; i++ {
|
||||
if g.Particles[i].Active {
|
||||
g.Particles[i].Position.X -= 1.0
|
||||
g.Particles[i].Alpha -= 0.05
|
||||
|
||||
if g.Particles[i].Alpha <= 0.0 {
|
||||
g.Particles[i].Active = false
|
||||
}
|
||||
|
||||
g.Particles[i].Rotation += 3.0
|
||||
}
|
||||
}
|
||||
|
||||
// Check Collisions
|
||||
for i := 0; i < maxPipes*2; i++ {
|
||||
if rl.CheckCollisionRecs(rl.NewRectangle(g.Floppy.Position.X, g.Floppy.Position.Y, spriteSize, spriteSize), g.Pipes[i].Rec) {
|
||||
// OMG You killed Gopher you bastard!
|
||||
g.Dead = true
|
||||
|
||||
rl.PlaySound(g.FxSlap)
|
||||
} else if (g.PipesPos[i/2].X < g.Floppy.Position.X-spriteSize) && g.Pipes[i/2].Active && !g.GameOver {
|
||||
// Score point
|
||||
g.Score += 1
|
||||
g.Pipes[i/2].Active = false
|
||||
|
||||
// Flash screen
|
||||
g.SuperFX = true
|
||||
|
||||
// Update HiScore
|
||||
if g.Score > g.HiScore {
|
||||
g.HiScore = g.Score
|
||||
}
|
||||
|
||||
rl.PlaySound(g.FxPoint)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Wait 60 frames before GameOver
|
||||
g.FramesCounter++
|
||||
if g.FramesCounter >= 60 {
|
||||
g.GameOver = true
|
||||
}
|
||||
|
||||
// Switch dead sprite
|
||||
if g.FramesCounter >= 8 {
|
||||
g.FrameRec.X = spriteSize * 5
|
||||
} else {
|
||||
g.FrameRec.X = spriteSize * 4
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if rl.IsMouseButtonDown(rl.MouseLeftButton) {
|
||||
g.Pause = !g.Pause
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if rl.IsKeyPressed(rl.KeyEnter) || rl.IsMouseButtonDown(rl.MouseLeftButton) {
|
||||
rl.PlaySound(g.FxClick)
|
||||
|
||||
// Return of the Gopher!
|
||||
g.Init()
|
||||
} else if runtime.GOOS == "android" && rl.IsKeyDown(rl.KeyBack) {
|
||||
g.WindowShouldClose = true
|
||||
}
|
||||
|
||||
// Switch flap sprites
|
||||
g.FramesCounter++
|
||||
if g.FramesCounter >= 8 {
|
||||
g.FramesCounter = 0
|
||||
g.FrameRec.X = spriteSize
|
||||
} else {
|
||||
g.FrameRec.X = 0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Draw - Draw game
|
||||
func (g *Game) Draw() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.SkyBlue)
|
||||
|
||||
if !g.GameOver {
|
||||
// Draw clouds
|
||||
rl.DrawTextureRec(g.TxClouds, g.CloudRec, rl.NewVector2(0, float32(screenHeight-g.TxClouds.Height)), rl.RayWhite)
|
||||
|
||||
// Draw rotated clouds
|
||||
rl.DrawTexturePro(g.TxClouds, rl.NewRectangle(-g.CloudRec.X, 0, float32(g.TxClouds.Width), float32(g.TxClouds.Height)),
|
||||
rl.NewRectangle(0, 0, float32(g.TxClouds.Width), float32(g.TxClouds.Height)), rl.NewVector2(float32(g.TxClouds.Width), float32(g.TxClouds.Height)), 180, rl.White)
|
||||
|
||||
// Draw Gopher
|
||||
rl.DrawTextureRec(g.TxSprites, g.FrameRec, g.Floppy.Position, rl.RayWhite)
|
||||
|
||||
// Draw active particles
|
||||
if !g.Dead {
|
||||
for i := 0; i < maxParticles; i++ {
|
||||
if g.Particles[i].Active {
|
||||
rl.DrawTexturePro(
|
||||
g.TxSmoke,
|
||||
rl.NewRectangle(0, 0, float32(g.TxSmoke.Width), float32(g.TxSmoke.Height)),
|
||||
rl.NewRectangle(g.Particles[i].Position.X, g.Particles[i].Position.Y, float32(g.TxSmoke.Width)*g.Particles[i].Size, float32(g.TxSmoke.Height)*g.Particles[i].Size),
|
||||
rl.NewVector2(float32(g.TxSmoke.Width)*g.Particles[i].Size/2, float32(g.TxSmoke.Height)*g.Particles[i].Size/2),
|
||||
g.Particles[i].Rotation,
|
||||
rl.Fade(g.Particles[i].Color, g.Particles[i].Alpha),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw pipes
|
||||
for i := 0; i < maxPipes; i++ {
|
||||
rl.DrawRectangle(int32(g.Pipes[i*2].Rec.X), int32(g.Pipes[i*2].Rec.Y), int32(g.Pipes[i*2].Rec.Width), int32(g.Pipes[i*2].Rec.Height), g.Pipes[i*2].Color)
|
||||
rl.DrawRectangle(int32(g.Pipes[i*2+1].Rec.X), int32(g.Pipes[i*2+1].Rec.Y), int32(g.Pipes[i*2+1].Rec.Width), int32(g.Pipes[i*2+1].Rec.Height), g.Pipes[i*2].Color)
|
||||
|
||||
// Draw borders
|
||||
rl.DrawRectangleLines(int32(g.Pipes[i*2].Rec.X), int32(g.Pipes[i*2].Rec.Y), int32(g.Pipes[i*2].Rec.Width), int32(g.Pipes[i*2].Rec.Height), rl.Black)
|
||||
rl.DrawRectangleLines(int32(g.Pipes[i*2+1].Rec.X), int32(g.Pipes[i*2+1].Rec.Y), int32(g.Pipes[i*2+1].Rec.Width), int32(g.Pipes[i*2+1].Rec.Height), rl.Black)
|
||||
}
|
||||
|
||||
// Draw Super Flashing FX (one frame only)
|
||||
if g.SuperFX {
|
||||
rl.DrawRectangle(0, 0, screenWidth, screenHeight, rl.White)
|
||||
g.SuperFX = false
|
||||
}
|
||||
|
||||
// Draw HI-SCORE
|
||||
rl.DrawText(fmt.Sprintf("%02d", g.Score), 20, 20, 32, rl.Black)
|
||||
rl.DrawText(fmt.Sprintf("HI-SCORE: %02d", g.HiScore), 20, 64, 20, rl.Black)
|
||||
|
||||
if g.Pause {
|
||||
// Draw PAUSED text
|
||||
rl.DrawText("PAUSED", screenWidth/2-rl.MeasureText("PAUSED", 24)/2, screenHeight/2-50, 20, rl.Black)
|
||||
}
|
||||
} else {
|
||||
// Draw text
|
||||
rl.DrawText("Floppy Gopher", int32(rl.GetScreenWidth())/2-rl.MeasureText("Floppy Gopher", 40)/2, int32(rl.GetScreenHeight())/2-150, 40, rl.RayWhite)
|
||||
|
||||
if runtime.GOOS == "android" {
|
||||
rl.DrawText("[TAP] TO PLAY", int32(rl.GetScreenWidth())/2-rl.MeasureText("[TAP] TO PLAY", 20)/2, int32(rl.GetScreenHeight())/2-50, 20, rl.Black)
|
||||
} else {
|
||||
rl.DrawText("[ENTER] TO PLAY", int32(rl.GetScreenWidth())/2-rl.MeasureText("[ENTER] TO PLAY", 20)/2, int32(rl.GetScreenHeight())/2-50, 20, rl.Black)
|
||||
}
|
||||
|
||||
// Draw Gopher
|
||||
rl.DrawTextureRec(g.TxSprites, g.FrameRec, rl.NewVector2(float32(rl.GetScreenWidth()/2-spriteSize/2), float32(rl.GetScreenHeight()/2)), rl.RayWhite)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
squareSize = 8
|
||||
)
|
||||
|
||||
// Cell type
|
||||
type Cell struct {
|
||||
Position rl.Vector2
|
||||
Size rl.Vector2
|
||||
Alive bool
|
||||
Next bool
|
||||
Visited bool
|
||||
}
|
||||
|
||||
// Game type
|
||||
type Game struct {
|
||||
ScreenWidth int32
|
||||
ScreenHeight int32
|
||||
Cols int32
|
||||
Rows int32
|
||||
FramesCounter int32
|
||||
Playing bool
|
||||
Cells [][]*Cell
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
game := Game{}
|
||||
game.Init(false)
|
||||
|
||||
rl.InitWindow(game.ScreenWidth, game.ScreenHeight, "Conway's Game of Life")
|
||||
rl.SetTargetFPS(20)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if game.Playing {
|
||||
game.Update()
|
||||
}
|
||||
|
||||
game.Input()
|
||||
|
||||
game.Draw()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
// Init - Initialize game
|
||||
func (g *Game) Init(clear bool) {
|
||||
g.ScreenWidth = 800
|
||||
g.ScreenHeight = 450
|
||||
g.FramesCounter = 0
|
||||
|
||||
g.Cols = g.ScreenWidth / squareSize
|
||||
g.Rows = g.ScreenHeight / squareSize
|
||||
|
||||
g.Cells = make([][]*Cell, g.Cols+1)
|
||||
for i := int32(0); i <= g.Cols; i++ {
|
||||
g.Cells[i] = make([]*Cell, g.Rows+1)
|
||||
}
|
||||
|
||||
for x := int32(0); x <= g.Cols; x++ {
|
||||
for y := int32(0); y <= g.Rows; y++ {
|
||||
g.Cells[x][y] = &Cell{}
|
||||
g.Cells[x][y].Position = rl.NewVector2((float32(x) * squareSize), (float32(y)*squareSize)+1)
|
||||
g.Cells[x][y].Size = rl.NewVector2(squareSize-1, squareSize-1)
|
||||
if rand.Float64() < 0.1 && clear == false {
|
||||
g.Cells[x][y].Alive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Input - Game input
|
||||
func (g *Game) Input() {
|
||||
// control
|
||||
if rl.IsKeyPressed(rl.KeyR) {
|
||||
g.Init(false)
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyC) {
|
||||
g.Init(true)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyRight) && !g.Playing {
|
||||
g.Update()
|
||||
}
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
g.Click(rl.GetMouseX(), rl.GetMouseY())
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
g.Playing = !g.Playing
|
||||
}
|
||||
|
||||
g.FramesCounter++
|
||||
}
|
||||
|
||||
// Click - Toggle if a cell is alive or dead on click
|
||||
func (g *Game) Click(x, y int32) {
|
||||
for i := int32(0); i <= g.Cols; i++ {
|
||||
for j := int32(0); j <= g.Rows; j++ {
|
||||
cell := g.Cells[i][j].Position
|
||||
if int32(cell.X) < x && int32(cell.X)+squareSize > x && int32(cell.Y) < y && int32(cell.Y)+squareSize > y {
|
||||
g.Cells[i][j].Alive = !g.Cells[i][j].Alive
|
||||
g.Cells[i][j].Next = g.Cells[i][j].Alive
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update - Update game
|
||||
func (g *Game) Update() {
|
||||
for i := int32(0); i <= g.Cols; i++ {
|
||||
for j := int32(0); j <= g.Rows; j++ {
|
||||
NeighborCount := g.CountNeighbors(i, j)
|
||||
if g.Cells[i][j].Alive {
|
||||
if NeighborCount < 2 {
|
||||
g.Cells[i][j].Next = false
|
||||
} else if NeighborCount > 3 {
|
||||
g.Cells[i][j].Next = false
|
||||
} else {
|
||||
g.Cells[i][j].Next = true
|
||||
}
|
||||
} else {
|
||||
if NeighborCount == 3 {
|
||||
g.Cells[i][j].Next = true
|
||||
g.Cells[i][j].Visited = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := int32(0); i <= g.Cols; i++ {
|
||||
for j := int32(0); j < g.Rows; j++ {
|
||||
g.Cells[i][j].Alive = g.Cells[i][j].Next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CountNeighbors - Counts how many neighbous a cell has
|
||||
func (g *Game) CountNeighbors(x, y int32) int {
|
||||
count := 0
|
||||
|
||||
for i := int32(-1); i < 2; i++ {
|
||||
for j := int32(-1); j < 2; j++ {
|
||||
col := (x + i + (g.Cols)) % (g.Cols)
|
||||
row := (y + j + (g.Rows)) % (g.Rows)
|
||||
if g.Cells[col][row].Alive {
|
||||
count++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if g.Cells[x][y].Alive {
|
||||
count--
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
// Draw - Draw game
|
||||
func (g *Game) Draw() {
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
// Draw cells
|
||||
for x := int32(0); x <= g.Cols; x++ {
|
||||
for y := int32(0); y <= g.Rows; y++ {
|
||||
if g.Cells[x][y].Alive {
|
||||
rl.DrawRectangleV(g.Cells[x][y].Position, g.Cells[x][y].Size, rl.Blue)
|
||||
} else if g.Cells[x][y].Visited {
|
||||
rl.DrawRectangleV(g.Cells[x][y].Position, g.Cells[x][y].Size, rl.Color{R: 128, G: 177, B: 136, A: 255})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw grid lines
|
||||
for i := int32(0); i < g.Cols+1; i++ {
|
||||
rl.DrawLineV(
|
||||
rl.NewVector2(float32(squareSize*i), 0),
|
||||
rl.NewVector2(float32(squareSize*i), float32(g.ScreenHeight)),
|
||||
rl.LightGray,
|
||||
)
|
||||
}
|
||||
|
||||
for i := int32(0); i < g.Rows+1; i++ {
|
||||
rl.DrawLineV(
|
||||
rl.NewVector2(0, float32(squareSize*i)),
|
||||
rl.NewVector2(float32(g.ScreenWidth), float32(squareSize*i)),
|
||||
rl.LightGray,
|
||||
)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
|
@ -1,238 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
snakeLength = 256
|
||||
squareSize = 31
|
||||
)
|
||||
|
||||
// Snake type
|
||||
type Snake struct {
|
||||
Position rl.Vector2
|
||||
Size rl.Vector2
|
||||
Speed rl.Vector2
|
||||
Color rl.Color
|
||||
}
|
||||
|
||||
// Food type
|
||||
type Food struct {
|
||||
Position rl.Vector2
|
||||
Size rl.Vector2
|
||||
Active bool
|
||||
Color rl.Color
|
||||
}
|
||||
|
||||
// Game type
|
||||
type Game struct {
|
||||
ScreenWidth int32
|
||||
ScreenHeight int32
|
||||
|
||||
FramesCounter int32
|
||||
GameOver bool
|
||||
Pause bool
|
||||
|
||||
Fruit Food
|
||||
Snake []Snake
|
||||
SnakePosition []rl.Vector2
|
||||
AllowMove bool
|
||||
Offset rl.Vector2
|
||||
CounterTail int
|
||||
}
|
||||
|
||||
func main() {
|
||||
game := Game{}
|
||||
game.Init()
|
||||
|
||||
rl.InitWindow(game.ScreenWidth, game.ScreenHeight, "sample game: snake")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
game.Update()
|
||||
|
||||
game.Draw()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
// Init - Initialize game
|
||||
func (g *Game) Init() {
|
||||
g.ScreenWidth = 800
|
||||
g.ScreenHeight = 450
|
||||
|
||||
g.FramesCounter = 0
|
||||
g.GameOver = false
|
||||
g.Pause = false
|
||||
|
||||
g.CounterTail = 1
|
||||
g.AllowMove = false
|
||||
|
||||
g.Offset = rl.Vector2{}
|
||||
g.Offset.X = float32(g.ScreenWidth % squareSize)
|
||||
g.Offset.Y = float32(g.ScreenHeight % squareSize)
|
||||
|
||||
g.Snake = make([]Snake, snakeLength)
|
||||
|
||||
for i := 0; i < snakeLength; i++ {
|
||||
g.Snake[i].Position = rl.NewVector2(g.Offset.X/2, g.Offset.Y/2)
|
||||
g.Snake[i].Size = rl.NewVector2(squareSize, squareSize)
|
||||
g.Snake[i].Speed = rl.NewVector2(squareSize, 0)
|
||||
|
||||
if i == 0 {
|
||||
g.Snake[i].Color = rl.DarkBlue
|
||||
} else {
|
||||
g.Snake[i].Color = rl.Blue
|
||||
}
|
||||
}
|
||||
|
||||
g.SnakePosition = make([]rl.Vector2, snakeLength)
|
||||
|
||||
for i := 0; i < snakeLength; i++ {
|
||||
g.SnakePosition[i] = rl.NewVector2(0.0, 0.0)
|
||||
}
|
||||
|
||||
g.Fruit.Size = rl.NewVector2(squareSize, squareSize)
|
||||
g.Fruit.Color = rl.SkyBlue
|
||||
g.Fruit.Active = false
|
||||
}
|
||||
|
||||
// Update - Update game
|
||||
func (g *Game) Update() {
|
||||
if !g.GameOver {
|
||||
if rl.IsKeyPressed(rl.KeyP) {
|
||||
g.Pause = !g.Pause
|
||||
}
|
||||
|
||||
if !g.Pause {
|
||||
// control
|
||||
if rl.IsKeyPressed(rl.KeyRight) && g.Snake[0].Speed.X == 0 && g.AllowMove {
|
||||
g.Snake[0].Speed = rl.NewVector2(squareSize, 0)
|
||||
g.AllowMove = false
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyLeft) && g.Snake[0].Speed.X == 0 && g.AllowMove {
|
||||
g.Snake[0].Speed = rl.NewVector2(-squareSize, 0)
|
||||
g.AllowMove = false
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyUp) && g.Snake[0].Speed.Y == 0 && g.AllowMove {
|
||||
g.Snake[0].Speed = rl.NewVector2(0, -squareSize)
|
||||
g.AllowMove = false
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyDown) && g.Snake[0].Speed.Y == 0 && g.AllowMove {
|
||||
g.Snake[0].Speed = rl.NewVector2(0, squareSize)
|
||||
g.AllowMove = false
|
||||
}
|
||||
|
||||
// movement
|
||||
for i := 0; i < g.CounterTail; i++ {
|
||||
g.SnakePosition[i] = g.Snake[i].Position
|
||||
}
|
||||
|
||||
if g.FramesCounter%5 == 0 {
|
||||
for i := 0; i < g.CounterTail; i++ {
|
||||
if i == 0 {
|
||||
g.Snake[0].Position.X += g.Snake[0].Speed.X
|
||||
g.Snake[0].Position.Y += g.Snake[0].Speed.Y
|
||||
g.AllowMove = true
|
||||
} else {
|
||||
g.Snake[i].Position = g.SnakePosition[i-1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wall behaviour
|
||||
if ((g.Snake[0].Position.X) > (float32(g.ScreenWidth) - g.Offset.X)) ||
|
||||
((g.Snake[0].Position.Y) > (float32(g.ScreenHeight) - g.Offset.Y)) ||
|
||||
(g.Snake[0].Position.X < 0) || (g.Snake[0].Position.Y < 0) {
|
||||
g.GameOver = true
|
||||
}
|
||||
|
||||
// collision with yourself
|
||||
for i := 1; i < g.CounterTail; i++ {
|
||||
if (g.Snake[0].Position.X == g.Snake[i].Position.X) && (g.Snake[0].Position.Y == g.Snake[i].Position.Y) {
|
||||
g.GameOver = true
|
||||
}
|
||||
}
|
||||
|
||||
if !g.Fruit.Active {
|
||||
g.Fruit.Active = true
|
||||
g.Fruit.Position = rl.NewVector2(
|
||||
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize+int32(g.Offset.X)/2),
|
||||
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize+int32(g.Offset.Y)/2),
|
||||
)
|
||||
|
||||
for i := 0; i < g.CounterTail; i++ {
|
||||
for (g.Fruit.Position.X == g.Snake[i].Position.X) && (g.Fruit.Position.Y == g.Snake[i].Position.Y) {
|
||||
g.Fruit.Position = rl.NewVector2(
|
||||
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize),
|
||||
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize),
|
||||
)
|
||||
i = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// collision
|
||||
if rl.CheckCollisionRecs(
|
||||
rl.NewRectangle(g.Snake[0].Position.X, g.Snake[0].Position.Y, g.Snake[0].Size.X, g.Snake[0].Size.Y),
|
||||
rl.NewRectangle(g.Fruit.Position.X, g.Fruit.Position.Y, g.Fruit.Size.X, g.Fruit.Size.Y),
|
||||
) {
|
||||
g.Snake[g.CounterTail].Position = g.SnakePosition[g.CounterTail-1]
|
||||
g.CounterTail += 1
|
||||
g.Fruit.Active = false
|
||||
}
|
||||
|
||||
g.FramesCounter++
|
||||
}
|
||||
} else {
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
g.Init()
|
||||
g.GameOver = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw - Draw game
|
||||
func (g *Game) Draw() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
if !g.GameOver {
|
||||
// Draw grid lines
|
||||
for i := int32(0); i < g.ScreenWidth/squareSize+1; i++ {
|
||||
rl.DrawLineV(
|
||||
rl.NewVector2(float32(squareSize*i)+g.Offset.X/2, g.Offset.Y/2),
|
||||
rl.NewVector2(float32(squareSize*i)+g.Offset.X/2, float32(g.ScreenHeight)-g.Offset.Y/2),
|
||||
rl.LightGray,
|
||||
)
|
||||
}
|
||||
|
||||
for i := int32(0); i < g.ScreenHeight/squareSize+1; i++ {
|
||||
rl.DrawLineV(
|
||||
rl.NewVector2(g.Offset.X/2, float32(squareSize*i)+g.Offset.Y/2),
|
||||
rl.NewVector2(float32(g.ScreenWidth)-g.Offset.X/2, float32(squareSize*i)+g.Offset.Y/2),
|
||||
rl.LightGray,
|
||||
)
|
||||
}
|
||||
|
||||
// Draw snake
|
||||
for i := 0; i < g.CounterTail; i++ {
|
||||
rl.DrawRectangleV(g.Snake[i].Position, g.Snake[i].Size, g.Snake[i].Color)
|
||||
}
|
||||
|
||||
// Draw fruit to pick
|
||||
rl.DrawRectangleV(g.Fruit.Position, g.Fruit.Size, g.Fruit.Color)
|
||||
|
||||
if g.Pause {
|
||||
rl.DrawText("GAME PAUSED", g.ScreenWidth/2-rl.MeasureText("GAME PAUSED", 40)/2, g.ScreenHeight/2-40, 40, rl.Gray)
|
||||
}
|
||||
} else {
|
||||
rl.DrawText("PRESS [ENTER] TO PLAY AGAIN", int32(rl.GetScreenWidth())/2-rl.MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, int32(rl.GetScreenHeight())/2-50, 20, rl.Gray)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
|
@ -1,13 +1,3 @@
|
|||
module examples
|
||||
module example
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/Konstantin8105/raylib-go/raygui v0.0.0-20221122151443-e8a384ed1346 // indirect
|
||||
github.com/gen2brain/raylib-go/easings v0.0.0-20220827153754-6e090424c541
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20220827153754-6e090424c541
|
||||
github.com/gen2brain/raylib-go/raygui v0.0.0-20220827153754-6e090424c541
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20220827153754-6e090424c541
|
||||
github.com/jakecoffman/cp v1.2.1
|
||||
github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b
|
||||
)
|
||||
go 1.19
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raygui"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [gui] example - basic controls")
|
||||
|
||||
buttonToggle := true
|
||||
buttonClicked := false
|
||||
checkboxChecked := false
|
||||
|
||||
spinnerValue := 5
|
||||
sliderValue := float32(10)
|
||||
sliderBarValue := float32(70)
|
||||
progressValue := float32(0.5)
|
||||
|
||||
comboActive := 0
|
||||
comboLastActive := 0
|
||||
toggleActive := 0
|
||||
|
||||
toggleText := []string{"Item 1", "Item 2", "Item 3"}
|
||||
comboText := []string{"default_light", "default_dark", "hello_kitty", "monokai", "obsidian", "solarized_light", "solarized", "zahnrad"}
|
||||
|
||||
var inputText string
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if buttonClicked {
|
||||
progressValue += 0.1
|
||||
if progressValue >= 1.1 {
|
||||
progressValue = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Beige)
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 50, 80, 20), "Label")
|
||||
|
||||
buttonClicked = raygui.Button(rl.NewRectangle(50, 70, 80, 40), "Button")
|
||||
|
||||
raygui.Label(rl.NewRectangle(70, 140, 20, 20), "Checkbox")
|
||||
checkboxChecked = raygui.CheckBox(rl.NewRectangle(50, 140, 20, 20), checkboxChecked)
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 190, 200, 20), "ProgressBar")
|
||||
raygui.ProgressBar(rl.NewRectangle(50, 210, 200, 20), progressValue)
|
||||
raygui.Label(rl.NewRectangle(200+50+5, 210, 20, 20), fmt.Sprintf("%.1f", progressValue))
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 260, 200, 20), "Slider")
|
||||
sliderValue = raygui.Slider(rl.NewRectangle(50, 280, 200, 20), sliderValue, 0, 100)
|
||||
raygui.Label(rl.NewRectangle(200+50+5, 280, 20, 20), fmt.Sprintf("%.0f", sliderValue))
|
||||
|
||||
buttonToggle = raygui.ToggleButton(rl.NewRectangle(50, 350, 100, 40), "ToggleButton", buttonToggle)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 50, 200, 20), "ToggleGroup")
|
||||
toggleActive = raygui.ToggleGroup(rl.NewRectangle(500, 70, 60, 30), toggleText, toggleActive)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 120, 200, 20), "SliderBar")
|
||||
sliderBarValue = raygui.SliderBar(rl.NewRectangle(500, 140, 200, 20), sliderBarValue, 0, 100)
|
||||
raygui.Label(rl.NewRectangle(500+200+5, 140, 20, 20), fmt.Sprintf("%.0f", sliderBarValue))
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 190, 200, 20), "Spinner")
|
||||
spinnerValue = raygui.Spinner(rl.NewRectangle(500, 210, 200, 20), spinnerValue, 0, 100)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 260, 200, 20), "ComboBox")
|
||||
comboActive = raygui.ComboBox(rl.NewRectangle(500, 280, 200, 20), comboText, comboActive)
|
||||
|
||||
if comboLastActive != comboActive {
|
||||
raygui.LoadGuiStyle(fmt.Sprintf("styles/%s.style", comboText[comboActive]))
|
||||
comboLastActive = comboActive
|
||||
}
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 330, 200, 20), "TextBox")
|
||||
inputText = raygui.TextBox(rl.NewRectangle(500, 350, 200, 20), inputText)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0xf5f5f5ff
|
||||
GLOBAL_BORDER_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0x293235ff
|
||||
LINES_COLOR 0x90abb5ff
|
||||
LABEL_BORDER_WIDTH 0x0
|
||||
LABEL_TEXT_COLOR 0x90acb4ff
|
||||
LABEL_TEXT_PADDING 0x0
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x0
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x3e4a4fff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0x344041ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0x90acb4ff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x47595fff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0x334f59ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0x90acb4ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x5f9aa4ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0x334f59ff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0x5f9aa8ff
|
||||
TOGGLE_TEXT_PADDING 0x20
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x3e4b4dff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0x344041ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0x828282ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x47595fff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0x334f59ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0x828282ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x5f9aa8ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0x334f59ff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0x5f9aa8ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x92c763ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x334f59ff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0x92c763ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x0
|
||||
SLIDER_BORDER_COLOR 0x828282ff
|
||||
SLIDER_INSIDE_COLOR 0x3e4b4dff
|
||||
SLIDER_DEFAULT_COLOR 0x92c763ff
|
||||
SLIDER_HOVER_COLOR 0xc3e0a9ff
|
||||
SLIDER_ACTIVE_COLOR 0xffffffff
|
||||
SLIDERBAR_BORDER_COLOR 0x828282ff
|
||||
SLIDERBAR_INSIDE_COLOR 0x344041ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x92c763ff
|
||||
SLIDERBAR_HOVER_COLOR 0xc3e0a9ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0xffffffff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x828282ff
|
||||
PROGRESSBAR_BORDER_COLOR 0x828282ff
|
||||
PROGRESSBAR_INSIDE_COLOR 0x3e4b4dff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x92c763ff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x1
|
||||
SPINNER_LABEL_BORDER_COLOR 0x3e4b4dff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0x344041ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x3e4b4dff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0x344041ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0x5f9aa8ff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0x5f9aa8ff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x47595fff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0x334f59ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0x5f9aa8ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0x5f9aa8ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x92c763ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0x334f59ff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0x92c763ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0x92c763ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x30
|
||||
COMBOBOX_BUTTON_HEIGHT 0x20
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x3e4b4dff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0x344041ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x47595fff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0x334f59ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x334f59ff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0x5f9aa8ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x92c763ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x334f59ff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0x92c763ff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x47595fff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0x344041ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x47595fff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0x334f59ff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x5f9aa8ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x334f59ff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x92c763ff
|
||||
CHECKBOX_INSIDE_WIDTH 0x2
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x47595fff
|
||||
TEXTBOX_INSIDE_COLOR 0x828282ff
|
||||
TEXTBOX_TEXT_COLOR 0xff
|
||||
TEXTBOX_LINE_COLOR 0xff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,99 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0xf5f5f5ff
|
||||
GLOBAL_BORDER_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xf5f5f5ff
|
||||
LINES_COLOR 0x90abb5ff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0x4d4d4dff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0xc8c8c8ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0x4d4d4dff
|
||||
BUTTON_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0xffffffff
|
||||
BUTTON_HOVER_TEXT_COLOR 0x868686ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x7bb0d6ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0xbcecffff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0x5f9aa7ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0xc8c8c8ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0x828282ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0xffffffff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0x828282ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0xbdd7eaff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0xddf5ffff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xafccd3ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x7bb0d6ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0xbcecffff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0x5f9aa7ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x828282ff
|
||||
SLIDER_INSIDE_COLOR 0xc8c8c8ff
|
||||
SLIDER_DEFAULT_COLOR 0xbcecffff
|
||||
SLIDER_HOVER_COLOR 0xffffffff
|
||||
SLIDER_ACTIVE_COLOR 0xddf5ffff
|
||||
SLIDERBAR_BORDER_COLOR 0x828282ff
|
||||
SLIDERBAR_INSIDE_COLOR 0xc8c8c8ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0xbcecffff
|
||||
SLIDERBAR_HOVER_COLOR 0xffffffff
|
||||
SLIDERBAR_ACTIVE_COLOR 0xddf5ffff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x828282ff
|
||||
PROGRESSBAR_BORDER_COLOR 0x828282ff
|
||||
PROGRESSBAR_INSIDE_COLOR 0xc8c8c8ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0xbcecffff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x828282ff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0xc8c8c8ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x828282ff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0xc8c8c8ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0xc8c8c8ff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0xffffffff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0xff
|
||||
SPINNER_HOVER_TEXT_COLOR 0xff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x7bb0d6ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0xbcecffff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0x5f9aa7ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x14
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0xc8c8c8ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0x828282ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0x828282ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0x828282ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0x828282ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x7bb0d6ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0xbcecffff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0x5f9aa7ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x78acff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x66e7ffff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0x78acff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x66e7ffff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0xddf5ffff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0xbcecffff
|
||||
CHECKBOX_INSIDE_WIDTH 0x1
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x828282ff
|
||||
TEXTBOX_INSIDE_COLOR 0xf5f5f5ff
|
||||
TEXTBOX_TEXT_COLOR 0xff
|
||||
TEXTBOX_LINE_COLOR 0xff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0xff80c1ff
|
||||
GLOBAL_BORDER_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_COLOR 0x650065ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xffd4eaff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0x650065ff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0xffc6e3ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0x650065ff
|
||||
BUTTON_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0xffc6e3ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0x761c76ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x7bb0d6ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0xffb8dcff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xa971a9ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0xffc6e3ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0x650065ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0xffc6e3ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0x761c76ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0xbdd7eaff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0xffb8dcff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xa971a9ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x7bb0d6ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0xff8ec7ff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xa971a9ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x828282ff
|
||||
SLIDER_INSIDE_COLOR 0xffc6e3ff
|
||||
SLIDER_DEFAULT_COLOR 0xffaad5ff
|
||||
SLIDER_HOVER_COLOR 0xff9cceff
|
||||
SLIDER_ACTIVE_COLOR 0xff80c1ff
|
||||
SLIDERBAR_BORDER_COLOR 0x828282ff
|
||||
SLIDERBAR_INSIDE_COLOR 0xffc6e3ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0xffaad5ff
|
||||
SLIDERBAR_HOVER_COLOR 0xff9cceff
|
||||
SLIDERBAR_ACTIVE_COLOR 0xff80c1ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0xff8ec7ff
|
||||
PROGRESSBAR_BORDER_COLOR 0x828282ff
|
||||
PROGRESSBAR_INSIDE_COLOR 0xffc6e3ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0xffaad5ff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x828282ff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0xffc6e3ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x828282ff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0xffc6e3ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0x650065ff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0x650065ff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0xc8c8c8ff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0xffc6e3ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0x761c76ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0x761c76ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x7bb0d6ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0xffb8dcff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xa971a9ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xa971a9ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0xffc6e3ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0x650065ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0x650065ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0xffc6e3ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0x761c76ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0x761c76ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x7bb0d6ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0xff8ec7ff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xba8dbaff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x78acff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0xff8ec7ff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xba8dbaff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x828282ff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0xffc6e3ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0xc8c8c8ff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x66e7ffff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0xffaad5ff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0xff8ec7ff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x828282ff
|
||||
TEXTBOX_INSIDE_COLOR 0xffc6e3ff
|
||||
TEXTBOX_TEXT_COLOR 0x650065ff
|
||||
TEXTBOX_LINE_COLOR 0x985598ff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0x262921ff
|
||||
GLOBAL_BORDER_COLOR 0x102ff
|
||||
GLOBAL_TEXT_COLOR 0xf8f8f1ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xb6b7b5ff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0xf8f8f1ff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0x9e9f9cff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0x9e9f9cff
|
||||
BUTTON_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x102ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0x868883ff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0x9e9f9cff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0x9e9f9cff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x102ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0x868883ff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x102ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x3e4039ff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x38393aff
|
||||
SLIDER_INSIDE_COLOR 0x9e9f9cff
|
||||
SLIDER_DEFAULT_COLOR 0x6e706bff
|
||||
SLIDER_HOVER_COLOR 0x565852ff
|
||||
SLIDER_ACTIVE_COLOR 0x262921ff
|
||||
SLIDERBAR_BORDER_COLOR 0x38393aff
|
||||
SLIDERBAR_INSIDE_COLOR 0x9e9f9cff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x6e706bff
|
||||
SLIDERBAR_HOVER_COLOR 0x565852ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0x262921ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x3e4039ff
|
||||
PROGRESSBAR_BORDER_COLOR 0x38393aff
|
||||
PROGRESSBAR_INSIDE_COLOR 0x9e9f9cff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x6e706bff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x38393aff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0x9e9f9cff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x38393aff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0x9e9f9cff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xf8f8f1ff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x1c1d1eff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0x9e9f9cff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0xf8f8f2ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x102ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0x868883ff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xfbfbf7ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0x9e9f9cff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0xf8f8f1ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0x9e9f9cff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0xf8f8f2ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x3e4039ff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xfbfbf8ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x3e4039ff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xfbfbf8ff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0x9e9f9cff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x102ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x6e706bff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x3e4039ff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x38393aff
|
||||
TEXTBOX_INSIDE_COLOR 0x9e9f9cff
|
||||
TEXTBOX_TEXT_COLOR 0xf8f8f1ff
|
||||
TEXTBOX_LINE_COLOR 0xfafaf5ff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0x293034ff
|
||||
GLOBAL_BORDER_COLOR 0x102ff
|
||||
GLOBAL_TEXT_COLOR 0xa8e2aeff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xb7babbff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0xa8e2aeff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0x9fa3a4ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0xa8e2aeff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0x9fa3a4ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0xb1e5b7ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x102ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0x888c8eff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xceeed2ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0x9fa3a4ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0xa8e2aeff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0x9fa3a4ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0xb1e5b7ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x102ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0x888c8eff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xceeed2ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x102ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x40474aff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xceeed2ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x38393aff
|
||||
SLIDER_INSIDE_COLOR 0x9fa3a4ff
|
||||
SLIDER_DEFAULT_COLOR 0x707577ff
|
||||
SLIDER_HOVER_COLOR 0x585e61ff
|
||||
SLIDER_ACTIVE_COLOR 0x293034ff
|
||||
SLIDERBAR_BORDER_COLOR 0x38393aff
|
||||
SLIDERBAR_INSIDE_COLOR 0x9fa3a4ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x707577ff
|
||||
SLIDERBAR_HOVER_COLOR 0x585e61ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0x293034ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x40474aff
|
||||
PROGRESSBAR_BORDER_COLOR 0x38393aff
|
||||
PROGRESSBAR_INSIDE_COLOR 0x9fa3a4ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x707577ff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x38393aff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0x9fa3a4ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x38393aff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0x9fa3a4ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xa8e2aeff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xa8e2aeff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x1c1d1eff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0x9fa3a4ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0xb1e5b7ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0xb1e5b7ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x102ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0x888c8eff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xceeed2ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xceeed2ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0x9fa3a4ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0xa8e2aeff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0xa8e2aeff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0x9fa3a4ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0xb1e5b7ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0xb1e5b7ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x40474aff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xd8f2dbff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x40474aff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xd8f2dbff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0x9fa3a4ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x102ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x707577ff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x40474aff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x38393aff
|
||||
TEXTBOX_INSIDE_COLOR 0x9fa3a4ff
|
||||
TEXTBOX_TEXT_COLOR 0xa8e2aeff
|
||||
TEXTBOX_LINE_COLOR 0xc5ebc9ff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0x2b36ff
|
||||
GLOBAL_BORDER_COLOR 0x102ff
|
||||
GLOBAL_TEXT_COLOR 0xf8f8f1ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xaab8bcff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0xf8f8f1ff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0x8da0a5ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0x8da0a5ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x102ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0x71898fff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0x8da0a5ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0x8da0a5ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x102ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0x71898fff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x102ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x1c424cff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xfbfbf7ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x38393aff
|
||||
SLIDER_INSIDE_COLOR 0x8da0a5ff
|
||||
SLIDER_DEFAULT_COLOR 0x557179ff
|
||||
SLIDER_HOVER_COLOR 0x385a62ff
|
||||
SLIDER_ACTIVE_COLOR 0x2b36ff
|
||||
SLIDERBAR_BORDER_COLOR 0x38393aff
|
||||
SLIDERBAR_INSIDE_COLOR 0x8da0a5ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x557179ff
|
||||
SLIDERBAR_HOVER_COLOR 0x385a62ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0x2b36ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0x1c424cff
|
||||
PROGRESSBAR_BORDER_COLOR 0x38393aff
|
||||
PROGRESSBAR_INSIDE_COLOR 0x8da0a5ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x557179ff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x38393aff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0x8da0a5ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x38393aff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0x8da0a5ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xf8f8f1ff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x1c1d1eff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0x8da0a5ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0xf8f8f2ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x102ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0x71898fff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xfbfbf7ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xfbfbf7ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0x8da0a5ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0xf8f8f1ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0xf8f8f1ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0x8da0a5ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0xf8f8f2ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0xf8f8f2ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x1c424cff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xfbfbf8ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x1c424cff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xfbfbf8ff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0x8da0a5ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x102ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x557179ff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x1c424cff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x38393aff
|
||||
TEXTBOX_INSIDE_COLOR 0x8da0a5ff
|
||||
TEXTBOX_TEXT_COLOR 0xf8f8f1ff
|
||||
TEXTBOX_LINE_COLOR 0xfafaf5ff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0xfcf6e3ff
|
||||
GLOBAL_BORDER_COLOR 0x102ff
|
||||
GLOBAL_TEXT_COLOR 0x657b82ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0xfefcf5ff
|
||||
LABEL_BORDER_WIDTH 0x1
|
||||
LABEL_TEXT_COLOR 0x657b82ff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x2
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0xfdfbf2ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0x657b82ff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0xfdfbf2ff
|
||||
BUTTON_HOVER_TEXT_COLOR 0x76898fff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x102ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0xfdfaefff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0xa9b5b9ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0xfdfbf2ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0x657b82ff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0xfdfbf2ff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0x76898fff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x102ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0xfdfaefff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0xa9b5b9ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0x102ff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0xfcf7e6ff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xa9b5b9ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x1
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x1
|
||||
SLIDER_BORDER_COLOR 0x38393aff
|
||||
SLIDER_INSIDE_COLOR 0xfdfbf2ff
|
||||
SLIDER_DEFAULT_COLOR 0xfdf9ecff
|
||||
SLIDER_HOVER_COLOR 0xfcf8e9ff
|
||||
SLIDER_ACTIVE_COLOR 0xfcf6e3ff
|
||||
SLIDERBAR_BORDER_COLOR 0x38393aff
|
||||
SLIDERBAR_INSIDE_COLOR 0xfdfbf2ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0xfdf9ecff
|
||||
SLIDERBAR_HOVER_COLOR 0xfcf8e9ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0xfcf6e3ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0xfcf7e6ff
|
||||
PROGRESSBAR_BORDER_COLOR 0x38393aff
|
||||
PROGRESSBAR_INSIDE_COLOR 0xfdfbf2ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0xfdf9ecff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x2
|
||||
SPINNER_LABEL_BORDER_COLOR 0x38393aff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0xfdfbf2ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x38393aff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0xfdfbf2ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0x657b82ff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0x657b82ff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x1c1d1eff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0xfdfbf2ff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0x76898fff
|
||||
SPINNER_HOVER_TEXT_COLOR 0x76898fff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x102ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0xfdfaefff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0xa9b5b9ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0xa9b5b9ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0xfdfbf2ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0x657b82ff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0x657b82ff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0xfdfbf2ff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0x76898fff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0x76898fff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0xfcf7e6ff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0xbac4c7ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x102ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0xfcf7e6ff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0xbac4c7ff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x38393aff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0xfdfbf2ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x1c1d1eff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0xffffffff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x102ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0xfdf9ecff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0xfcf7e6ff
|
||||
CHECKBOX_INSIDE_WIDTH 0x4
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x38393aff
|
||||
TEXTBOX_INSIDE_COLOR 0xfdfbf2ff
|
||||
TEXTBOX_TEXT_COLOR 0x657b82ff
|
||||
TEXTBOX_LINE_COLOR 0x98a7abff
|
||||
TEXTBOX_TEXT_FONTSIZE 0xa
|
|
@ -1,98 +0,0 @@
|
|||
GLOBAL_BASE_COLOR 0xf5f5f5ff
|
||||
GLOBAL_BORDER_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_COLOR 0xf5f5f5ff
|
||||
GLOBAL_TEXT_FONTSIZE 0xa
|
||||
GLOBAL_BORDER_WIDTH 0x1
|
||||
BACKGROUND_COLOR 0x2d2d2dff
|
||||
LABEL_BORDER_WIDTH 0x2
|
||||
LABEL_TEXT_COLOR 0xafafafff
|
||||
LABEL_TEXT_PADDING 0x14
|
||||
BUTTON_BORDER_WIDTH 0x1
|
||||
BUTTON_TEXT_PADDING 0x14
|
||||
BUTTON_DEFAULT_BORDER_COLOR 0x414141ff
|
||||
BUTTON_DEFAULT_INSIDE_COLOR 0x323232ff
|
||||
BUTTON_DEFAULT_TEXT_COLOR 0xafafafff
|
||||
BUTTON_HOVER_BORDER_COLOR 0x3e3e3eff
|
||||
BUTTON_HOVER_INSIDE_COLOR 0x2d2d2dff
|
||||
BUTTON_HOVER_TEXT_COLOR 0x767472ff
|
||||
BUTTON_PRESSED_BORDER_COLOR 0x414141ff
|
||||
BUTTON_PRESSED_INSIDE_COLOR 0x323232ff
|
||||
BUTTON_PRESSED_TEXT_COLOR 0x616161ff
|
||||
TOGGLE_TEXT_PADDING 0x14
|
||||
TOGGLE_BORDER_WIDTH 0x1
|
||||
TOGGLE_DEFAULT_BORDER_COLOR 0x414141ff
|
||||
TOGGLE_DEFAULT_INSIDE_COLOR 0x323232ff
|
||||
TOGGLE_DEFAULT_TEXT_COLOR 0xafafafff
|
||||
TOGGLE_HOVER_BORDER_COLOR 0x3e3e3eff
|
||||
TOGGLE_HOVER_INSIDE_COLOR 0x2d2d2dff
|
||||
TOGGLE_HOVER_TEXT_COLOR 0x767472ff
|
||||
TOGGLE_PRESSED_BORDER_COLOR 0x414141ff
|
||||
TOGGLE_PRESSED_INSIDE_COLOR 0x323232ff
|
||||
TOGGLE_PRESSED_TEXT_COLOR 0x616161ff
|
||||
TOGGLE_ACTIVE_BORDER_COLOR 0xafafafff
|
||||
TOGGLE_ACTIVE_INSIDE_COLOR 0x414141ff
|
||||
TOGGLE_ACTIVE_TEXT_COLOR 0xa3a3a3ff
|
||||
TOGGLEGROUP_PADDING 0x3
|
||||
SLIDER_BORDER_WIDTH 0x0
|
||||
SLIDER_BUTTON_BORDER_WIDTH 0x0
|
||||
SLIDER_BORDER_COLOR 0x414141ff
|
||||
SLIDER_INSIDE_COLOR 0x232525ff
|
||||
SLIDER_DEFAULT_COLOR 0x646464ff
|
||||
SLIDER_HOVER_COLOR 0x767472ff
|
||||
SLIDER_ACTIVE_COLOR 0x929291ff
|
||||
SLIDERBAR_BORDER_COLOR 0x828282ff
|
||||
SLIDERBAR_INSIDE_COLOR 0x262626ff
|
||||
SLIDERBAR_DEFAULT_COLOR 0x616161ff
|
||||
SLIDERBAR_HOVER_COLOR 0x646464ff
|
||||
SLIDERBAR_ACTIVE_COLOR 0x929292ff
|
||||
SLIDERBAR_ZERO_LINE_COLOR 0xafafafff
|
||||
PROGRESSBAR_BORDER_COLOR 0x828282ff
|
||||
PROGRESSBAR_INSIDE_COLOR 0x262626ff
|
||||
PROGRESSBAR_PROGRESS_COLOR 0x646464ff
|
||||
PROGRESSBAR_BORDER_WIDTH 0x0
|
||||
SPINNER_LABEL_BORDER_COLOR 0x414141ff
|
||||
SPINNER_LABEL_INSIDE_COLOR 0x323232ff
|
||||
SPINNER_DEFAULT_BUTTON_BORDER_COLOR 0x414141ff
|
||||
SPINNER_DEFAULT_BUTTON_INSIDE_COLOR 0x323232ff
|
||||
SPINNER_DEFAULT_SYMBOL_COLOR 0xafafafff
|
||||
SPINNER_DEFAULT_TEXT_COLOR 0xafafafff
|
||||
SPINNER_HOVER_BUTTON_BORDER_COLOR 0x3e3e3eff
|
||||
SPINNER_HOVER_BUTTON_INSIDE_COLOR 0x2d2d2dff
|
||||
SPINNER_HOVER_SYMBOL_COLOR 0x767472ff
|
||||
SPINNER_HOVER_TEXT_COLOR 0x767472ff
|
||||
SPINNER_PRESSED_BUTTON_BORDER_COLOR 0x414141ff
|
||||
SPINNER_PRESSED_BUTTON_INSIDE_COLOR 0x323232ff
|
||||
SPINNER_PRESSED_SYMBOL_COLOR 0x646464ff
|
||||
SPINNER_PRESSED_TEXT_COLOR 0x646464ff
|
||||
COMBOBOX_PADDING 0x1
|
||||
COMBOBOX_BUTTON_WIDTH 0x1e
|
||||
COMBOBOX_BUTTON_HEIGHT 0x1e
|
||||
COMBOBOX_BORDER_WIDTH 0x1
|
||||
COMBOBOX_DEFAULT_BORDER_COLOR 0x414141ff
|
||||
COMBOBOX_DEFAULT_INSIDE_COLOR 0x323232ff
|
||||
COMBOBOX_DEFAULT_TEXT_COLOR 0xafafafff
|
||||
COMBOBOX_DEFAULT_LIST_TEXT_COLOR 0xafafafff
|
||||
COMBOBOX_HOVER_BORDER_COLOR 0x3e3e3eff
|
||||
COMBOBOX_HOVER_INSIDE_COLOR 0x2d2d2dff
|
||||
COMBOBOX_HOVER_TEXT_COLOR 0x767472ff
|
||||
COMBOBOX_HOVER_LIST_TEXT_COLOR 0x767472ff
|
||||
COMBOBOX_PRESSED_BORDER_COLOR 0x414141ff
|
||||
COMBOBOX_PRESSED_INSIDE_COLOR 0x323232ff
|
||||
COMBOBOX_PRESSED_TEXT_COLOR 0x646464ff
|
||||
COMBOBOX_PRESSED_LIST_BORDER_COLOR 0x414141ff
|
||||
COMBOBOX_PRESSED_LIST_INSIDE_COLOR 0x323232ff
|
||||
COMBOBOX_PRESSED_LIST_TEXT_COLOR 0x646464ff
|
||||
CHECKBOX_DEFAULT_BORDER_COLOR 0x414141ff
|
||||
CHECKBOX_DEFAULT_INSIDE_COLOR 0x323232ff
|
||||
CHECKBOX_HOVER_BORDER_COLOR 0x3e3e3eff
|
||||
CHECKBOX_HOVER_INSIDE_COLOR 0x2d2d2dff
|
||||
CHECKBOX_CLICK_BORDER_COLOR 0x414141ff
|
||||
CHECKBOX_CLICK_INSIDE_COLOR 0x323232ff
|
||||
CHECKBOX_STATUS_ACTIVE_COLOR 0x414141ff
|
||||
CHECKBOX_INSIDE_WIDTH 0x2
|
||||
TEXTBOX_BORDER_WIDTH 0x1
|
||||
TEXTBOX_BORDER_COLOR 0x414141ff
|
||||
TEXTBOX_INSIDE_COLOR 0x323232ff
|
||||
TEXTBOX_TEXT_COLOR 0xafafafff
|
||||
TEXTBOX_LINE_COLOR 0xafafafff
|
||||
TEXTBOX_TEXT_FONTSIZE 0x9
|
|
@ -1,5 +0,0 @@
|
|||
module example
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/Konstantin8105/raylib-go/raygui v0.0.0-20221122151443-e8a384ed1346 // indirect
|
|
@ -1,30 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
rl "github.com/Konstantin8105/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [physics] example - box2d")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
var button bool
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Black)
|
||||
|
||||
button = rl.Button(rl.NewRectangle(50, 150, 100, 40), "Click")
|
||||
if button {
|
||||
fmt.Println("Clicked on button")
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 22 KiB |
|
@ -1,48 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(5.0, 4.0, 5.0)
|
||||
camera.Target = rl.NewVector3(0.0, 2.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
bill := rl.LoadTexture("billboard.png") // Our texture billboard
|
||||
billPosition := rl.NewVector3(0.0, 2.0, 0.0) // Position where draw billboard
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
rl.DrawBillboard(camera, bill, billPosition, 2.0, rl.White)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(bill) // Unload texture
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(0.0, 10.0, 10.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
playerPosition := rl.NewVector3(0.0, 1.0, 2.0)
|
||||
playerSize := rl.NewVector3(1.0, 2.0, 1.0)
|
||||
playerColor := rl.Green
|
||||
|
||||
enemyBoxPos := rl.NewVector3(-4.0, 1.0, 0.0)
|
||||
enemyBoxSize := rl.NewVector3(2.0, 2.0, 2.0)
|
||||
|
||||
enemySpherePos := rl.NewVector3(4.0, 0.0, 0.0)
|
||||
enemySphereSize := float32(1.5)
|
||||
|
||||
collision := false
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
|
||||
// Move player
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
playerPosition.X += 0.2
|
||||
} else if rl.IsKeyDown(rl.KeyLeft) {
|
||||
playerPosition.X -= 0.2
|
||||
} else if rl.IsKeyDown(rl.KeyDown) {
|
||||
playerPosition.Z += 0.2
|
||||
} else if rl.IsKeyDown(rl.KeyUp) {
|
||||
playerPosition.Z -= 0.2
|
||||
}
|
||||
|
||||
collision = false
|
||||
|
||||
// Check collisions player vs enemy-box
|
||||
if rl.CheckCollisionBoxes(
|
||||
rl.NewBoundingBox(
|
||||
rl.NewVector3(playerPosition.X-playerSize.X/2, playerPosition.Y-playerSize.Y/2, playerPosition.Z-playerSize.Z/2),
|
||||
rl.NewVector3(playerPosition.X+playerSize.X/2, playerPosition.Y+playerSize.Y/2, playerPosition.Z+playerSize.Z/2)),
|
||||
rl.NewBoundingBox(
|
||||
rl.NewVector3(enemyBoxPos.X-enemyBoxSize.X/2, enemyBoxPos.Y-enemyBoxSize.Y/2, enemyBoxPos.Z-enemyBoxSize.Z/2),
|
||||
rl.NewVector3(enemyBoxPos.X+enemyBoxSize.X/2, enemyBoxPos.Y+enemyBoxSize.Y/2, enemyBoxPos.Z+enemyBoxSize.Z/2)),
|
||||
) {
|
||||
collision = true
|
||||
}
|
||||
|
||||
// Check collisions player vs enemy-sphere
|
||||
if rl.CheckCollisionBoxSphere(
|
||||
rl.NewBoundingBox(
|
||||
rl.NewVector3(playerPosition.X-playerSize.X/2, playerPosition.Y-playerSize.Y/2, playerPosition.Z-playerSize.Z/2),
|
||||
rl.NewVector3(playerPosition.X+playerSize.X/2, playerPosition.Y+playerSize.Y/2, playerPosition.Z+playerSize.Z/2)),
|
||||
enemySpherePos,
|
||||
enemySphereSize,
|
||||
) {
|
||||
collision = true
|
||||
}
|
||||
|
||||
if collision {
|
||||
playerColor = rl.Red
|
||||
} else {
|
||||
playerColor = rl.Green
|
||||
}
|
||||
|
||||
// Draw
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
// Draw enemy-box
|
||||
rl.DrawCube(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, rl.Gray)
|
||||
rl.DrawCubeWires(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, rl.DarkGray)
|
||||
|
||||
// Draw enemy-sphere
|
||||
rl.DrawSphere(enemySpherePos, enemySphereSize, rl.Gray)
|
||||
rl.DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, rl.DarkGray)
|
||||
|
||||
// Draw player
|
||||
rl.DrawCubeV(playerPosition, playerSize, playerColor)
|
||||
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawText("Move player with cursors to collide", 220, 40, 20, rl.Gray)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 36 KiB |
|
@ -1,70 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(16.0, 14.0, 16.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
image := rl.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubicmap := rl.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||
|
||||
mesh := rl.GenMeshCubicmap(*image, rl.NewVector3(1.0, 1.0, 1.0))
|
||||
model := rl.LoadModelFromMesh(mesh)
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||
|
||||
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
|
||||
rl.UnloadImage(image) // Unload cubicmap image from RAM, already uploaded to VRAM
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
// Draw
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawModel(model, mapPosition, 1.0, rl.White)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawTextureEx(cubicmap, rl.NewVector2(float32(screenWidth-cubicmap.Width*4-20), 20), 0.0, 4.0, rl.White)
|
||||
rl.DrawRectangleLines(screenWidth-cubicmap.Width*4-20, 20, cubicmap.Width*4, cubicmap.Height*4, rl.Green)
|
||||
|
||||
rl.DrawText("cubicmap image used to", 658, 90, 10, rl.Gray)
|
||||
rl.DrawText("generate map 3d model", 658, 104, 10, rl.Gray)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(cubicmap) // Unload cubicmap texture
|
||||
rl.UnloadTexture(texture) // Unload map texture
|
||||
rl.UnloadModel(model) // Unload map model
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 36 KiB |
|
@ -1,119 +0,0 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - first person maze
|
||||
*
|
||||
* This example has been created using raylib-go v0.0.0-20220104071325-2f072dc2d259 (https://github.com/gen2brain/raylib-go)
|
||||
* raylib-go is licensed under an unmodified zlib/libpng license (https://github.com/gen2brain/raylib-go/blob/master/LICENSE)
|
||||
*
|
||||
* Original C version for Raylib 2.5 Copyright (c) 2019 Ramon Santamaria (@raysan5)
|
||||
* Converted to Go by Michael Redman January 4, 2022
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
var screenWidth int32 = 800
|
||||
var screenHeight int32 = 450
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze")
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(0.2, 0.4, 0.2)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
imMap := rl.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubicmap := rl.LoadTextureFromImage(imMap) // Convert image to texture to display (VRAM)
|
||||
mesh := rl.GenMeshCubicmap(*imMap, rl.NewVector3(1.0, 1.0, 1.0))
|
||||
model := rl.LoadModelFromMesh(mesh)
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
texture := rl.LoadTexture("cubicmap_atlas.png") // load map texture
|
||||
model.Materials.GetMap(rl.MapDiffuse).Texture = texture // Set map diffuse texture
|
||||
// Get map image data to be used for collision detectio
|
||||
mapPixels := rl.LoadImageColors(imMap)
|
||||
rl.UnloadImage(imMap) // Unload image from RAM
|
||||
|
||||
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFirstPerson) // Set camera mode
|
||||
|
||||
rl.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
for !rl.WindowShouldClose() { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
oldCamPos := camera.Position // Store old camera position
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
// Check player collision (we simplify to 2D collision detection)
|
||||
playerPos := rl.NewVector2(camera.Position.X, camera.Position.Z)
|
||||
playerRadius := 0.1 // Collision radius (player is modelled as a cylinder for collision)
|
||||
|
||||
playerCellX := (int)(playerPos.X - mapPosition.X + 0.5)
|
||||
playerCellY := (int)(playerPos.Y - mapPosition.Z + 0.5)
|
||||
|
||||
// Out-of-limits security check
|
||||
if playerCellX < 0 {
|
||||
playerCellX = 0
|
||||
} else if playerCellX >= int(cubicmap.Width) {
|
||||
playerCellX = int(cubicmap.Width) - 1
|
||||
}
|
||||
|
||||
if playerCellY < 0 {
|
||||
playerCellY = 0
|
||||
} else if playerCellY >= int(cubicmap.Height) {
|
||||
playerCellY = int(cubicmap.Height) - 1
|
||||
}
|
||||
|
||||
// Check map collisions using image data and player position
|
||||
// TODO: Improvement: Just check player surrounding cells for collision
|
||||
for y := 0; y < int(cubicmap.Height); y++ {
|
||||
for x := 0; x < int(cubicmap.Width); x++ {
|
||||
// Collision: white pixel, only check R channel
|
||||
if mapPixels[y*int(cubicmap.Width)+x].R == 255 && (rl.CheckCollisionCircleRec(playerPos, float32(playerRadius), rl.NewRectangle(float32(mapPosition.X-0.5+float32(x)), float32(mapPosition.Z-0.5+float32(y)), 1.0, 1.0))) {
|
||||
// Collision detected, reset camera position
|
||||
camera.Position = oldCamPos
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.BeginMode3D(camera)
|
||||
rl.DrawModel(model, mapPosition, 1.0, rl.White) // Draw maze map
|
||||
rl.EndMode3D()
|
||||
rl.DrawTextureEx(cubicmap, rl.NewVector2(float32(rl.GetScreenWidth())-float32(cubicmap.Width)*4.0-20, 20.0), 0.0, 4.0, rl.White)
|
||||
rl.DrawRectangleLines(int32(rl.GetScreenWidth())-cubicmap.Width*4-20, 20, cubicmap.Width*4, cubicmap.Height*4, rl.Green)
|
||||
// Draw player position radar
|
||||
rl.DrawRectangle(int32(rl.GetScreenWidth()-int(cubicmap.Width*4)-20+(playerCellX*4)), int32(20+playerCellY*4), 4, 4, rl.Red)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
rl.UnloadTexture(cubicmap) // Unload cubicmap texture
|
||||
rl.UnloadTexture(texture) // Unload map texture
|
||||
rl.UnloadModel(model) // Unload map model
|
||||
rl.CloseWindow() // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(0.0, 10.0, 10.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawCube(rl.NewVector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, rl.Red)
|
||||
rl.DrawCubeWires(rl.NewVector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, rl.Gold)
|
||||
rl.DrawCubeWires(rl.NewVector3(-4.0, 0.0, -2.0), 3.0, 6.0, 2.0, rl.Maroon)
|
||||
|
||||
rl.DrawSphere(rl.NewVector3(-1.0, 0.0, -2.0), 1.0, rl.Green)
|
||||
rl.DrawSphereWires(rl.NewVector3(1.0, 0.0, 2.0), 2.0, 16, 16, rl.Lime)
|
||||
|
||||
rl.DrawCylinder(rl.NewVector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, rl.SkyBlue)
|
||||
rl.DrawCylinderWires(rl.NewVector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, rl.DarkBlue)
|
||||
rl.DrawCylinderWires(rl.NewVector3(4.5, -1.0, 2.0), 1.0, 1.0, 2.0, 6, rl.Brown)
|
||||
|
||||
rl.DrawCylinder(rl.NewVector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, rl.Gold)
|
||||
rl.DrawCylinderWires(rl.NewVector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, rl.Pink)
|
||||
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 11 KiB |
|
@ -1,68 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(18.0, 16.0, 18.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
image := rl.LoadImage("heightmap.png") // Load heightmap image (RAM)
|
||||
texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
||||
|
||||
mesh := rl.GenMeshHeightmap(*image, rl.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
|
||||
model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
|
||||
|
||||
rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||
|
||||
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||
|
||||
rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
// Draw
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawModel(model, mapPosition, 1.0, rl.Red)
|
||||
|
||||
rl.DrawGrid(20, 1.0)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawTexture(texture, screenWidth-texture.Width-20, 20, rl.White)
|
||||
rl.DrawRectangleLines(screenWidth-texture.Width-20, 20, texture.Width, texture.Height, rl.Green)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(texture) // Unload map texture
|
||||
rl.UnloadModel(model) // Unload map model
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 434 KiB |
|
@ -1,51 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(50.0, 50.0, 50.0)
|
||||
camera.Target = rl.NewVector3(0.0, 10.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
obj := rl.LoadModel("castle.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("castle_diffuse.png") // Load model texture
|
||||
|
||||
rl.SetMaterialTexture(obj.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawModel(obj, position, 1.0, rl.White) // Draw 3d model with texture
|
||||
|
||||
rl.DrawGrid(20, 10.0) // Draw a grid
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.DrawText("(c) Castle 3D model by Alberto Cano", screenWidth-200, screenHeight-20, 10, rl.Gray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(texture) // Unload texture
|
||||
rl.UnloadModel(obj) // Unload model
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
### Android example
|
||||
|
||||
To compile example to shared library you will need [Android NDK](https://developer.android.com/ndk/downloads/index.html).
|
||||
To build Android apk you will need [Android SDK](http://developer.android.com/sdk/index.html#Other).
|
||||
|
||||
Export path to Android NDK, point to location where you have unpacked archive:
|
||||
|
||||
export ANDROID_NDK_HOME=/opt/android-ndk
|
||||
|
||||
Add toolchain bin directory to PATH:
|
||||
|
||||
export PATH=${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:${PATH}
|
||||
|
||||
Export sysroot and libdirs:
|
||||
|
||||
export ANDROID_SYSROOT=${ANDROID_NDK_HOME}/sysroot
|
||||
export ANDROID_PLATFORM=${ANDROID_NDK_HOME}/platforms/android-16/arch-arm
|
||||
export ANDROID_TOOLCHAIN=${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
|
||||
|
||||
And compile shared library:
|
||||
|
||||
CC="arm-linux-androideabi-gcc" \
|
||||
CGO_CFLAGS="-I${ANDROID_SYSROOT}/usr/include -I${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi --sysroot=${ANDROID_SYSROOT} -D__ANDROID_API__=16" \
|
||||
CGO_LDFLAGS="-L${ANDROID_SYSROOT}/usr/lib/arm-linux-androideabi -L${ANDROID_PLATFORM}/usr/lib -L${ANDROID_TOOLCHAIN}/arm-linux-androideabi/lib -L${ANDROID_TOOLCHAIN}/lib/gcc/arm-linux-androideabi/4.9.x --sysroot=${ANDROID_PLATFORM}" \
|
||||
CGO_ENABLED=1 GOOS=android GOARCH=arm \
|
||||
go build -buildmode=c-shared -ldflags="-s -w -extldflags=-Wl,-soname,libexample.so" \
|
||||
-o=android/libs/armeabi-v7a/libexample.so
|
||||
|
||||
To build apk export path to Android SDK, point to location where you unpacked archive:
|
||||
|
||||
export ANDROID_HOME=/opt/android-sdk
|
||||
|
||||
And build apk with ant:
|
||||
|
||||
cd android
|
||||
ant clean debug
|
||||
|
||||
Or with gradle:
|
||||
|
||||
./gradlew assembleDebug
|
||||
|
||||
If everything is successfully built apk can be found in bin/ directory or in the android/build/outputs in case `gradle` is used.
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.gen2brain.raylib.go"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
<!-- We do not have Java code. Therefore android:hasCode is set to false. -->
|
||||
<application android:allowBackup="false" android:hasCode="false"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
|
||||
|
||||
<!-- Our activity is the built-in NativeActivity framework class. -->
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:screenOrientation="landscape"
|
||||
android:clearTaskOnLaunch="true">
|
||||
|
||||
<!-- Tell NativeActivity the name of our .so -->
|
||||
<meta-data android:name="android.app.lib_name" android:value="example" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
Before Width: | Height: | Size: 3.7 KiB |
|
@ -1,34 +0,0 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion '27.0.3'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.android"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionName '1.0'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
zipAlignEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jniLibs.srcDirs = ['libs']
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="example" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env" />
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME" />
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -1,2 +0,0 @@
|
|||
# Project target.
|
||||
target=android-27
|
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 922 B |
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">raylib-go</string>
|
||||
</resources>
|
|
@ -1,16 +0,0 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
#Mon Nov 13 02:02:23 CET 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
160
examples/others/android/example/gradlew
vendored
|
@ -1,160 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
examples/others/android/example/gradlew.bat
vendored
|
@ -1,90 +0,0 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -1,123 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// Game states
|
||||
const (
|
||||
Logo = iota
|
||||
Title
|
||||
GamePlay
|
||||
Ending
|
||||
)
|
||||
|
||||
func init() {
|
||||
rl.SetCallbackFunc(main)
|
||||
}
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "Android example")
|
||||
|
||||
rl.InitAudioDevice()
|
||||
|
||||
currentScreen := Logo
|
||||
windowShouldClose := false
|
||||
|
||||
texture := rl.LoadTexture("raylib_logo.png") // Load texture (placed on assets folder)
|
||||
fx := rl.LoadSound("coin.wav") // Load WAV audio file (placed on assets folder)
|
||||
ambient := rl.LoadMusicStream("ambient.ogg") // Load music
|
||||
|
||||
rl.PlayMusicStream(ambient)
|
||||
|
||||
framesCounter := 0 // Used to count frames
|
||||
|
||||
//rl.SetTargetFPS(60)
|
||||
|
||||
for !windowShouldClose {
|
||||
rl.UpdateMusicStream(ambient)
|
||||
|
||||
if runtime.GOOS == "android" && rl.IsKeyDown(rl.KeyBack) || rl.WindowShouldClose() {
|
||||
windowShouldClose = true
|
||||
}
|
||||
|
||||
switch currentScreen {
|
||||
case Logo:
|
||||
framesCounter++ // Count frames
|
||||
|
||||
// Wait for 4 seconds (240 frames) before jumping to Title screen
|
||||
if framesCounter > 240 {
|
||||
currentScreen = Title
|
||||
}
|
||||
break
|
||||
case Title:
|
||||
// Press enter to change to GamePlay screen
|
||||
if rl.IsGestureDetected(rl.GestureTap) {
|
||||
rl.PlaySound(fx)
|
||||
currentScreen = GamePlay
|
||||
}
|
||||
break
|
||||
case GamePlay:
|
||||
// Press enter to change to Ending screen
|
||||
if rl.IsGestureDetected(rl.GestureTap) {
|
||||
rl.PlaySound(fx)
|
||||
currentScreen = Ending
|
||||
}
|
||||
break
|
||||
case Ending:
|
||||
// Press enter to return to Title screen
|
||||
if rl.IsGestureDetected(rl.GestureTap) {
|
||||
rl.PlaySound(fx)
|
||||
currentScreen = Title
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
switch currentScreen {
|
||||
case Logo:
|
||||
rl.DrawText("LOGO SCREEN", 20, 20, 40, rl.LightGray)
|
||||
rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2, rl.White)
|
||||
rl.DrawText("WAIT for 4 SECONDS...", 290, 400, 20, rl.Gray)
|
||||
break
|
||||
case Title:
|
||||
rl.DrawRectangle(0, 0, screenWidth, screenHeight, rl.Green)
|
||||
rl.DrawText("TITLE SCREEN", 20, 20, 40, rl.DarkGreen)
|
||||
rl.DrawText("TAP SCREEN to JUMP to GAMEPLAY SCREEN", 160, 220, 20, rl.DarkGreen)
|
||||
break
|
||||
case GamePlay:
|
||||
rl.DrawRectangle(0, 0, screenWidth, screenHeight, rl.Purple)
|
||||
rl.DrawText("GAMEPLAY SCREEN", 20, 20, 40, rl.Maroon)
|
||||
rl.DrawText("TAP SCREEN to JUMP to ENDING SCREEN", 170, 220, 20, rl.Maroon)
|
||||
break
|
||||
case Ending:
|
||||
rl.DrawRectangle(0, 0, screenWidth, screenHeight, rl.Blue)
|
||||
rl.DrawText("ENDING SCREEN", 20, 20, 40, rl.DarkBlue)
|
||||
rl.DrawText("TAP SCREEN to RETURN to TITLE SCREEN", 160, 220, 20, rl.DarkBlue)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadSound(fx) // Unload sound data
|
||||
rl.UnloadMusicStream(ambient) // Unload music stream data
|
||||
rl.CloseAudioDevice() // Close audio device (music streaming is automatically stopped)
|
||||
rl.UnloadTexture(texture) // Unload texture data
|
||||
rl.CloseWindow() // Close window
|
||||
|
||||
os.Exit(0)
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
include ':android'
|
|
@ -1,81 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// Bunny type
|
||||
type Bunny struct {
|
||||
Position rl.Vector2
|
||||
Speed rl.Vector2
|
||||
Color rl.Color
|
||||
}
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(1280)
|
||||
screenHeight := int32(960)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - Bunnymark")
|
||||
|
||||
texture := rl.LoadTexture("wabbit_alpha.png")
|
||||
|
||||
bunnies := make([]*Bunny, 0)
|
||||
bunniesCount := 0
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
||||
if rl.IsMouseButtonDown(rl.MouseLeftButton) {
|
||||
// Create more bunnies
|
||||
for i := 0; i < 100; i++ {
|
||||
b := &Bunny{}
|
||||
b.Position = rl.GetMousePosition()
|
||||
b.Speed.X = float32(rl.GetRandomValue(250, 500)) / 60.0
|
||||
b.Speed.Y = float32(rl.GetRandomValue(250, 500)-500) / 60.0
|
||||
|
||||
bunnies = append(bunnies, b)
|
||||
bunniesCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Update bunnies
|
||||
for _, b := range bunnies {
|
||||
b.Position.X += b.Speed.X
|
||||
b.Position.Y += b.Speed.Y
|
||||
|
||||
if (b.Position.X > float32(screenWidth)) || (b.Position.X < 0) {
|
||||
b.Speed.X *= -1
|
||||
}
|
||||
|
||||
if (b.Position.Y > float32(screenHeight)) || (b.Position.Y < 0) {
|
||||
b.Speed.Y *= -1
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
for _, b := range bunnies {
|
||||
// NOTE: When internal QUADS batch limit is reached, a draw call is launched and
|
||||
// batching buffer starts being filled again; before launching the draw call,
|
||||
// updated vertex data from internal buffer is send to GPU... it seems it generates
|
||||
// a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps
|
||||
rl.DrawTexture(texture, int32(b.Position.X), int32(b.Position.Y), rl.RayWhite)
|
||||
}
|
||||
|
||||
rl.DrawRectangle(0, 0, screenWidth, 40, rl.LightGray)
|
||||
rl.DrawText("raylib bunnymark", 10, 10, 20, rl.DarkGray)
|
||||
rl.DrawText(fmt.Sprintf("bunnies: %d", bunniesCount), 400, 10, 20, rl.Red)
|
||||
|
||||
rl.DrawFPS(260, 10)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadTexture(texture)
|
||||
rl.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 449 B |
|
@ -1,18 +0,0 @@
|
|||
### Raspberry Pi example
|
||||
|
||||
To cross compile example for Raspberry Pi you will need [RPi toolchain](https://github.com/raspberrypi/tools/tree/master/arm-bcm2708) and [userspace libraries](https://github.com/raspberrypi/firmware) (opt/vc).
|
||||
|
||||
Export path to RPi toolchain:
|
||||
|
||||
export RPI_HOME=/opt/tools/arm-bcm2708/arm-linux-gnueabihf
|
||||
|
||||
Add toolchain bin directory to PATH:
|
||||
|
||||
export PATH=${RPI_HOME}/bin:${PATH}
|
||||
|
||||
And compile example:
|
||||
|
||||
CC=arm-linux-gnueabihf-gcc \
|
||||
CGO_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads --sysroot=${RPI_HOME}/arm-linux-gnueabihf/sysroot" \
|
||||
CGO_LDFLAGS="-L/opt/vc/lib -L/opt/vc/lib64 --sysroot=${RPI_HOME}/arm-linux-gnueabihf/sysroot" \
|
||||
CGO_ENABLED=1 GOOS=linux GOARCH=arm go build
|
|
@ -1,21 +0,0 @@
|
|||
package main
|
||||
|
||||
import "github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [rpi] example - basic window")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.SetTraceLogCallback(func(logType int, str string) {
|
||||
level := ""
|
||||
switch logType {
|
||||
case rl.LogDebug:
|
||||
level = "Debug"
|
||||
case rl.LogError:
|
||||
level = "Error"
|
||||
case rl.LogInfo:
|
||||
level = "Info"
|
||||
case rl.LogTrace:
|
||||
level = "Trace"
|
||||
case rl.LogWarning:
|
||||
level = "Warning"
|
||||
case rl.LogFatal:
|
||||
level = "Fatal"
|
||||
}
|
||||
if logType != rl.LogFatal {
|
||||
log.Printf("%s - %s", level, str)
|
||||
} else {
|
||||
log.Fatalf("%s - %s", level, str)
|
||||
}
|
||||
})
|
||||
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
rl.InitWindow(800, 450, "raylib [utils] example - SetTraceLogCallback")
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.DrawText("The raylib trace log is controlled in GO!", 190, 200, 20, rl.LightGray)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,513 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
box2d "github.com/neguse/go-box2d-lite/box2dlite"
|
||||
)
|
||||
|
||||
// Game type
|
||||
type Game struct {
|
||||
World *box2d.World
|
||||
TimeStep float64
|
||||
}
|
||||
|
||||
// NewGame - Start new game
|
||||
func NewGame() (g Game) {
|
||||
g.Init()
|
||||
return
|
||||
}
|
||||
|
||||
// Init - Initialize game
|
||||
func (g *Game) Init() {
|
||||
gravity := box2d.Vec2{0.0, -10.0}
|
||||
g.World = box2d.NewWorld(gravity, 10) // 10 iterations
|
||||
}
|
||||
|
||||
// Update - Update game
|
||||
func (g *Game) Update() {
|
||||
// Keys 1-9 switch demos
|
||||
switch rl.GetKeyPressed() {
|
||||
case rl.KeyOne:
|
||||
g.Demo1()
|
||||
case rl.KeyTwo:
|
||||
g.Demo2()
|
||||
case rl.KeyThree:
|
||||
g.Demo3()
|
||||
case rl.KeyFour:
|
||||
g.Demo4()
|
||||
case rl.KeyFive:
|
||||
g.Demo5()
|
||||
case rl.KeySix:
|
||||
g.Demo6()
|
||||
case rl.KeySeven:
|
||||
g.Demo7()
|
||||
case rl.KeyEight:
|
||||
g.Demo8()
|
||||
case rl.KeyNine:
|
||||
g.Demo9()
|
||||
}
|
||||
|
||||
g.TimeStep = float64(rl.GetFrameTime())
|
||||
|
||||
// Physics steps calculations
|
||||
g.World.Step(g.TimeStep)
|
||||
}
|
||||
|
||||
// Draw - Draw game
|
||||
func (g *Game) Draw() {
|
||||
for _, b := range g.World.Bodies {
|
||||
g.DrawBody(b)
|
||||
}
|
||||
for _, j := range g.World.Joints {
|
||||
g.DrawJoint(j)
|
||||
}
|
||||
|
||||
rl.DrawText("Use keys 1-9 to switch current demo", 20, 20, 10, rl.RayWhite)
|
||||
}
|
||||
|
||||
// DrawBody - Draw body
|
||||
func (g *Game) DrawBody(b *box2d.Body) {
|
||||
R := box2d.Mat22ByAngle(b.Rotation)
|
||||
x := b.Position
|
||||
h := box2d.MulSV(0.5, b.Width)
|
||||
|
||||
o := box2d.Vec2{400, 400}
|
||||
S := box2d.Mat22{box2d.Vec2{20.0, 0.0}, box2d.Vec2{0.0, -20.0}}
|
||||
|
||||
v1 := o.Add(S.MulV(x.Add(R.MulV(box2d.Vec2{-h.X, -h.Y}))))
|
||||
v2 := o.Add(S.MulV(x.Add(R.MulV(box2d.Vec2{h.X, -h.Y}))))
|
||||
v3 := o.Add(S.MulV(x.Add(R.MulV(box2d.Vec2{h.X, h.Y}))))
|
||||
v4 := o.Add(S.MulV(x.Add(R.MulV(box2d.Vec2{-h.X, h.Y}))))
|
||||
|
||||
rl.DrawLine(int32(v1.X), int32(v1.Y), int32(v2.X), int32(v2.Y), rl.RayWhite)
|
||||
rl.DrawLine(int32(v2.X), int32(v2.Y), int32(v3.X), int32(v3.Y), rl.RayWhite)
|
||||
rl.DrawLine(int32(v3.X), int32(v3.Y), int32(v4.X), int32(v4.Y), rl.RayWhite)
|
||||
rl.DrawLine(int32(v4.X), int32(v4.Y), int32(v1.X), int32(v1.Y), rl.RayWhite)
|
||||
}
|
||||
|
||||
// DrawJoint - Draw joint
|
||||
func (g *Game) DrawJoint(j *box2d.Joint) {
|
||||
b1 := j.Body1
|
||||
b2 := j.Body2
|
||||
|
||||
R1 := box2d.Mat22ByAngle(b1.Rotation)
|
||||
R2 := box2d.Mat22ByAngle(b2.Rotation)
|
||||
|
||||
x1 := b1.Position
|
||||
p1 := x1.Add(R1.MulV(j.LocalAnchor1))
|
||||
|
||||
x2 := b2.Position
|
||||
p2 := x2.Add(R2.MulV(j.LocalAnchor2))
|
||||
|
||||
o := box2d.Vec2{400, 400}
|
||||
S := box2d.Mat22{box2d.Vec2{20.0, 0.0}, box2d.Vec2{0.0, -20.0}}
|
||||
|
||||
x1 = o.Add(S.MulV(x1))
|
||||
p1 = o.Add(S.MulV(p1))
|
||||
x2 = o.Add(S.MulV(x2))
|
||||
p2 = o.Add(S.MulV(p2))
|
||||
|
||||
rl.DrawLine(int32(x1.X), int32(x1.Y), int32(p1.X), int32(p1.Y), rl.RayWhite)
|
||||
rl.DrawLine(int32(x2.X), int32(x2.Y), int32(p2.X), int32(p2.Y), rl.RayWhite)
|
||||
}
|
||||
|
||||
// Demo1 - Single box
|
||||
func (g *Game) Demo1() {
|
||||
g.World.Clear()
|
||||
|
||||
var b1, b2 box2d.Body
|
||||
|
||||
b1.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b1.Position = box2d.Vec2{0.0, -0.5 * b1.Width.Y}
|
||||
g.World.AddBody(&b1)
|
||||
|
||||
b2.Set(&box2d.Vec2{1.0, 1.0}, 200.0)
|
||||
b2.Position = box2d.Vec2{0.0, 4.0}
|
||||
g.World.AddBody(&b2)
|
||||
}
|
||||
|
||||
// Demo2 - A simple pendulum
|
||||
func (g *Game) Demo2() {
|
||||
g.World.Clear()
|
||||
|
||||
var b2, b1 box2d.Body
|
||||
var j box2d.Joint
|
||||
|
||||
b1.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b1.Friction = 0.2
|
||||
b1.Position = box2d.Vec2{0.0, -0.5 * b1.Width.Y}
|
||||
b1.Rotation = 0.0
|
||||
g.World.AddBody(&b1)
|
||||
|
||||
b2.Set(&box2d.Vec2{1.0, 1.0}, 100.0)
|
||||
b2.Friction = 0.2
|
||||
b2.Position = box2d.Vec2{9.0, 11.0}
|
||||
b2.Rotation = 0.0
|
||||
g.World.AddBody(&b2)
|
||||
|
||||
j.Set(&b1, &b2, &box2d.Vec2{0.0, 11.0})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
// Demo3 - Varying friction coefficients
|
||||
func (g *Game) Demo3() {
|
||||
g.World.Clear()
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{0.0, -0.5 * b.Width.Y}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{13.0, 0.25}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{-2.0, 11.0}
|
||||
b.Rotation = -0.25
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{0.25, 1.0}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{5.25, 9.5}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{13.0, 0.25}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{2.0, 7.0}
|
||||
b.Rotation = 0.25
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{0.25, 1.0}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{-5.25, 5.5}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
frictions := []float64{0.75, 0.5, 0.35, 0.1, 0.0}
|
||||
for i := 0; i < 5; i++ {
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{0.5, 0.5}, 25.0)
|
||||
b.Friction = frictions[i]
|
||||
b.Position = box2d.Vec2{-7.5 + 2.0*float64(i), 14.0}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Demo4 - A vertical stack
|
||||
func (g *Game) Demo4() {
|
||||
g.World.Clear()
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b.Friction = 0.2
|
||||
b.Position = box2d.Vec2{0.0, -0.5 * b.Width.Y}
|
||||
b.Rotation = 0.0
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{1.0, 1.0}, 1.0)
|
||||
b.Friction = 0.2
|
||||
x := rand.Float64()*0.2 - 0.1
|
||||
b.Position = box2d.Vec2{x, 0.51 + 1.05*float64(i)}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Demo5 - A pyramid
|
||||
func (g *Game) Demo5() {
|
||||
g.World.Clear()
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b.Friction = 0.2
|
||||
b.Position = box2d.Vec2{0.0, -0.5 * b.Width.Y}
|
||||
b.Rotation = 0.0
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
x := box2d.Vec2{-6.0, 0.75}
|
||||
|
||||
for i := 0; i < 12; i++ {
|
||||
y := x
|
||||
for j := i; j < 12; j++ {
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{1.0, 1.0}, 10.0)
|
||||
b.Friction = 0.2
|
||||
b.Position = y
|
||||
g.World.AddBody(&b)
|
||||
|
||||
y = y.Add(box2d.Vec2{1.125, 0.0})
|
||||
}
|
||||
|
||||
x = x.Add(box2d.Vec2{0.5625, 2.0})
|
||||
}
|
||||
}
|
||||
|
||||
// Demo6 - A teeter
|
||||
func (g *Game) Demo6() {
|
||||
g.World.Clear()
|
||||
|
||||
var b1, b2, b3, b4, b5 box2d.Body
|
||||
b1.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b1.Position = box2d.Vec2{0.0, -0.5 * b1.Width.Y}
|
||||
g.World.AddBody(&b1)
|
||||
|
||||
b2.Set(&box2d.Vec2{12.0, 0.25}, 100)
|
||||
b2.Position = box2d.Vec2{0.0, 1.0}
|
||||
g.World.AddBody(&b2)
|
||||
|
||||
b3.Set(&box2d.Vec2{0.5, 0.5}, 25.0)
|
||||
b3.Position = box2d.Vec2{-5.0, 2.0}
|
||||
g.World.AddBody(&b3)
|
||||
|
||||
b4.Set(&box2d.Vec2{0.5, 0.5}, 25.0)
|
||||
b4.Position = box2d.Vec2{-5.5, 2.0}
|
||||
g.World.AddBody(&b4)
|
||||
|
||||
b5.Set(&box2d.Vec2{1.0, 1.0}, 100)
|
||||
b5.Position = box2d.Vec2{5.5, 15.0}
|
||||
g.World.AddBody(&b5)
|
||||
|
||||
{
|
||||
var j box2d.Joint
|
||||
j.Set(&b1, &b2, &box2d.Vec2{0.0, 1.0})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Demo7 - A suspension bridge
|
||||
func (g *Game) Demo7() {
|
||||
g.World.Clear()
|
||||
|
||||
var ba []*box2d.Body
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b.Friction = 0.2
|
||||
b.Position = box2d.Vec2{0.0, -0.5 * b.Width.Y}
|
||||
b.Rotation = 0.0
|
||||
g.World.AddBody(&b)
|
||||
ba = append(ba, &b)
|
||||
}
|
||||
|
||||
const numPlunks = 15
|
||||
const mass = 50.0
|
||||
|
||||
for i := 0; i < numPlunks; i++ {
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{1.0, 0.25}, mass)
|
||||
b.Friction = 0.2
|
||||
b.Position = box2d.Vec2{-8.5 + 1.25*float64(i), 5.0}
|
||||
g.World.AddBody(&b)
|
||||
ba = append(ba, &b)
|
||||
}
|
||||
|
||||
// Tuning
|
||||
const frequencyHz = 2.0
|
||||
const dampingRatio = 0.7
|
||||
|
||||
// Frequency in radians
|
||||
const omega = 2.0 * math.Pi * frequencyHz
|
||||
|
||||
// Damping coefficient
|
||||
const d = 2.0 * mass * dampingRatio * omega
|
||||
|
||||
// Spring stifness
|
||||
const k = mass * omega * omega
|
||||
|
||||
// Magic formulas
|
||||
softness := 1.0 / (d + g.TimeStep*k)
|
||||
biasFactor := g.TimeStep * k / (d + g.TimeStep*k)
|
||||
|
||||
for i := 0; i <= numPlunks; i++ {
|
||||
var j box2d.Joint
|
||||
j.Set(ba[i], ba[(i+1)%(numPlunks+1)], &box2d.Vec2{-9.125 + 1.25*float64(i), 5.0})
|
||||
j.Softness = softness
|
||||
j.BiasFactor = biasFactor
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Demo8 - Dominos
|
||||
func (g *Game) Demo8() {
|
||||
g.World.Clear()
|
||||
|
||||
var b1 box2d.Body
|
||||
b1.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b1.Position = box2d.Vec2{0.0, -0.5 * b1.Width.Y}
|
||||
g.World.AddBody(&b1)
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{12.0, 0.5}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{-1.5, 10.0}
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{0.2, 2.0}, 10.0)
|
||||
b.Position = box2d.Vec2{-6.0 + 1.0*float64(i), 11.125}
|
||||
b.Friction = 0.1
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{14.0, 0.5}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{1.0, 6.0}
|
||||
b.Rotation = 0.3
|
||||
g.World.AddBody(&b)
|
||||
}
|
||||
|
||||
var b2 box2d.Body
|
||||
b2.Set(&box2d.Vec2{0.5, 3.0}, math.MaxFloat64)
|
||||
b2.Position = box2d.Vec2{-7.0, 4.0}
|
||||
g.World.AddBody(&b2)
|
||||
|
||||
var b3 box2d.Body
|
||||
b3.Set(&box2d.Vec2{12.0, 0.25}, 20.0)
|
||||
b3.Position = box2d.Vec2{-0.9, 1.0}
|
||||
g.World.AddBody(&b3)
|
||||
|
||||
{
|
||||
var j box2d.Joint
|
||||
j.Set(&b1, &b3, &box2d.Vec2{-2.0, 1.0})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
var b4 box2d.Body
|
||||
b4.Set(&box2d.Vec2{0.5, 0.5}, 10.0)
|
||||
b4.Position = box2d.Vec2{-10.0, 15.0}
|
||||
g.World.AddBody(&b4)
|
||||
|
||||
{
|
||||
var j box2d.Joint
|
||||
j.Set(&b2, &b4, &box2d.Vec2{-7.0, 15.0})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
var b5 box2d.Body
|
||||
b5.Set(&box2d.Vec2{2.0, 2.0}, 20.0)
|
||||
b5.Position = box2d.Vec2{6.0, 2.5}
|
||||
b5.Friction = 0.1
|
||||
g.World.AddBody(&b5)
|
||||
|
||||
{
|
||||
var j box2d.Joint
|
||||
j.Set(&b1, &b5, &box2d.Vec2{6.0, 2.6})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
var b6 box2d.Body
|
||||
b6.Set(&box2d.Vec2{2.0, 0.2}, 10.0)
|
||||
b6.Position = box2d.Vec2{6.0, 3.6}
|
||||
g.World.AddBody(&b6)
|
||||
|
||||
{
|
||||
var j box2d.Joint
|
||||
j.Set(&b5, &b6, &box2d.Vec2{7.0, 3.5})
|
||||
g.World.AddJoint(&j)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Demo9 - A multi-pendulum
|
||||
func (g *Game) Demo9() {
|
||||
g.World.Clear()
|
||||
|
||||
var b1 *box2d.Body
|
||||
|
||||
{
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{100.0, 20.0}, math.MaxFloat64)
|
||||
b.Position = box2d.Vec2{0.0, -0.5 * b.Width.Y}
|
||||
g.World.AddBody(&b)
|
||||
b1 = &b
|
||||
}
|
||||
|
||||
const mass = 10.0
|
||||
|
||||
// Tuning
|
||||
const frequencyHz = 4.0
|
||||
const dampingRatio = 0.7
|
||||
|
||||
// Frequency in radians
|
||||
const omega = 2.0 * math.Pi * frequencyHz
|
||||
|
||||
// Damping coefficient
|
||||
const d = 2.0 * mass * dampingRatio * omega
|
||||
|
||||
// Spring stiffness
|
||||
const k = mass * omega * omega
|
||||
|
||||
// Magic formulas
|
||||
softness := 1.0 / (d + g.TimeStep*k)
|
||||
biasFactor := g.TimeStep * k / (d + g.TimeStep*k)
|
||||
|
||||
const y = 12.0
|
||||
|
||||
for i := 0; i < 15; i++ {
|
||||
x := box2d.Vec2{0.5 + float64(i), y}
|
||||
|
||||
var b box2d.Body
|
||||
b.Set(&box2d.Vec2{0.75, 0.25}, mass)
|
||||
b.Friction = 0.2
|
||||
b.Position = x
|
||||
b.Rotation = 0.0
|
||||
g.World.AddBody(&b)
|
||||
|
||||
var j box2d.Joint
|
||||
j.Set(b1, &b, &box2d.Vec2{float64(i), y})
|
||||
j.Softness = softness
|
||||
j.BiasFactor = biasFactor
|
||||
g.World.AddJoint(&j)
|
||||
|
||||
b1 = &b
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [physics] example - box2d")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
game := NewGame()
|
||||
|
||||
game.Demo1()
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Black)
|
||||
|
||||
game.Update()
|
||||
|
||||
game.Draw()
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
"github.com/jakecoffman/cp"
|
||||
)
|
||||
|
||||
var grabbableMaskBit uint = 1 << 31
|
||||
var grabFilter = cp.ShapeFilter{
|
||||
cp.NO_GROUP, grabbableMaskBit, grabbableMaskBit,
|
||||
}
|
||||
|
||||
func randUnitCircle() cp.Vector {
|
||||
v := cp.Vector{X: rand.Float64()*2.0 - 1.0, Y: rand.Float64()*2.0 - 1.0}
|
||||
if v.LengthSq() < 1.0 {
|
||||
return v
|
||||
}
|
||||
return randUnitCircle()
|
||||
}
|
||||
|
||||
var simpleTerrainVerts = []cp.Vector{
|
||||
{350.00, 425.07}, {336.00, 436.55}, {272.00, 435.39}, {258.00, 427.63}, {225.28, 420.00}, {202.82, 396.00},
|
||||
{191.81, 388.00}, {189.00, 381.89}, {173.00, 380.39}, {162.59, 368.00}, {150.47, 319.00}, {128.00, 311.55},
|
||||
{119.14, 286.00}, {126.84, 263.00}, {120.56, 227.00}, {141.14, 178.00}, {137.52, 162.00}, {146.51, 142.00},
|
||||
{156.23, 136.00}, {158.00, 118.27}, {170.00, 100.77}, {208.43, 84.00}, {224.00, 69.65}, {249.30, 68.00},
|
||||
{257.00, 54.77}, {363.00, 45.94}, {374.15, 54.00}, {386.00, 69.60}, {413.00, 70.73}, {456.00, 84.89},
|
||||
{468.09, 99.00}, {467.09, 123.00}, {464.92, 135.00}, {469.00, 141.03}, {497.00, 148.67}, {513.85, 180.00},
|
||||
{509.56, 223.00}, {523.51, 247.00}, {523.00, 277.00}, {497.79, 311.00}, {478.67, 348.00}, {467.90, 360.00},
|
||||
{456.76, 382.00}, {432.95, 389.00}, {417.00, 411.32}, {373.00, 433.19}, {361.00, 430.02}, {350.00, 425.07},
|
||||
}
|
||||
|
||||
// creates a circle with random placement
|
||||
func addCircle(space *cp.Space, radius float64) {
|
||||
mass := radius * radius / 25.0
|
||||
body := space.AddBody(cp.NewBody(mass, cp.MomentForCircle(mass, 0, radius, cp.Vector{})))
|
||||
body.SetPosition(randUnitCircle().Mult(180))
|
||||
|
||||
shape := space.AddShape(cp.NewCircle(body, radius, cp.Vector{}))
|
||||
shape.SetElasticity(0)
|
||||
shape.SetFriction(0.9)
|
||||
}
|
||||
|
||||
// creates a simple terrain to contain bodies
|
||||
func simpleTerrain() *cp.Space {
|
||||
space := cp.NewSpace()
|
||||
space.Iterations = 10
|
||||
space.SetGravity(cp.Vector{0, -100})
|
||||
space.SetCollisionSlop(0.5)
|
||||
|
||||
offset := cp.Vector{X: -320, Y: -240}
|
||||
for i := 0; i < len(simpleTerrainVerts)-1; i++ {
|
||||
a := simpleTerrainVerts[i]
|
||||
b := simpleTerrainVerts[i+1]
|
||||
space.AddShape(cp.NewSegment(space.StaticBody, a.Add(offset), b.Add(offset), 0))
|
||||
}
|
||||
|
||||
return space
|
||||
}
|
||||
|
||||
func main() {
|
||||
const width, height = 800, 450
|
||||
const physicsTickrate = 1.0 / 60.0
|
||||
|
||||
rl.SetConfigFlags(rl.FlagVsyncHint)
|
||||
rl.InitWindow(width, height, "raylib [physics] example - chipmunk")
|
||||
|
||||
offset := rl.Vector2{X: width / 2, Y: height / 2}
|
||||
// since the example ported from elsewhere, flip the camera 180 and offset to center it
|
||||
camera := rl.NewCamera2D(offset, rl.Vector2{}, 180, 1)
|
||||
|
||||
space := simpleTerrain()
|
||||
for i := 0; i < 1000; i++ {
|
||||
addCircle(space, 5)
|
||||
}
|
||||
mouseBody := cp.NewKinematicBody()
|
||||
var mouse cp.Vector
|
||||
var mouseJoint *cp.Constraint
|
||||
|
||||
var accumulator, dt float32
|
||||
lastTime := rl.GetTime()
|
||||
for !rl.WindowShouldClose() {
|
||||
// calculate dt
|
||||
now := rl.GetTime()
|
||||
dt = float32(now - lastTime)
|
||||
lastTime = now
|
||||
|
||||
// update the mouse position
|
||||
mousePos := rl.GetMousePosition()
|
||||
// alter the mouse coordinates based on the camera position, rotation
|
||||
mouse.X = float64(mousePos.X-camera.Offset.X) * -1
|
||||
mouse.Y = float64(mousePos.Y-camera.Offset.Y) * -1
|
||||
// smooth mouse movements to new position
|
||||
newPoint := mouseBody.Position().Lerp(mouse, 0.25)
|
||||
mouseBody.SetVelocityVector(newPoint.Sub(mouseBody.Position()).Mult(60.0))
|
||||
mouseBody.SetPosition(newPoint)
|
||||
|
||||
// handle grabbing
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
result := space.PointQueryNearest(mouse, 5, grabFilter)
|
||||
if result.Shape != nil && result.Shape.Body().Mass() < cp.INFINITY {
|
||||
var nearest cp.Vector
|
||||
if result.Distance > 0 {
|
||||
nearest = result.Point
|
||||
} else {
|
||||
nearest = mouse
|
||||
}
|
||||
|
||||
// create a new constraint where the mouse is to draw the body towards the mouse
|
||||
body := result.Shape.Body()
|
||||
mouseJoint = cp.NewPivotJoint2(mouseBody, body, cp.Vector{}, body.WorldToLocal(nearest))
|
||||
mouseJoint.SetMaxForce(50000)
|
||||
mouseJoint.SetErrorBias(math.Pow(1.0-0.15, 60.0))
|
||||
space.AddConstraint(mouseJoint)
|
||||
}
|
||||
} else if rl.IsMouseButtonReleased(rl.MouseLeftButton) && mouseJoint != nil {
|
||||
space.RemoveConstraint(mouseJoint)
|
||||
mouseJoint = nil
|
||||
}
|
||||
|
||||
// perform a fixed rate physics tick
|
||||
accumulator += dt
|
||||
for accumulator >= physicsTickrate {
|
||||
space.Step(physicsTickrate)
|
||||
accumulator -= physicsTickrate
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.BeginMode2D(camera)
|
||||
|
||||
// this is a generic way to iterate over the shapes in a space,
|
||||
// to avoid the type switch just keep a pointer to the shapes when they've been created
|
||||
space.EachShape(func(s *cp.Shape) {
|
||||
switch s.Class.(type) {
|
||||
case *cp.Segment:
|
||||
segment := s.Class.(*cp.Segment)
|
||||
a := segment.A()
|
||||
b := segment.B()
|
||||
rl.DrawLineV(v(a), v(b), rl.Black)
|
||||
case *cp.Circle:
|
||||
circle := s.Class.(*cp.Circle)
|
||||
pos := circle.Body().Position()
|
||||
rl.DrawCircleV(v(pos), float32(circle.Radius()), rl.Red)
|
||||
default:
|
||||
fmt.Println("unexpected shape", s.Class)
|
||||
}
|
||||
})
|
||||
|
||||
rl.EndMode2D()
|
||||
rl.DrawFPS(0, 0)
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
func v(v cp.Vector) rl.Vector2 {
|
||||
return rl.Vector2{X: float32(v.X), Y: float32(v.Y)}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/physics"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(screenWidth, screenHeight, "Physac [raylib] - physics demo")
|
||||
|
||||
// Physac logo drawing position
|
||||
logoX := screenWidth - rl.MeasureText("Physac", 30) - 10
|
||||
logoY := int32(15)
|
||||
|
||||
// Initialize physics and default physics bodies
|
||||
physics.Init()
|
||||
|
||||
// Create floor rectangle physics body
|
||||
floor := physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)), 500, 100, 10)
|
||||
floor.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
|
||||
// Create obstacle circle physics body
|
||||
circle := physics.NewBodyCircle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)/2), 45, 10)
|
||||
circle.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
||||
// Update created physics objects
|
||||
physics.Update()
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyR) { // Reset physics input
|
||||
physics.Reset()
|
||||
|
||||
floor = physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)), 500, 100, 10)
|
||||
floor.Enabled = false
|
||||
|
||||
circle = physics.NewBodyCircle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)/2), 45, 10)
|
||||
circle.Enabled = false
|
||||
}
|
||||
|
||||
// Physics body creation inputs
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
physics.NewBodyPolygon(rl.GetMousePosition(), float32(rl.GetRandomValue(20, 80)), int(rl.GetRandomValue(3, 8)), 10)
|
||||
} else if rl.IsMouseButtonPressed(rl.MouseRightButton) {
|
||||
physics.NewBodyCircle(rl.GetMousePosition(), float32(rl.GetRandomValue(10, 45)), 10)
|
||||
}
|
||||
|
||||
// Destroy falling physics bodies
|
||||
for i := 0; i < physics.GetBodiesCount(); i++ {
|
||||
body := physics.GetBody(i)
|
||||
if body.Position.Y > float32(screenHeight)*2 {
|
||||
body.Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Black)
|
||||
|
||||
rl.DrawFPS(screenWidth-90, screenHeight-30)
|
||||
|
||||
// Draw created physics bodies
|
||||
for i := 0; i < physics.GetBodiesCount(); i++ {
|
||||
body := physics.GetBody(i)
|
||||
|
||||
vertexCount := physics.GetShapeVerticesCount(i)
|
||||
for j := 0; j < vertexCount; j++ {
|
||||
// Get physics bodies shape vertices to draw lines
|
||||
// NOTE: GetShapeVertex() already calculates rotation transformations
|
||||
vertexA := body.GetShapeVertex(j)
|
||||
|
||||
jj := 0
|
||||
if j+1 < vertexCount { // Get next vertex or first to close the shape
|
||||
jj = j + 1
|
||||
}
|
||||
|
||||
vertexB := body.GetShapeVertex(jj)
|
||||
|
||||
rl.DrawLineV(vertexA, vertexB, rl.Green) // Draw a line between two vertex positions
|
||||
}
|
||||
}
|
||||
|
||||
rl.DrawText("Left mouse button to create a polygon", 10, 10, 10, rl.White)
|
||||
rl.DrawText("Right mouse button to create a circle", 10, 25, 10, rl.White)
|
||||
rl.DrawText("Press 'R' to reset example", 10, 40, 10, rl.White)
|
||||
|
||||
rl.DrawText("Physac", logoX, logoY, 30, rl.White)
|
||||
rl.DrawText("Powered by", logoX+50, logoY-7, 10, rl.White)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
physics.Close() // Unitialize physics
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/physics"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(screenWidth, screenHeight, "Physac [raylib] - physics friction")
|
||||
|
||||
// Physac logo drawing position
|
||||
logoX := screenWidth - rl.MeasureText("Physac", 30) - 10
|
||||
logoY := int32(15)
|
||||
|
||||
// Initialize physics and default physics bodies
|
||||
physics.Init()
|
||||
|
||||
// Create floor rectangle physics body
|
||||
floor := physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)), float32(screenHeight), 100, 10)
|
||||
floor.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
wall := physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)*0.8), 10, 80, 10)
|
||||
wall.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
|
||||
// Create left ramp physics body
|
||||
rectLeft := physics.NewBodyRectangle(rl.NewVector2(25, float32(screenHeight)-5), 250, 250, 10)
|
||||
rectLeft.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
rectLeft.SetRotation(30 * rl.Deg2rad)
|
||||
|
||||
// Create right ramp physics body
|
||||
rectRight := physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)-25, float32(screenHeight)-5), 250, 250, 10)
|
||||
rectRight.Enabled = false // Disable body state to convert it to static (no dynamics, but collisions)
|
||||
rectRight.SetRotation(330 * rl.Deg2rad)
|
||||
|
||||
// Create dynamic physics bodies
|
||||
bodyA := physics.NewBodyRectangle(rl.NewVector2(35, float32(screenHeight)*0.6), 40, 40, 10)
|
||||
bodyA.StaticFriction = 0.1
|
||||
bodyA.DynamicFriction = 0.1
|
||||
bodyA.SetRotation(30 * rl.Deg2rad)
|
||||
|
||||
bodyB := physics.NewBodyRectangle(rl.NewVector2(float32(screenWidth)-35, float32(screenHeight)*0.6), 40, 40, 10)
|
||||
bodyB.StaticFriction = 1
|
||||
bodyB.DynamicFriction = 1
|
||||
bodyB.SetRotation(330 * rl.Deg2rad)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Physics steps calculations
|
||||
physics.Update()
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyR) { // Reset physics input
|
||||
// Reset dynamic physics bodies position, velocity and rotation
|
||||
bodyA.Position = rl.NewVector2(35, float32(screenHeight)*0.6)
|
||||
bodyA.Velocity = rl.NewVector2(0, 0)
|
||||
bodyA.AngularVelocity = 0
|
||||
bodyA.SetRotation(30 * rl.Deg2rad)
|
||||
|
||||
bodyB.Position = rl.NewVector2(float32(screenWidth)-35, float32(screenHeight)*0.6)
|
||||
bodyB.Velocity = rl.NewVector2(0, 0)
|
||||
bodyB.AngularVelocity = 0
|
||||
bodyB.SetRotation(330 * rl.Deg2rad)
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Black)
|
||||
|
||||
rl.DrawFPS(screenWidth-90, screenHeight-30)
|
||||
|
||||
// Draw created physics bodies
|
||||
bodiesCount := physics.GetBodiesCount()
|
||||
for i := 0; i < bodiesCount; i++ {
|
||||
body := physics.GetBody(i)
|
||||
|
||||
vertexCount := physics.GetShapeVerticesCount(i)
|
||||
for j := 0; j < vertexCount; j++ {
|
||||
// Get physics bodies shape vertices to draw lines
|
||||
// NOTE: GetShapeVertex() already calculates rotation transformations
|
||||
vertexA := body.GetShapeVertex(j)
|
||||
|
||||
jj := 0
|
||||
if j+1 < vertexCount { // Get next vertex or first to close the shape
|
||||
jj = j + 1
|
||||
}
|
||||
|
||||
vertexB := body.GetShapeVertex(jj)
|
||||
|
||||
rl.DrawLineV(vertexA, vertexB, rl.Green) // Draw a line between two vertex positions
|
||||
}
|
||||
}
|
||||
|
||||
rl.DrawRectangle(0, screenHeight-49, screenWidth, 49, rl.Black)
|
||||
|
||||
rl.DrawText("Friction amount", (screenWidth-rl.MeasureText("Friction amount", 30))/2, 75, 30, rl.White)
|
||||
rl.DrawText("0.1", int32(bodyA.Position.X)-rl.MeasureText("0.1", 20)/2, int32(bodyA.Position.Y)-7, 20, rl.White)
|
||||
rl.DrawText("1", int32(bodyB.Position.X)-rl.MeasureText("1", 20)/2, int32(bodyB.Position.Y)-7, 20, rl.White)
|
||||
|
||||
rl.DrawText("Press 'R' to reset example", 10, 10, 10, rl.White)
|
||||
|
||||
rl.DrawText("Physac", logoX, logoY, 30, rl.White)
|
||||
rl.DrawText("Powered by", logoX+50, logoY-7, 10, rl.White)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
physics.Close() // Unitialize physics
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|