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() {
|
func drawSquares() {
|
||||||
for index, element := range squares {
|
for index, element := range squares {
|
||||||
if debug {
|
debugLog(debug, fmt.Sprintln(index, element.X))
|
||||||
fmt.Println(index, element.X)
|
|
||||||
}
|
|
||||||
|
|
||||||
rl.DrawRectangleV(element, rl.Vector2{X: float32(squareSize), Y: float32(squareSize)}, rl.LightGray)
|
rl.DrawRectangleV(element, rl.Vector2{X: float32(squareSize), Y: float32(squareSize)}, rl.LightGray)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,25 +90,17 @@ func moveBall() {
|
||||||
if rl.IsKeyDown(rl.KeyS) {
|
if rl.IsKeyDown(rl.KeyS) {
|
||||||
speed += 2
|
speed += 2
|
||||||
}
|
}
|
||||||
if rl.IsKeyDown(rl.KeyRight) {
|
if rl.IsKeyDown(rl.KeyRight) && !checkCollision(rl.Vector2{X: ballpos.X + float32(speed), Y: ballpos.Y}) {
|
||||||
if !checkCollision(rl.Vector2{X: ballpos.X + float32(speed), Y: ballpos.Y}) {
|
ballpos.X = ballpos.X + float32(speed)
|
||||||
ballpos.X = ballpos.X + float32(speed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if rl.IsKeyDown(rl.KeyLeft) {
|
if rl.IsKeyDown(rl.KeyLeft) && !checkCollision(rl.Vector2{X: ballpos.X - float32(speed), Y: ballpos.Y}) {
|
||||||
if !checkCollision(rl.Vector2{X: ballpos.X - float32(speed), Y: ballpos.Y}) {
|
ballpos.X = ballpos.X - float32(speed)
|
||||||
ballpos.X = ballpos.X - float32(speed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if rl.IsKeyDown(rl.KeyUp) {
|
if rl.IsKeyDown(rl.KeyUp) && !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y - float32(speed)}) {
|
||||||
if !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y - float32(speed)}) {
|
|
||||||
ballpos.Y = ballpos.Y - float32(speed)
|
ballpos.Y = ballpos.Y - float32(speed)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if rl.IsKeyDown(rl.KeyDown) {
|
if rl.IsKeyDown(rl.KeyDown) && !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y + float32(speed)}) {
|
||||||
if !checkCollision(rl.Vector2{X: ballpos.X, Y: ballpos.Y + float32(speed)}) {
|
ballpos.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