mirror of
https://github.com/Fluffy-Bean/ColouringApp.git
synced 2025-02-17 23:50:05 +00:00
Init
This commit is contained in:
parent
09446517cf
commit
1b05e0364b
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Remove Editor Files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# Remove Enviroment Variables
|
||||||
|
.env
|
18
application/globalVars.go
Normal file
18
application/globalVars.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package application
|
||||||
|
|
||||||
|
const (
|
||||||
|
WindowTitle = "Colouring App"
|
||||||
|
WindowWidth = 800
|
||||||
|
WindowHeight = 600
|
||||||
|
WindowFPS = 60
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SceneTitle = iota
|
||||||
|
SceneOptions
|
||||||
|
SceneGame
|
||||||
|
)
|
||||||
|
|
||||||
|
var CurrentScene = SceneTitle
|
||||||
|
|
||||||
|
var ShouldQuit = false
|
13
go.mod
Normal file
13
go.mod
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module ColouringApp
|
||||||
|
|
||||||
|
go 1.21.5
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20231230150416-17ce08145200
|
||||||
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20231230150416-17ce08145200
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa // indirect
|
||||||
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
|
)
|
8
go.sum
Normal file
8
go.sum
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk=
|
||||||
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
||||||
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20231230150416-17ce08145200 h1:8UJDYu3Ws+VRrPnhESvjtityUEotaFM2uEPbT+3rR8Q=
|
||||||
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20231230150416-17ce08145200/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM=
|
||||||
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20231230150416-17ce08145200 h1:cff+9Xad/S2SfPhUieMoyDlvJFnsxvwd6aWFfhbeOe4=
|
||||||
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20231230150416-17ce08145200/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE=
|
||||||
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
35
main.go
Normal file
35
main.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ColouringApp/application"
|
||||||
|
"ColouringApp/scenes"
|
||||||
|
raylib "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
raylib.InitWindow(application.WindowWidth, application.WindowHeight, application.WindowTitle)
|
||||||
|
raylib.InitAudioDevice()
|
||||||
|
|
||||||
|
raylib.SetTargetFPS(application.WindowFPS)
|
||||||
|
raylib.SetExitKey(0) // disable exit key
|
||||||
|
|
||||||
|
// MAIN LOOP
|
||||||
|
for !application.ShouldQuit {
|
||||||
|
switch application.CurrentScene {
|
||||||
|
case application.SceneTitle:
|
||||||
|
scenes.Title()
|
||||||
|
case application.SceneOptions:
|
||||||
|
scenes.Options()
|
||||||
|
case application.SceneGame:
|
||||||
|
scenes.Game()
|
||||||
|
default:
|
||||||
|
panic("Unknown scene")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// QUIT
|
||||||
|
raylib.CloseAudioDevice()
|
||||||
|
raylib.CloseWindow()
|
||||||
|
|
||||||
|
// GOODBYE
|
||||||
|
}
|
49
scenes/game.go
Normal file
49
scenes/game.go
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package scenes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ColouringApp/application"
|
||||||
|
|
||||||
|
gui "github.com/gen2brain/raylib-go/raygui"
|
||||||
|
raylib "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Game() {
|
||||||
|
var (
|
||||||
|
scenePaused = false
|
||||||
|
)
|
||||||
|
|
||||||
|
// load resources here
|
||||||
|
|
||||||
|
for !application.ShouldQuit {
|
||||||
|
application.ShouldQuit = raylib.WindowShouldClose()
|
||||||
|
if application.CurrentScene != application.SceneGame {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if raylib.IsKeyPressed(raylib.KeyEscape) {
|
||||||
|
scenePaused = !scenePaused
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.BeginDrawing()
|
||||||
|
raylib.ClearBackground(raylib.Black)
|
||||||
|
|
||||||
|
raylib.DrawText("Game", 100, 100, 20, raylib.White)
|
||||||
|
|
||||||
|
if scenePaused {
|
||||||
|
raylib.DrawRectangle(0, 0, application.WindowWidth, application.WindowHeight, raylib.Fade(raylib.Black, 0.5))
|
||||||
|
raylib.DrawText("Paused", 10, 10, 20, raylib.White)
|
||||||
|
raylib.DrawLine(10, 40, 790, 40, raylib.White)
|
||||||
|
if gui.Button(raylib.NewRectangle(application.WindowWidth-110, 10, 100, 20), "Unpause") {
|
||||||
|
scenePaused = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if gui.Button(raylib.NewRectangle(10, 50, 100, 20), "Main Menu") {
|
||||||
|
application.CurrentScene = application.SceneTitle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.EndDrawing()
|
||||||
|
}
|
||||||
|
|
||||||
|
// unload resources here
|
||||||
|
}
|
94
scenes/options.go
Normal file
94
scenes/options.go
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
package scenes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ColouringApp/application"
|
||||||
|
"fmt"
|
||||||
|
gui "github.com/gen2brain/raylib-go/raygui"
|
||||||
|
raylib "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Options() {
|
||||||
|
var (
|
||||||
|
centerPos float32 = 10
|
||||||
|
backPos float32 = -application.WindowWidth + 10
|
||||||
|
forwardPos float32 = application.WindowWidth + 10
|
||||||
|
|
||||||
|
rootPanelPos = true
|
||||||
|
controlsPanelPos = false
|
||||||
|
graphicPanelPos = false
|
||||||
|
|
||||||
|
rootPos = centerPos
|
||||||
|
controlsPos = forwardPos
|
||||||
|
graphicPos = forwardPos
|
||||||
|
)
|
||||||
|
// load resources here
|
||||||
|
|
||||||
|
fmt.Println("Options")
|
||||||
|
|
||||||
|
for !application.ShouldQuit {
|
||||||
|
application.ShouldQuit = raylib.WindowShouldClose()
|
||||||
|
if application.CurrentScene != application.SceneOptions {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.BeginDrawing()
|
||||||
|
raylib.ClearBackground(raylib.Black)
|
||||||
|
|
||||||
|
raylib.DrawText("Options", 10, 10, 20, raylib.White)
|
||||||
|
raylib.DrawLine(10, 40, 790, 40, raylib.White)
|
||||||
|
if gui.Button(raylib.NewRectangle(application.WindowWidth-110, 10, 100, 20), "Main Menu") {
|
||||||
|
application.CurrentScene = application.SceneTitle
|
||||||
|
}
|
||||||
|
|
||||||
|
// ROOT PANEL FOR SETTINGS
|
||||||
|
{
|
||||||
|
if rootPanelPos {
|
||||||
|
rootPos = raylib.Lerp(rootPos, centerPos, 0.1)
|
||||||
|
} else {
|
||||||
|
rootPos = raylib.Lerp(rootPos, backPos, 0.1)
|
||||||
|
}
|
||||||
|
if gui.Button(raylib.NewRectangle(rootPos, 50, 100, 20), "Controls") {
|
||||||
|
rootPanelPos = false
|
||||||
|
controlsPanelPos = true
|
||||||
|
}
|
||||||
|
if gui.Button(raylib.NewRectangle(rootPos, 80, 100, 20), "Graphics") {
|
||||||
|
rootPanelPos = false
|
||||||
|
graphicPanelPos = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONTROLS PANEL
|
||||||
|
{
|
||||||
|
if controlsPanelPos {
|
||||||
|
controlsPos = raylib.Lerp(controlsPos, centerPos, 0.1)
|
||||||
|
} else {
|
||||||
|
controlsPos = raylib.Lerp(controlsPos, forwardPos, 0.1)
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.DrawText("Controls", int32(controlsPos), 50, 20, raylib.White)
|
||||||
|
if gui.Button(raylib.NewRectangle(controlsPos, 80, 100, 20), "Back") {
|
||||||
|
rootPanelPos = true
|
||||||
|
controlsPanelPos = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GRAPHICS PANEL
|
||||||
|
{
|
||||||
|
if graphicPanelPos {
|
||||||
|
graphicPos = raylib.Lerp(graphicPos, centerPos, 0.1)
|
||||||
|
} else {
|
||||||
|
graphicPos = raylib.Lerp(graphicPos, forwardPos, 0.1)
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.DrawText("Graphics", int32(graphicPos), 50, 20, raylib.White)
|
||||||
|
if gui.Button(raylib.NewRectangle(graphicPos, 80, 100, 20), "Back") {
|
||||||
|
rootPanelPos = true
|
||||||
|
graphicPanelPos = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.EndDrawing()
|
||||||
|
}
|
||||||
|
|
||||||
|
// unload resources here
|
||||||
|
}
|
43
scenes/title.go
Normal file
43
scenes/title.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package scenes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ColouringApp/application"
|
||||||
|
|
||||||
|
gui "github.com/gen2brain/raylib-go/raygui"
|
||||||
|
raylib "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Title() {
|
||||||
|
var (
|
||||||
|
titleText = "Example Game"
|
||||||
|
)
|
||||||
|
|
||||||
|
// load resources here
|
||||||
|
|
||||||
|
for !application.ShouldQuit {
|
||||||
|
application.ShouldQuit = raylib.WindowShouldClose()
|
||||||
|
if application.CurrentScene != application.SceneTitle {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.BeginDrawing()
|
||||||
|
raylib.ClearBackground(raylib.Black)
|
||||||
|
|
||||||
|
raylib.DrawText(titleText, 10, 10, 20, raylib.White)
|
||||||
|
raylib.DrawLine(10, 40, 790, 40, raylib.White)
|
||||||
|
|
||||||
|
if gui.Button(raylib.NewRectangle(10, 50, 100, 20), "Start") {
|
||||||
|
application.CurrentScene = application.SceneGame
|
||||||
|
}
|
||||||
|
if gui.Button(raylib.NewRectangle(10, 80, 100, 20), "Options") {
|
||||||
|
application.CurrentScene = application.SceneOptions
|
||||||
|
}
|
||||||
|
if gui.Button(raylib.NewRectangle(10, 110, 100, 20), "Quit") {
|
||||||
|
application.ShouldQuit = true
|
||||||
|
}
|
||||||
|
|
||||||
|
raylib.EndDrawing()
|
||||||
|
}
|
||||||
|
|
||||||
|
// unload resources here
|
||||||
|
}
|
Loading…
Reference in a new issue