gofmt -s -w -l .
This commit is contained in:
parent
2243b93c92
commit
f3d7d84178
9 changed files with 298 additions and 298 deletions
|
@ -17,9 +17,9 @@ import (
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
func main() {
|
func main() {
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -31,7 +31,7 @@ func DrawScene() {
|
||||||
rl.DrawPlane(rl.Vector3{0, 0, 0}, rl.Vector2{50, 50}, rl.Beige) // Simple world plane
|
rl.DrawPlane(rl.Vector3{0, 0, 0}, rl.Vector2{50, 50}, rl.Beige) // Simple world plane
|
||||||
|
|
||||||
for x := -float32(count * spacing); x <= count*spacing; x += spacing {
|
for x := -float32(count * spacing); x <= count*spacing; x += spacing {
|
||||||
for z :=-float32(count * spacing); z <= count*spacing; z += spacing {
|
for z := -float32(count * spacing); z <= count*spacing; z += spacing {
|
||||||
rl.DrawCube(rl.Vector3{x, 1.5, z}, 1, 1, 1, rl.Lime)
|
rl.DrawCube(rl.Vector3{x, 1.5, z}, 1, 1, 1, rl.Lime)
|
||||||
rl.DrawCube(rl.Vector3{x, 0.5, z}, 0.25, 1, 0.25, rl.Brown)
|
rl.DrawCube(rl.Vector3{x, 0.5, z}, 0.25, 1, 0.25, rl.Brown)
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ func DrawScene() {
|
||||||
rl.DrawCube(cameraPlayer2.Position, 1, 1, 1, rl.Blue)
|
rl.DrawCube(cameraPlayer2.Position, 1, 1, 1, rl.Blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
func main() {
|
func main() {
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -14,7 +14,7 @@ func main() {
|
||||||
camera.Position = rl.NewVector3(10.0, 10.0, 10.0) // Camera position
|
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.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.Up = rl.NewVector3(0.0, 1.0, 0.0) // Camera up vector (rotation towards target)
|
||||||
camera.Fovy = 45.0 // Camera field-of-view Y
|
camera.Fovy = 45.0 // Camera field-of-view Y
|
||||||
|
|
||||||
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
||||||
cubeScreenPosition := rl.Vector2{}
|
cubeScreenPosition := rl.Vector2{}
|
||||||
|
|
|
@ -1,277 +1,277 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib - sample game: arkanoid
|
* raylib - sample game: arkanoid
|
||||||
*
|
*
|
||||||
* Sample game Marc Palau and Ramon Santamaria
|
* Sample game Marc Palau and Ramon Santamaria
|
||||||
*
|
*
|
||||||
* This game has been created using raylib v1.3 (www.raylib.com)
|
* 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)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Ported to raylib-go by Nehpe (@nehpe), July 2019
|
* Ported to raylib-go by Nehpe (@nehpe), July 2019
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
rl "github.com/gen2brain/raylib-go/raylib"
|
rl "github.com/gen2brain/raylib-go/raylib"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PLAYER_MAX_LIFE = 5
|
PLAYER_MAX_LIFE = 5
|
||||||
LINES_OF_BRICKS = 5
|
LINES_OF_BRICKS = 5
|
||||||
BRICKS_PER_LINE = 20
|
BRICKS_PER_LINE = 20
|
||||||
)
|
)
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
position rl.Vector2
|
position rl.Vector2
|
||||||
size rl.Vector2
|
size rl.Vector2
|
||||||
life int
|
life int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ball struct {
|
type Ball struct {
|
||||||
position rl.Vector2
|
position rl.Vector2
|
||||||
speed rl.Vector2
|
speed rl.Vector2
|
||||||
radius float32
|
radius float32
|
||||||
active bool
|
active bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Brick struct {
|
type Brick struct {
|
||||||
position rl.Vector2
|
position rl.Vector2
|
||||||
active bool
|
active bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
screenWidth = 800
|
screenWidth = 800
|
||||||
screenHeight = 450
|
screenHeight = 450
|
||||||
)
|
)
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
gameOver bool
|
gameOver bool
|
||||||
pause bool
|
pause bool
|
||||||
player Player
|
player Player
|
||||||
ball Ball
|
ball Ball
|
||||||
brick [LINES_OF_BRICKS][BRICKS_PER_LINE]Brick
|
brick [LINES_OF_BRICKS][BRICKS_PER_LINE]Brick
|
||||||
brickSize rl.Vector2
|
brickSize rl.Vector2
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rl.InitWindow(screenWidth, screenHeight, "sample game: arkanoid")
|
rl.InitWindow(screenWidth, screenHeight, "sample game: arkanoid")
|
||||||
|
|
||||||
// Init game
|
// Init game
|
||||||
game := NewGame()
|
game := NewGame()
|
||||||
game.gameOver = true
|
game.gameOver = true
|
||||||
|
|
||||||
rl.SetTargetFPS(60)
|
rl.SetTargetFPS(60)
|
||||||
|
|
||||||
for !rl.WindowShouldClose() {
|
for !rl.WindowShouldClose() {
|
||||||
game.Update()
|
game.Update()
|
||||||
|
|
||||||
game.Draw()
|
game.Draw()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.CloseWindow()
|
rl.CloseWindow()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For android
|
// For android
|
||||||
func init() {
|
func init() {
|
||||||
rl.SetCallbackFunc(main)
|
rl.SetCallbackFunc(main)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGame - Create a new game instance
|
// NewGame - Create a new game instance
|
||||||
func NewGame() (g Game) {
|
func NewGame() (g Game) {
|
||||||
g.Init()
|
g.Init()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init - initialize game
|
// Init - initialize game
|
||||||
func (g *Game) Init() {
|
func (g *Game) Init() {
|
||||||
g.brickSize = rl.Vector2{float32(rl.GetScreenWidth() / BRICKS_PER_LINE), 40}
|
g.brickSize = rl.Vector2{float32(rl.GetScreenWidth() / BRICKS_PER_LINE), 40}
|
||||||
|
|
||||||
// Initialize player
|
// Initialize player
|
||||||
g.player.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight * 7 / 8)}
|
g.player.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight * 7 / 8)}
|
||||||
g.player.size = rl.Vector2{float32(screenWidth / 10), 20}
|
g.player.size = rl.Vector2{float32(screenWidth / 10), 20}
|
||||||
g.player.life = PLAYER_MAX_LIFE
|
g.player.life = PLAYER_MAX_LIFE
|
||||||
|
|
||||||
// Initialize ball
|
// Initialize ball
|
||||||
g.ball.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight*7/8 - 30)}
|
g.ball.position = rl.Vector2{float32(screenWidth / 2), float32(screenHeight*7/8 - 30)}
|
||||||
g.ball.speed = rl.Vector2{0, 0}
|
g.ball.speed = rl.Vector2{0, 0}
|
||||||
g.ball.radius = 7
|
g.ball.radius = 7
|
||||||
g.ball.active = false
|
g.ball.active = false
|
||||||
|
|
||||||
initialDownPosition := int(50)
|
initialDownPosition := int(50)
|
||||||
|
|
||||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
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].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
|
g.brick[i][j].active = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update - update game state
|
// Update - update game state
|
||||||
func (g *Game) Update() {
|
func (g *Game) Update() {
|
||||||
if !g.gameOver {
|
if !g.gameOver {
|
||||||
|
|
||||||
if rl.IsKeyPressed(rl.KeyP) {
|
if rl.IsKeyPressed(rl.KeyP) {
|
||||||
g.pause = !g.pause
|
g.pause = !g.pause
|
||||||
}
|
}
|
||||||
|
|
||||||
if !g.pause {
|
if !g.pause {
|
||||||
|
|
||||||
if rl.IsKeyDown(rl.KeyLeft) || rl.IsKeyDown(rl.KeyA) {
|
if rl.IsKeyDown(rl.KeyLeft) || rl.IsKeyDown(rl.KeyA) {
|
||||||
g.player.position.X -= 5
|
g.player.position.X -= 5
|
||||||
}
|
}
|
||||||
if (g.player.position.X - g.player.size.X/2) <= 0 {
|
if (g.player.position.X - g.player.size.X/2) <= 0 {
|
||||||
g.player.position.X = g.player.size.X / 2
|
g.player.position.X = g.player.size.X / 2
|
||||||
}
|
}
|
||||||
if rl.IsKeyDown(rl.KeyRight) || rl.IsKeyDown(rl.KeyD) {
|
if rl.IsKeyDown(rl.KeyRight) || rl.IsKeyDown(rl.KeyD) {
|
||||||
g.player.position.X += 5
|
g.player.position.X += 5
|
||||||
}
|
}
|
||||||
if (g.player.position.X + g.player.size.X/2) >= screenWidth {
|
if (g.player.position.X + g.player.size.X/2) >= screenWidth {
|
||||||
g.player.position.X = screenWidth - g.player.size.X/2
|
g.player.position.X = screenWidth - g.player.size.X/2
|
||||||
}
|
}
|
||||||
|
|
||||||
if !g.ball.active {
|
if !g.ball.active {
|
||||||
if rl.IsKeyPressed(rl.KeySpace) {
|
if rl.IsKeyPressed(rl.KeySpace) {
|
||||||
g.ball.active = true
|
g.ball.active = true
|
||||||
g.ball.speed = rl.Vector2{0, -5}
|
g.ball.speed = rl.Vector2{0, -5}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.ball.active {
|
if g.ball.active {
|
||||||
g.ball.position.X += g.ball.speed.X
|
g.ball.position.X += g.ball.speed.X
|
||||||
g.ball.position.Y += g.ball.speed.Y
|
g.ball.position.Y += g.ball.speed.Y
|
||||||
} else {
|
} else {
|
||||||
g.ball.position = rl.Vector2{g.player.position.X, screenHeight*7/8 - 30}
|
g.ball.position = rl.Vector2{g.player.position.X, screenHeight*7/8 - 30}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collision logic: ball vs walls
|
// Collision logic: ball vs walls
|
||||||
if ((g.ball.position.X + g.ball.radius) >= screenWidth) || ((g.ball.position.X - g.ball.radius) <= 0) {
|
if ((g.ball.position.X + g.ball.radius) >= screenWidth) || ((g.ball.position.X - g.ball.radius) <= 0) {
|
||||||
g.ball.speed.X *= -1
|
g.ball.speed.X *= -1
|
||||||
}
|
}
|
||||||
if (g.ball.position.Y - g.ball.radius) <= 0 {
|
if (g.ball.position.Y - g.ball.radius) <= 0 {
|
||||||
g.ball.speed.Y *= -1
|
g.ball.speed.Y *= -1
|
||||||
}
|
}
|
||||||
if (g.ball.position.Y + g.ball.radius) >= screenHeight {
|
if (g.ball.position.Y + g.ball.radius) >= screenHeight {
|
||||||
g.ball.speed = rl.Vector2{0, 0}
|
g.ball.speed = rl.Vector2{0, 0}
|
||||||
g.ball.active = false
|
g.ball.active = false
|
||||||
|
|
||||||
g.player.life--
|
g.player.life--
|
||||||
}
|
}
|
||||||
if (rl.CheckCollisionCircleRec(g.ball.position, g.ball.radius,
|
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})) {
|
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 {
|
if g.ball.speed.Y > 0 {
|
||||||
g.ball.speed.Y *= -1
|
g.ball.speed.Y *= -1
|
||||||
g.ball.speed.X = (g.ball.position.X - g.player.position.X) / (g.player.size.X / 2) * 5
|
g.ball.speed.X = (g.ball.position.X - g.player.position.X) / (g.player.size.X / 2) * 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Collision logic: ball vs bricks
|
// Collision logic: ball vs bricks
|
||||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||||
if g.brick[i][j].active {
|
if g.brick[i][j].active {
|
||||||
if ((g.ball.position.Y - g.ball.radius) <= (g.brick[i][j].position.Y + g.brickSize.Y/2)) &&
|
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)) &&
|
((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)) &&
|
((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) {
|
(g.ball.speed.Y < 0) {
|
||||||
// Hit below
|
// Hit below
|
||||||
g.brick[i][j].active = false
|
g.brick[i][j].active = false
|
||||||
g.ball.speed.Y *= -1
|
g.ball.speed.Y *= -1
|
||||||
} else if ((g.ball.position.Y + g.ball.radius) >= (g.brick[i][j].position.Y - g.brickSize.Y/2)) &&
|
} 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)) &&
|
((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)) &&
|
((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) {
|
(g.ball.speed.Y > 0) {
|
||||||
// Hit above
|
// Hit above
|
||||||
g.brick[i][j].active = false
|
g.brick[i][j].active = false
|
||||||
g.ball.speed.Y *= -1
|
g.ball.speed.Y *= -1
|
||||||
} else if ((g.ball.position.X + g.ball.radius) >= (g.brick[i][j].position.X - g.brickSize.X/2)) &&
|
} 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)) &&
|
((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)) &&
|
((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) {
|
(g.ball.speed.X > 0) {
|
||||||
// Hit left
|
// Hit left
|
||||||
g.brick[i][j].active = false
|
g.brick[i][j].active = false
|
||||||
g.ball.speed.X *= -1
|
g.ball.speed.X *= -1
|
||||||
} else if ((g.ball.position.X - g.ball.radius) <= (g.brick[i][j].position.X + g.brickSize.X/2)) &&
|
} 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)) &&
|
((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)) &&
|
((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) {
|
(g.ball.speed.X < 0) {
|
||||||
// Hit right
|
// Hit right
|
||||||
g.brick[i][j].active = false
|
g.brick[i][j].active = false
|
||||||
g.ball.speed.X *= -1
|
g.ball.speed.X *= -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Game over logic
|
// Game over logic
|
||||||
if g.player.life <= 0 {
|
if g.player.life <= 0 {
|
||||||
g.gameOver = true
|
g.gameOver = true
|
||||||
} else {
|
} else {
|
||||||
g.gameOver = true
|
g.gameOver = true
|
||||||
|
|
||||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||||
if g.brick[i][j].active {
|
if g.brick[i][j].active {
|
||||||
g.gameOver = false
|
g.gameOver = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||||
g.Init()
|
g.Init()
|
||||||
g.gameOver = false
|
g.gameOver = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw - draw game
|
// Draw - draw game
|
||||||
func (g *Game) Draw() {
|
func (g *Game) Draw() {
|
||||||
rl.BeginDrawing()
|
rl.BeginDrawing()
|
||||||
rl.ClearBackground(rl.White)
|
rl.ClearBackground(rl.White)
|
||||||
|
|
||||||
if !g.gameOver {
|
if !g.gameOver {
|
||||||
// Draw player bar
|
// 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)
|
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
|
// Draw player lives
|
||||||
for i := 0; i < g.player.life; i++ {
|
for i := 0; i < g.player.life; i++ {
|
||||||
rl.DrawRectangle(int32(20+40*i), screenHeight-30, 35, 10, rl.LightGray)
|
rl.DrawRectangle(int32(20+40*i), screenHeight-30, 35, 10, rl.LightGray)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw Ball
|
// Draw Ball
|
||||||
rl.DrawCircleV(g.ball.position, g.ball.radius, rl.Maroon)
|
rl.DrawCircleV(g.ball.position, g.ball.radius, rl.Maroon)
|
||||||
|
|
||||||
for i := 0; i < LINES_OF_BRICKS; i++ {
|
for i := 0; i < LINES_OF_BRICKS; i++ {
|
||||||
for j := 0; j < BRICKS_PER_LINE; j++ {
|
for j := 0; j < BRICKS_PER_LINE; j++ {
|
||||||
if g.brick[i][j].active {
|
if g.brick[i][j].active {
|
||||||
if (i+j)%2 == 0 {
|
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)
|
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 {
|
} 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)
|
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 {
|
if g.pause {
|
||||||
rl.DrawText("GAME PAUSED", screenWidth/2-rl.MeasureText("GAME PAUSED", 40)/2, screenHeight/2+screenHeight/4-40, 40, rl.Gray)
|
rl.DrawText("GAME PAUSED", screenWidth/2-rl.MeasureText("GAME PAUSED", 40)/2, screenHeight/2+screenHeight/4-40, 40, rl.Gray)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
str := "PRESS [ENTER] TO PLAY AGAIN"
|
str := "PRESS [ENTER] TO PLAY AGAIN"
|
||||||
x := int(rl.GetScreenWidth()/2) - int(rl.MeasureText(str, 20)/2)
|
x := int(rl.GetScreenWidth()/2) - int(rl.MeasureText(str, 20)/2)
|
||||||
y := rl.GetScreenHeight()/2 - 50
|
y := rl.GetScreenHeight()/2 - 50
|
||||||
rl.DrawText(str, int32(x), int32(y), 20, rl.Gray)
|
rl.DrawText(str, int32(x), int32(y), 20, rl.Gray)
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
rl "github.com/gen2brain/raylib-go/raylib"
|
gui "github.com/gen2brain/raylib-go/raygui"
|
||||||
gui "github.com/gen2brain/raylib-go/raygui"
|
rl "github.com/gen2brain/raylib-go/raylib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -46,9 +46,9 @@ import (
|
||||||
//#define RAYGUI_CUSTOM_ICONS // It requires providing gui_icons.h in the same directory
|
//#define RAYGUI_CUSTOM_ICONS // It requires providing gui_icons.h in the same directory
|
||||||
//#include "gui_icons.h" // External icons data provided, it can be generated with rGuiIcons tool
|
//#include "gui_icons.h" // External icons data provided, it can be generated with rGuiIcons tool
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
func main() {
|
func main() {
|
||||||
// Initialization
|
// Initialization
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
func main() {
|
func main() {
|
||||||
// Initialization
|
// Initialization
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -30,9 +30,9 @@ import (
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -85,10 +85,10 @@ func main() {
|
||||||
|
|
||||||
if showContentArea {
|
if showContentArea {
|
||||||
rl.DrawRectangle(
|
rl.DrawRectangle(
|
||||||
int32(panelRec.X+panelScroll.X),
|
int32(panelRec.X+panelScroll.X),
|
||||||
int32(panelRec.Y+panelScroll.Y),
|
int32(panelRec.Y+panelScroll.Y),
|
||||||
int32(panelContentRec.Width),
|
int32(panelContentRec.Width),
|
||||||
int32(panelContentRec.Height),
|
int32(panelContentRec.Height),
|
||||||
rl.Fade(rl.Red, 0.1),
|
rl.Fade(rl.Red, 0.1),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ func DrawStyleEditControls() {
|
||||||
gui.Spinner(rl.Rectangle{670, 240, 90, 20}, "", &style, 0, 14, false)
|
gui.Spinner(rl.Rectangle{670, 240, 90, 20}, "", &style, 0, 14, false)
|
||||||
gui.SetStyle(gui.SCROLLBAR, gui.SLIDER_PADDING, style)
|
gui.SetStyle(gui.SCROLLBAR, gui.SLIDER_PADDING, style)
|
||||||
|
|
||||||
style = boolToint32( gui.CheckBox(rl.Rectangle{565, 280, 20, 20}, "ARROWS_VISIBLE", int32Tobool(gui.GetStyle(gui.SCROLLBAR, gui.ARROWS_VISIBLE))))
|
style = boolToint32(gui.CheckBox(rl.Rectangle{565, 280, 20, 20}, "ARROWS_VISIBLE", int32Tobool(gui.GetStyle(gui.SCROLLBAR, gui.ARROWS_VISIBLE))))
|
||||||
gui.SetStyle(gui.SCROLLBAR, gui.ARROWS_VISIBLE, style)
|
gui.SetStyle(gui.SCROLLBAR, gui.ARROWS_VISIBLE, style)
|
||||||
|
|
||||||
style = gui.GetStyle(gui.SCROLLBAR, gui.SLIDER_PADDING)
|
style = gui.GetStyle(gui.SCROLLBAR, gui.SLIDER_PADDING)
|
||||||
|
@ -159,7 +159,7 @@ func DrawStyleEditControls() {
|
||||||
} else {
|
} else {
|
||||||
text = "SCROLLBAR: RIGHT"
|
text = "SCROLLBAR: RIGHT"
|
||||||
}
|
}
|
||||||
style = boolToint32( gui.Toggle(rl.Rectangle{560, 110, 200, 35}, text, int32Tobool(gui.GetStyle(gui.LISTVIEW, gui.SCROLLBAR_SIDE))))
|
style = boolToint32(gui.Toggle(rl.Rectangle{560, 110, 200, 35}, text, int32Tobool(gui.GetStyle(gui.LISTVIEW, gui.SCROLLBAR_SIDE))))
|
||||||
gui.SetStyle(gui.LISTVIEW, gui.SCROLLBAR_SIDE, style)
|
gui.SetStyle(gui.LISTVIEW, gui.SCROLLBAR_SIDE, style)
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -422,7 +422,7 @@ func genSource(w io.Writer, data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//genBin generates go-bindata file
|
// genBin generates go-bindata file
|
||||||
func genBin(base string) error {
|
func genBin(base string) error {
|
||||||
cfg := bindata.NewConfig()
|
cfg := bindata.NewConfig()
|
||||||
cfg.NoCompress = true
|
cfg.NoCompress = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue