Update examples
This commit is contained in:
parent
a62b332ffc
commit
363905fef0
17 changed files with 27 additions and 114 deletions
|
@ -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
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -29,12 +29,10 @@ func main() {
|
|||
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.UpdateCamera(&camera, rl.CameraFirstPerson) // Update camera with first person mode
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -16,12 +16,10 @@ func main() {
|
|||
|
||||
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
|
||||
rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
|
||||
|
||||
if rl.IsKeyDown(rl.KeyZ) {
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
|
|
|
@ -23,12 +23,10 @@ func main() {
|
|||
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
|
||||
rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
|
||||
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
if !collision.Hit {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -19,12 +19,10 @@ func main() {
|
|||
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
|
||||
rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
|
||||
|
||||
// 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)
|
||||
|
|
|
@ -3,8 +3,8 @@ module examples
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20230307111832-5dcd22c1f844
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230307112435-42e75c98a85b
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20230413172235-a62b332ffc4a
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230413172235-a62b332ffc4a
|
||||
github.com/jakecoffman/cp v1.2.1
|
||||
github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b
|
||||
)
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
github.com/gen2brain/raylib-go/physics v0.0.0-20230307111832-5dcd22c1f844 h1:Ujsq26uwt3Ee1Liif/A+61hUPEOeeRc24zZORP52Fko=
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20230307111832-5dcd22c1f844/go.mod h1:Vf/TIMnolPj/pEnPQObb/cL481gg/La8CgwibfA9gx4=
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20230413172235-a62b332ffc4a h1:YiVRz76RzAgEl4UDxXK51PZp4a46ocSF3MN5RPDiKs8=
|
||||
github.com/gen2brain/raylib-go/physics v0.0.0-20230413172235-a62b332ffc4a/go.mod h1:Vf/TIMnolPj/pEnPQObb/cL481gg/La8CgwibfA9gx4=
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230307112435-42e75c98a85b h1:YK1HMLMb37bDpjetVdsQYJ+J+40gavgbt+XP5FK3MKw=
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230307112435-42e75c98a85b/go.mod h1:+NbsqGlEQqGqrsgJFF5Yj2dkvn0ML2SQb8RqM2hJsPU=
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230413172235-a62b332ffc4a h1:Ia3FYwv7nxvb55YZCKfiXfgLwrrQv3fbjvnSwnOAl14=
|
||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20230413172235-a62b332ffc4a/go.mod h1:AwtGA3aTtYdezNxEVbfchaLw/z+CuRDh2Mlxy0FbBro=
|
||||
github.com/jakecoffman/cp v1.2.1 h1:zkhc2Gpo9l4NLUZfeG3j33+3bQD7MkqPa+n5PdX+5mI=
|
||||
github.com/jakecoffman/cp v1.2.1/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
|
||||
github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b h1:+67TGbwfgeB5o03Rx+ZBW44zAQ+wUujcwdRA0p9CbJI=
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -20,12 +20,10 @@ func main() {
|
|||
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.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -30,14 +30,12 @@ func main() {
|
|||
|
||||
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
|
||||
rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
|
||||
// Draw
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ func main() {
|
|||
|
||||
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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -57,7 +55,7 @@ func main() {
|
|||
//----------------------------------------------------------------------------------
|
||||
oldCamPos := camera.Position // Store old camera position
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera, rl.CameraFirstPerson) // Update camera with first person mode
|
||||
|
||||
// Check player collision (we simplify to 2D collision detection)
|
||||
playerPos := rl.NewVector2(camera.Position.X, camera.Position.Z)
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
//"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -30,14 +30,12 @@ func main() {
|
|||
|
||||
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
|
||||
rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
|
||||
// Draw
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -39,9 +39,6 @@ func main() {
|
|||
// Create a RenderTexture2D to be used for render to texture
|
||||
target := rl.LoadRenderTexture(screenWidth, screenHeight)
|
||||
|
||||
// Setup orbital camera
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
@ -55,7 +52,7 @@ func main() {
|
|||
// Send new value to the shader to be used on drawing
|
||||
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, rl.ShaderUniformVec2)
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
|
|
|
@ -75,8 +75,6 @@ func main() {
|
|||
mmap := material.GetMap(rl.MapDiffuse)
|
||||
mmap.Color = rl.Red
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital)
|
||||
|
||||
rl.SetTargetFPS(int32(fps))
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
|
@ -187,7 +185,7 @@ func main() {
|
|||
transforms[i] = rl.MatrixMultiply(transforms[i], rl.MatrixTranslate(0.0, y, 0.0))
|
||||
}
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -29,12 +29,10 @@ func main() {
|
|||
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraFree) // Set free camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const MaxPostproShaders = 12
|
||||
|
@ -77,12 +77,10 @@ func main() {
|
|||
// Create a RenderTexture2D to be used for render to texture
|
||||
target := rl.LoadRenderTexture(screenWidth, screenHeight)
|
||||
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set free camera mode
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyRight) {
|
||||
currentShader++
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue