Skip to content

Commit

Permalink
version with skybox manipulations
Browse files Browse the repository at this point in the history
  • Loading branch information
mki1967 committed Mar 5, 2018
1 parent 71bebfe commit 54c01e6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions assets/scripts/zenity-help.bash
Expand Up @@ -44,5 +44,7 @@ Key press actions:
P - pause the game
X - reload random stage
Q - display your score and the number of remaining tokens
S - toggle SKYBOX ON/OFF
N - new SKYBOX
EOF

12 changes: 9 additions & 3 deletions game.go
Expand Up @@ -12,8 +12,8 @@ import (
"math"
"strconv"
// "time"
// "math/rand"
_ "image/png"
"math/rand"
)

const BoxMargin = 30 // margin for bounding box of the stage
Expand All @@ -27,6 +27,8 @@ var NumberOfTokens = 10
const VerticalSectors = 6 // vertical dimmension of sectors array
const HorizontalSectors = 6 // horizontal dimmension of sectors array

const skyboxChance = 0.5 // the chance of having withSkybox==true on the new stage

// data structure for the game
type Mki3dGame struct {
// assets info
Expand Down Expand Up @@ -69,7 +71,8 @@ type Mki3dGame struct {

JustCollected bool // token has been just collected! Do some clebrations in Redraw ...

Skybox sbxgpu.SbxGpu // skybox
Skybox sbxgpu.SbxGpu // skybox
withSkybox bool // draw the skybox?
}

// Make game structure with the shader and without any data.
Expand Down Expand Up @@ -148,6 +151,7 @@ func (game *Mki3dGame) Init() (err error) {
}

game.Skybox.RenderRandomCube() // make random cube
game.withSkybox = (rand.Float64() < skyboxChance)
fmt.Println("NEW STAGE! Collect ", game.TokensRemaining, " tokens.")
// ZenityInfo("NEW STAGE! Collect "+strconv.Itoa( game.TokensRemaining)+ " tokens.", "2")
// init time probe
Expand Down Expand Up @@ -468,7 +472,9 @@ func (game *Mki3dGame) Redraw() {
game.DrawTokens()
// draw monsters
game.DrawMonsters()
game.Skybox.DrawSkybox(game.StageDSPtr.UniPtr.ViewUni, game.StageDSPtr.UniPtr.ProjectionUni) // draw the skybox
if game.withSkybox {
game.Skybox.DrawSkybox(game.StageDSPtr.UniPtr.ViewUni, game.StageDSPtr.UniPtr.ProjectionUni) // draw the skybox
}

}
if game.CurrentAction == nil {
Expand Down
3 changes: 3 additions & 0 deletions help.go
Expand Up @@ -20,6 +20,9 @@ Key press actions:
L - set the diffuse light direction perpendicular to the screen
P - pause the game
X - reload random stage
S - toggle SKYBOX ON/OFF
N - new SKYBOX
Or press the mouse on the screen sectors:
Expand Down
13 changes: 13 additions & 0 deletions key-callback.go
Expand Up @@ -103,6 +103,19 @@ func (g *Mki3dGame) KeyCallback(w *glfw.Window, key glfw.Key, scancode int, acti
"\nREMAINING TOKENS ON THIS STAGE: "+strconv.Itoa(g.TokensRemaining),
"4")

case key == glfw.KeyS && mods == 0: /* Togle skybox */
g.withSkybox = !g.withSkybox
ZenityInfo(
"WITH SKYBOX: "+strconv.FormatBool(g.withSkybox),
"1")

case key == glfw.KeyN && mods == 0: /* Togle skybox */
ZenityInfo(
"NEW SKYBOX !",
"1")
g.Skybox.RenderRandomCube()
g.withSkybox = true

}
}
}

0 comments on commit 54c01e6

Please sign in to comment.