forked from gnawmon/ballsoffline
less nested, making debug thing easier (?)
This commit is contained in:
parent
dbe47111d3
commit
eb65c2c609
27
bf.go
27
bf.go
|
@ -74,10 +74,7 @@ func drawPaint() {
|
|||
|
||||
func drawSquares() {
|
||||
for index, element := range squares {
|
||||
if debug {
|
||||
fmt.Println(index, element.X)
|
||||
}
|
||||
|
||||
debugLog(debug, fmt.Sprintln(index, element.X))
|
||||
rl.DrawRectangleV(element, rl.Vector2{X: float32(squareSize), Y: float32(squareSize)}, rl.LightGray)
|
||||
}
|
||||
}
|
||||
|
@ -93,25 +90,17 @@ func moveBall() {
|
|||
if rl.IsKeyDown(rl.KeyS) {
|
||||
speed += 2
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
if !checkCollision(rl.Vector2{X: ballpos.X + float32(speed), Y: ballpos.Y}) {
|
||||
ballpos.X = ballpos.X + float32(speed)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyRight) && !checkCollision(rl.Vector2{X: ballpos.X + float32(speed), Y: ballpos.Y}) {
|
||||
ballpos.X = ballpos.X + float32(speed)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyLeft) {
|
||||
if !checkCollision(rl.Vector2{X: ballpos.X - float32(speed), Y: ballpos.Y}) {
|
||||
ballpos.X = ballpos.X - float32(speed)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyLeft) && !checkCollision(rl.Vector2{X: ballpos.X - float32(speed), Y: ballpos.Y}) {
|
||||
ballpos.X = ballpos.X - float32(speed)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyUp) {
|
||||
if !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y - float32(speed)}) {
|
||||
if rl.IsKeyDown(rl.KeyUp) && !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y - float32(speed)}) {
|
||||
ballpos.Y = ballpos.Y - float32(speed)
|
||||
}
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyDown) {
|
||||
if !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y + float32(speed)}) {
|
||||
ballpos.Y = ballpos.Y + float32(speed)
|
||||
}
|
||||
if rl.IsKeyDown(rl.KeyDown) && !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y + float32(speed)}) {
|
||||
ballpos.Y = ballpos.Y + float32(speed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func debugLog(debug bool, print string) {
|
||||
if debug {
|
||||
fmt.Println(print)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: add other debuging code here so it's be more simple to read bf.go
|
||||
*/
|
Loading…
Reference in New Issue